Skip to content

Commit 570dc99

Browse files
committed
Merge pull request #44 from plotly/update-contributing
Adds some files to make contributing a little more straightforward.
2 parents b6fda38 + 7967c74 commit 570dc99

File tree

4 files changed

+165
-4
lines changed

4 files changed

+165
-4
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ Now you can download, design, and upload Plotly figures--all from Python.
1717

1818
###Contributing?
1919

20-
This project uses git submodules! After forking and cloning, in your terminal
21-
run `make` from inside your local `python-api/` repository. That will spit out
22-
the `make_instructions.txt` file. Checkout the *Getting started* section in
23-
there for more info.
20+
Heck yeah! We've got suggestions. We've got guides!
21+
-> checkout `contributing.md`
2422

2523
###Get in touch
2624

contributing.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
The bottom line. Follow your Nose, or our Nose. Write-run-love tests :fist:.
2+
3+
##Setup
4+
5+
###Fork, Clone, Setup Your Version of the Plotly Python API
6+
7+
First, you'll need to *get* our project. This is the appropriate *clone* command (if you're unfamiliar with this process, https://help.github.com/articles/fork-a-repo):
8+
9+
**DO THIS (in the directory where you want the repo to live)**
10+
11+
```bash
12+
git clone https://github.com/plotly/python-api.git
13+
```
14+
15+
###Submodules
16+
17+
Second, this project uses git submodules! There both helpful and, at times, difficult to work with. The good news is you probably don't need to think about them! Just run the following shell command to make sure that your local repo is wired properly:
18+
19+
**DO THIS (run this command in your new `plotly-api` directory)**
20+
21+
```bash
22+
make setup_subs
23+
```
24+
25+
That's going to initialize the submodules we use in this project, update them so that they're synced to the proper commit, and copy files to the appropriate locations in your local repo.
26+
27+
Here's what you need to know: changes to any files inside the following directories **will get overwritten**. These are synced with the submodules, if you need to change functionality there, you will need to make a pull request in the appropriate sub project repository.
28+
- chunked_requests
29+
- graph_reference
30+
- mplexporter
31+
32+
Additionally, there are some project shortcuts that live in the `makefile` file. You can read all about this in the `make_instructions.txt` file. OR, just run:
33+
34+
```bash
35+
make readme
36+
```
37+
38+
###Making a Development Branch
39+
40+
Third, *don't* work in the `master` branch. As soon as you get your master branch ready, run:
41+
42+
**DO THIS (but change the branch name)**
43+
```bash
44+
git checkout -b my-dev-branch
45+
```
46+
47+
... where you should give your branch a more descriptive name than `my-dev-branch`
48+
49+
###Pull Request When Ready
50+
51+
Once you've made your changes (and hopefully written some tests...), make that pull request!
52+
53+
##Suggestions
54+
55+
###Local Python
56+
Setting up Python versions that *don't* require you to use `sudo` is a good idea. In addition, the core Python on your machine may not be the Python that we've developed in! Here are some nice guides for Mac, Windows, and Linux:
57+
- http://docs.python-guide.org/en/latest/starting/install/osx/
58+
- http://docs.python-guide.org/en/latest/starting/install/win/
59+
- http://docs.python-guide.org/en/latest/starting/install/linux/
60+
61+
###Virtualenv
62+
Virtualenv is a way to create Python environments on your machine that know nothing about one another. This is really helpful for ironing out dependency-problems arising from different versions of packages. Here's a nice guide on how to do this: http://docs.python-guide.org/en/latest/dev/virtualenvs/
63+
64+
###Alter Your PYTHONPATH
65+
The PYTHONPATH variable in your shell tells Python where to look for modules. Since you'll be developing, it'll be a pain to need to *install* Python every time you need to test some functionality (or at least ensure you're running code from the right directory...). You can easily make this change from a shell:
66+
67+
```bash
68+
export PYTHONPATH="/path/to/local/repo:$PYTHONPATH"
69+
```
70+
71+
Note, that's non-permanent. When you close the shell, that variable definition disappears. Also, `path/to/local/repo` is *your* specific repository path (e.g., `/Users/andrew/projects/python-api`).
72+
73+
###Why?
74+
75+
Now you can run the following code and be guaranteed to have a working development version that you can make changes to on-the-fly, test, and be confident will not break on other's machines!
76+
77+
```bash
78+
pip install -r requirements.txt
79+
pip install -r optional-requirements.txt
80+
export PYTHONPATH="/path/to/local/repo:$PYTHONPATH"
81+
```
82+
83+
##Dependencies
84+
85+
There's a short list of core dependencies you'll need installed in your Python environment to have any sort of fun with Plotly's Python API (see `requirements.txt`). Additionally, you're likely to have even more fun if you install some other requirements (see `optional-requirements.txt`).
86+
87+
###Dependencies and Virtualenv
88+
89+
If you decided to follow the suggestion about about the Virtualenv *and* you've run `source bin/activate` within your new virtualenv directory to activate it--you can run the following to install the core dependencies:
90+
91+
```bash
92+
pip install -r requirements.txt
93+
```
94+
95+
To install the optional dependencies:
96+
97+
```bash
98+
pip install -r optional-requirements.txt
99+
```
100+
101+
##Testing
102+
103+
Our API uses Nose to run tests. (https://nose.readthedocs.org/en/latest/)
104+
105+
###Running Tests
106+
107+
Since our tests cover *all* the functionality, to prevent tons of errors from showing up and having to parse through a messy output, you'll need to install `optional-requirements.txt` as explained above.
108+
109+
After you've done that, go ahead and follow (y)our Nose!
110+
111+
```bash
112+
nosetests -w plotly/tests
113+
```
114+
115+
Or for more *verbose* output:
116+
117+
```bash
118+
nosetests -w plotly/tests -v
119+
```
120+
121+
Either of those will run *every* test we've written for the Python API. You can get more granular by running something like:
122+
123+
```bash
124+
nosetests -w plotly/tests/test_plotly
125+
```
126+
127+
... or even more granular by running something like:
128+
129+
```bash
130+
nosetests plotly/tests/test_plotly/test_plot.py
131+
```
132+
133+
###Writing Tests
134+
135+
You're *strongly* encouraged to write tests that check your added functionality.
136+
137+
When you write a new test anywhere under the `tests` directory, if your PR gets accepted, that test will run in a virtual machine to ensure that future changes don't break your contributions!
138+
139+
<3 Team Plotly

optional-requirements.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Optional Dependencies for Additional Plotly Functionality ###
2+
### ###
3+
### To install, run: ###
4+
### $ pip install -r optional-requirements.txt ###
5+
### ###
6+
###################################################################
7+
8+
## matplotlylib dependencies ##
9+
matplotlib==1.3.1
10+
11+
## testing dependencies ##
12+
nose==1.3.3
13+
14+
## ipython dependencies ##
15+
ipython[all]

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Dependencies for Core Plotly Functionality ###
2+
### ###
3+
### To install, run: ###
4+
### $ pip install -r requirements.txt ###
5+
### ###
6+
###################################################
7+
8+
## http request dependencies ##
9+
requests==2.3.0

0 commit comments

Comments
 (0)