Skip to content

Commit 5a20f9e

Browse files
authored
Merge pull request #17 from Paperspace/fun-readme-graphic
Update README.md
2 parents f1c7b6f + dfe2c77 commit 5a20f9e

File tree

2 files changed

+28
-153
lines changed

2 files changed

+28
-153
lines changed

README.md

Lines changed: 27 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Paperspace Python
1+
![Artboard 1](https://user-images.githubusercontent.com/585865/59315146-781a3300-8c86-11e9-9b7d-0cbca81d4278.png)
2+
3+
Gradient CLI
24
=================
35

46
Release 0.2.2a0
@@ -9,7 +11,7 @@ See [releasenotes.md](https://github.com/Paperspace/paperspace-python/blob/maste
911

1012
Getting Started
1113
===============
12-
1. Make sure you have a Paperspace account set up. Go to http://paperspace.com
14+
1. Make sure you have a Paperspace account set up. Go to [http://paperspace.com](https://www.paperspace.com/account/signup?gradient=true)
1315
to register.
1416

1517
2. Use pip, pipenv, or conda to install the gradient package, e.g.:
@@ -33,42 +35,22 @@ Getting Started
3335
and then add `. ~/paperspace_complete.sh` to your `.bashrc`, `.zshrc` or `activate` script.
3436

3537
More: https://click.palletsprojects.com/en/7.x/bashcomplete/
36-
4. Download your api key by executing the following:
37-
38-
`gradient login`
39-
40-
Follow the prompts to enter your Paperspace email and password.
38+
4. Set your api key by executing the following:
4139

42-
You can also enter your credentials directly on the command line as follows:
43-
44-
`gradient login <email> <password> [<api_token_name>]`
40+
`gradient apiKey <your-api-key-here>`
4541

4642
Note: your api key is cached in ~/.paperspace/config.json
43+
4744
You can remove your cached api key by executing:
4845

4946
`gradient logout`
5047

51-
5. Run the sample script hello.py using Python:
52-
53-
`python hello.py`
54-
55-
The source of this sample script shows how a script can automatically run itself on the Paperspace job cluster node:
56-
57-
```
58-
import paperspace
59-
60-
paperspace.run()
61-
62-
print('hello gradient!')
63-
```
64-
65-
Note: the source is modified before transfer to the job cluster in order to remove imported `paperspace` references.
48+
5. Use gradient to run a python script remotely:
6649

67-
6. Use gradient to run a python script remotely:
68-
69-
`gradient run myscript.py`
50+
`gradient run myscript.py --name <your-new-job-name>`
7051

7152
The script will be run on the Paperspace job cluster node, and its output will be logged locally.
53+
Note: this will archive and upload your entire current working directory to our server if `--workspace` was not provided
7254

7355

7456
Create/create and start experiment
@@ -84,79 +66,25 @@ To create and immediately start new experiment use:
8466
gradient experiments run [type] [--options]
8567
```
8668

87-
For a full list of available commands run `paperspace experiments --help`.
69+
For a full list of available commands run `gradient experiments --help`.
8870
Note that some options are required to create new experiment.
8971

9072

91-
Specifying jobs options within a script
92-
=======================================
93-
This example shows how a script can specify paperspace jobs options for itself, such as `project` name, `machineType`, and a `container` reference:
94-
95-
# tests/test_remote.py - runs itself on paperspace, demonstrates setting jobs create options
96-
import os
97-
import paperspace
98-
99-
paperspace.run({'project': 'myproject', 'machineType': 'P5000',
100-
'container': 'paperspace/tensorflow-python'})
101-
102-
print(os.getcwd())
103-
print('something useful')
104-
105-
106-
Automatic running of a python script remotely
107-
=============================================
108-
The above example demonstrates running a python script locally and having that script transmit itself to the paperspace jobs cluster for further execution. To do this a copy of the local script is modified before transmission to the jobs cluster, in order to strip out the `import paperspace` statements and other `paperspace` library references. There are also some limitations on the types of import statements that are supported, and the dependencies that are supported in each environment (local vs. remote):
109-
110-
1. You need to use a bare import statement, `import paperspace`, and not use the `import paperspace as ...` form.
111-
2. The import form `from paperspace import ...` is currently not supported.
112-
3. Everything after the `paperspace.run()` function call is ignored when running locally (when no script name is provided). The local script execution stops after the `paperspace.run()` call.
113-
4. Dependencies that are included before `paperspace.run()` must be available locally.
114-
5. If you need to reference dependencies that are not available locally but are available remotely, those should be imported after the `paperspace.run()` call.
115-
6. Dependencies that are needed remotely need to either be already installed in the container used for the job, or need to be installed using one of the techniques below in the section [Dependency Options](#dependency-options)
116-
117-
Because of these limitations it may not always be appropriate to run python scripts automatically from within the same script file. As an alternative you can run your python scripts unmodified using the techniques below.
118-
119-
12073
Running a python script by name
12174
===============================
122-
You can run an python script on paperspace from the command line as follows:
75+
You can run a Python script on a Paperspace server from the command line as follows:
12376

124-
gradient run myscript.py
77+
gradient run myscript.py --name my_new_job
12578

12679
You can also provide additional jobs options on the command line:
12780

128-
gradient run myscript.py --project myproject --machineType P5000 \
81+
gradient run myscript.py --name my_new_job --project myproject --machineType P5000 \
12982
--container paperspace/tensorflow-python`
13083

131-
Alternatively you can use the `paperspace.run()` fuction in code with a script file name as the first argument:
132-
133-
import paperspace
84+
Note: this functionality is deprecated and will not be available in future releases
13485

135-
paperspace.run('myscript.py') # runs myscript on paperspace
86+
See the [Gradient docs](https://docs.paperspace.com/gradient/jobs/about) for the full list of jobs create options that can be specified.
13687

137-
In code you can provide additional paperspace jobs create options in a dict in the second argument to run():
138-
139-
paperspace.run('myscript.py', {'project': 'myproject', 'machineType': 'P5000',
140-
'container': 'paperspace/tensorflow-python'})
141-
142-
See the Paperspace API [jobs create](https://paperspace.github.io/paperspace-node/jobs.html#.create) documentation for the full list of jobs create options that can be specified.
143-
144-
145-
Using gradient run
146-
===========================
147-
The `gradient run` command provides a number of options to run python code and other commands remotely, as well as copy files and set up python dependencies:
148-
149-
gradient run [options] [[-m] <script> [args] | -c "python code" | --command "shell cmd"]
150-
options:
151-
[--python 2|3]
152-
[--init [<init.sh>]]
153-
[--pipenv]
154-
[--req [<requirements.txt>]]
155-
[--workspace .|<workspace_path>]
156-
[--ignoreFiles "<file-or-dir>,..."]
157-
[jobs create options]
158-
[--dryrun]
159-
[-]
16088

16189
Basic Run Scenarios
16290
===================
@@ -210,61 +138,22 @@ Job Options
210138
===========
211139
The `--workspace` option allows you to specify a workspace file or directory to upload, or a git repo link to download and merge with the container. For example, to upload the current directory along with a script file run:
212140

213-
gradient run myscript.py --workspace .
141+
gradient run myscript.py --name my_new_job --workspace workspace-dir
142+
143+
Note: `--workspace` defaults to `.`
214144

215145
See the Paperspae API [jobs create](https://paperspace.github.io/paperspace-node/jobs.html#.create) documentation for more details on the `--workspace` option and related options.
216146

217147
The `--ignoreFiles "<file-or-dir>,..."` option can be used specify a simple comma separated list of files and directories to ignore for the workspace upload:
218148

219-
gradient run myscript.py --workspace . --ignoreFiles "hello.py,paperspace"
149+
gradient run myscript.py --name my_new_job --workspace . --ignoreFiles "hello.py,paperspace"
220150

221151
The following files and directories are ignored by default: `.git`, `.gitignore`, `__pycache__`.
222152

223-
Other `jobs create options` can be specified, such as `--machineType <machine type>`, `--container <container image reference>`, and `--project <project name>`.
224-
225-
Here are some of the other jobs create options available:
226-
227-
- `--project "<project name>"` (defaults to 'paperspace-python')
228-
- `--machineType [C2|C7|GPU+|P4000|P5000|P6000|V100|G1|G6|G12|K80|GV100|GV100x8]` (defaults to P5000)
229-
- `--container <docker image link or paperspace container name>` (defaults to `docker.io/paperspace/tensorflow-python`)
230-
- `--name "<job name>"` (defaults to 'job for project <project name>')
231-
- `--projectId "<existing paperspace project id>"`
232-
- `--registryUsername "<username>"` (for access to a private docker registry)
233-
- `--registryPassword "<secretpw>"` (for access to a private docker registry)
234-
- `--workspaceUsername "<username>"` (for access to a private git repo)
235-
- `--workspacePassword "<secretpw>"` (for access to a private git repo)
153+
Other `jobs create` options can be specified, such as `--machineType <machine-type>`, `--container <container-image-reference>`, and `--project <project-name>`.
236154

237155
See the Paperspae API [jobs create](https://paperspace.github.io/paperspace-node/jobs.html#.create) documentation for a complete description of these options.
238156

239-
Dependency Options
240-
==================
241-
When running python scripts on paperspace you may need to provide additional dependencies to your scripts or specify the python version.
242-
The `gradient run` command has several options to support this: `--python`, `--init`, `--pipenv`, and `--req`. In addition you can use the `--workspace` option above to upload file dependencies.
243-
244-
The `--python 2|3` option allows you specify whether to use `python2` or `python3` when running the script on paperspace.
245-
If ommitted, the script will be run with the same major version as is being used to run `gradient` locally.
246-
247-
The `--init [<init.sh>]` option is used to specify a script to be run on the remote machine, inside the container, before the python script is run.
248-
If the init script name is ommitted, it is assumed to be the script named `init.sh` in the current directory. The script is run using
249-
`source init.sh` in the container bash shell. You can use this option to provide a list of commands to run to set up the dependencies for the script, such as running a list of `pip install` commands. However, if you are using `pipenv` or a `requirements.txt` file we recommend you use one of the options below. Multiple dependency setup options can be combinded however.
250-
251-
The `--pipenv` option is used to upload and run the `Pipfile` and `Pipfile.lock` files in the current directory, if found. These files
252-
are used on the paperspace machine to initialize the python environment using the `pipenv` tool, by running `pipenv install` within the container. Note: `pipenv` must already be installed in the container for this option to work. The default container used by gradient already has the `pipenv` package installed.
253-
254-
The `--req [<requirements.txt>]` option is used specify that a `requirements.txt` file should be used to install the required python dependencies using `pip`.
255-
By default this option looks for a file named `requirements.txt` in the current directory, but you can override this by specifying a different file name. Note: `pip` must already be installed in the container for this option to work. The default container used by gradient already has the `pip` package installed.
256-
257-
The `--dryrun` option allows you to see the resultant script that will be run on the paperspace job runner without actually running it.
258-
259-
All of the above options can be combined in any combination, however, the order of operations is fixed to the following:
260-
261-
1. `source <init.sh>` is run if `--init <init.sh>` is specified
262-
2. `pipenv [--two|--three] install` is run if `--pipenv` is specified
263-
3. `pip[2|3] install -r requirements.txt` is run if `--req <requirements.txt>` is specified
264-
4. `python[2|3] myscript.py` is run
265-
266-
As mentioned above, you can use the `--dryrun` option to see the resultant commands that will be run on the paperspace jobs cluster node for a given set of options, without actually running the commands.
267-
268157

269158
Default Container
270159
=================
@@ -278,20 +167,13 @@ Other examples
278167
See the scripts in the `tests` folder for other examples.
279168

280169

281-
Other Authentication options
170+
Authentication options
282171
============================
283-
1. Specify your apiKey explicitly on the paperspace.run() function or any of the paperspace.jobs methods, e.g.:
284-
285-
```
286-
paperspace.jobs.create({'apiKey': '1qks1hKsU7e1k...', 'project': 'myproject',
287-
'machineType': 'P5000', 'container': 'paperspace/tensorflow-python'})
288-
```
289-
290-
2. Set the package paperspace.config option in your python code:
172+
1. Set the package paperspace.config option in your python code:
291173

292-
`paperspace.config.PAPERSPACE_API_KEY = '1qks1hKsU7e1k...'`
174+
`gradient.config.PAPERSPACE_API_KEY = '1qks1hKsU7e1k...'`
293175

294-
3. Set the PAPERSPACE_API_KEY environment variable:
176+
2. Set the PAPERSPACE_API_KEY environment variable:
295177

296178
(on linux/mac:) `export PAPERSPACE_API_KEY=1qks1hKsU7e1k...`
297179

@@ -300,17 +182,10 @@ Other Authentication options
300182
Note: the above methods take precedence over use of the cached api key in
301183
`~/.paperspace/config.json`
302184

303-
4. Set the key in the `~/.paperspace/config.json` file from the command line by running:
304-
305-
`gradient apikey 1qks1hKsU7e1k...`
306-
185+
3. Set the key in the `~/.paperspace/config.json` file from the command line by running:
307186

308-
Using SAML, AD or GitHub credentials
309-
====================================
310-
Currently only email login is supported in the CLI - if you're using AD, SAML or GitHub to login to Paperspace, you will need an API key to log in with the CLI.
187+
`gradient apiKey 1qks1hKsU7e1k...`
311188

312-
You can create an API key from within your Paperspace console under the [API](https://www.paperspace.com/console/account/api) section. Login to your [Paperspace console](https://www.paperspace.com/console), scroll to the API section in the left navigation bar, and click [CREATE AN API KEY](https://www.paperspace.com/console/account/api). Follow the instructions there.
313-
You will need to pick and API token name for your API key, and also provide a description. You can copy the API key value associated with the API token name only at the time of initial creation. If you need to access your API key in the future, you can instead access it by API token name using the 'gradient login' command.
314189

315190
Contributing
316191
============

gradient/commands/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
from gradient import client, config, logger
4+
from gradient import logger
55
from gradient.commands.jobs import CreateJobCommand
66
from gradient.constants import RunMode
77
from gradient.workspace import WorkspaceHandler

0 commit comments

Comments
 (0)