A tool for running python code with docker on aws
Project description
Todo
[x] get the initial template to work
Done
Installation
pip install jaynes
Usage (Show me the Mo-NAY!! :moneybag::money_with_wings:)
Take a look at the folder test_projects/! These project scripts are used for test and development, so they should work out-of-the-box (if you have the right box ahem).
To run Local Docker
from jaynes import Jaynes, templates
from main import train, RUN
S3_PREFIX = "s3://ge-bair/code-block/new-experiment/"
J = Jaynes(
launch_log="jaynes_launch.log",
mounts=[
templates.S3Mount(local="https://github.com/episodeyang/jaynes/blob/master/", s3_prefix=S3_PREFIX, pypath=True),
templates.S3Mount(local=".https://github.com/episodeyang/jaynes/blob/master/.https://github.com/episodeyang/jaynes/blob/master/", s3_prefix=S3_PREFIX, pypath=True, file_mask="https://github.com/episodeyang/jaynes/blob/master/__init__.py https://github.com/episodeyang/jaynes/blob/master/jaynes"),
templates.S3UploadMount(docker_abs=RUN.log_dir, s3_prefix=S3_PREFIX, local=RUN.log_dir, sync_s3=True)
],
)
J.set_docker(
docker=templates.DockerRun("python:3.6",
pypath=":".join([m.pypath for m in J.mounts if hasattr(m, "pypath") and m.pypath]),
docker_startup_scripts=("pip install cloudpickle",),
docker_mount=" ".join([m.docker_mount for m in J.mounts]),
use_gpu=False).run(train, log_dir=RUN.log_dir)
)
J.run_local_setup(verbose=True)
J.launch_local_docker(verbose=True, delay=30)
To run on remote server with ssh
from jaynes import Jaynes, templates
from main import train, RUN
S3_PREFIX = "s3://ge-bair/code-block/run_remote/"
output_mount = templates.S3UploadMount(docker_abs=RUN.log_dir, s3_prefix=S3_PREFIX, local=RUN.log_dir, sync_s3=True)
J = Jaynes(
launch_log="jaynes_launch.log",
mounts=[
templates.S3Mount(local="https://github.com/episodeyang/jaynes/blob/master/", s3_prefix=S3_PREFIX, pypath=True),
templates.S3Mount(local=".https://github.com/episodeyang/jaynes/blob/master/.https://github.com/episodeyang/jaynes/blob/master/", s3_prefix=S3_PREFIX, pypath=True, file_mask="https://github.com/episodeyang/jaynes/blob/master/__init__.py https://github.com/episodeyang/jaynes/blob/master/jaynes"),
output_mount
],
)
J.set_docker(
docker=templates.DockerRun("python:3.6",
pypath=":".join([m.pypath for m in J.mounts if hasattr(m, "pypath") and m.pypath]),
docker_startup_scripts=("pip install cloudpickle",),
docker_mount=" ".join([m.docker_mount for m in J.mounts]),
use_gpu=False).run(train, log_dir=RUN.log_dir)
)
J.run_local_setup(verbose=True)
J.make_launch_script(log_dir=output_mount.remote_abs, instance_tag=RUN.instance_prefix, sudo=True,
terminate_after_finish=True)
J.launch_ssh(ip_address="52.11.206.135", pem="~/.ec2/ge-berkeley.pem", script_dir=output_mount.remote_abs, verbose=True)
To Launch EC2 instance and Run on Startup
make sure the instance terminate after docker run!
from jaynes import Jaynes, templates
from main import train, RUN
S3_PREFIX = "s3://ge-bair/code-block/run_ssh/"
output_mount = templates.S3UploadMount(docker_abs=RUN.log_dir, s3_prefix=S3_PREFIX, local=RUN.log_dir, sync_s3=True)
J = Jaynes(
launch_log="jaynes_launch.log",
mounts=[
templates.S3Mount(local="https://github.com/episodeyang/jaynes/blob/master/", s3_prefix=S3_PREFIX, pypath=True),
templates.S3Mount(local=".https://github.com/episodeyang/jaynes/blob/master/.https://github.com/episodeyang/jaynes/blob/master/", s3_prefix=S3_PREFIX, pypath=True, file_mask="https://github.com/episodeyang/jaynes/blob/master/__init__.py https://github.com/episodeyang/jaynes/blob/master/jaynes"),
output_mount
],
)
J.set_docker(
docker=templates.DockerRun("python:3.6",
pypath=":".join([m.pypath for m in J.mounts if hasattr(m, "pypath") and m.pypath]),
docker_startup_scripts=("pip install cloudpickle",),
docker_mount=" ".join([m.docker_mount for m in J.mounts]),
use_gpu=False).run(train, log_dir=RUN.log_dir)
)
J.run_local_setup(verbose=True)
J.make_launch_script(log_dir=output_mount.remote_abs, instance_tag=RUN.instance_prefix, sudo=False,
terminate_after_finish=True)
J.launch_ec2(region="us-west-2", image_id="ami-bd4fd7c5", instance_type="p2.xlarge", key_name="ge-berkeley",
security_group="torch-gym-prebuilt", spot_price=None,
iam_instance_profile_arn="arn:aws:iam::055406702465:instance-profile/main", dry=False)
Jaynes does the following:
To Develop
git clone https://github.com/episodeyang/jaynes.git
cd jaynes
make dev
To test, run
make test
This make dev command should build the wheel and install it in your current python environment. Take a look at the https://github.com/episodeyang/jaynes/blob/master/Makefile for details.
To publish, first update the version number, then do:
make publish
Acknowledgements
This code-block is inspired by @justinfu’s doodad, which is in turn built on top of Peter Chen’s script.
This code-block is written from scratch to allow a more permissible open-source license (BSD). Go bears :bear: !!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jaynes-0.4.21-py3-none-any.whl.
File metadata
- Download URL: jaynes-0.4.21-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6846b3c92488ee9f63060943356df74d62eefcf3b7df5ff592c3526010829dda
|
|
| MD5 |
d4e1616a58d93252b7e9668b7fe24774
|
|
| BLAKE2b-256 |
858ff9d1e8c657e0278c3a722328d474fcf98fef221623e22d4545c733fcbb47
|