Skip to content

Commit

Permalink
add gitignore, add urls, change gce download to public urls
Browse files Browse the repository at this point in the history
  • Loading branch information
prafullasd committed Apr 29, 2020
1 parent 711a575 commit 54af3e1
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 3 deletions.
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Global
.DS_Store
.idea

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# Jukebox
Code for "Jukebox: A Generative Model for Music"

[Paper](https://cdn.openai.com/jukebox.pdf)
[Blog](https://openai.com/blog/jukebox)
[Explorer](http://jukebox.openai.com/)
[Colab](https://colab.research.google.com/drive/1IQcUNjxLs79YVKLF-A8ghFLCaVYHjc4v)

# Install
```
# Required: Sampling
Expand Down
2 changes: 1 addition & 1 deletion jukebox/make_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def load_checkpoint(path):
if not os.path.dirname(local_path):
os.makedirs(os.path.dirname(local_path))
if not os.path.exists(local_path):
download(gs_path, local_path, False)
download(gs_path, local_path)
restore = local_path
dist.barrier()
checkpoint = t.load(restore, map_location=t.device('cpu'))
Expand Down
8 changes: 6 additions & 2 deletions jukebox/utils/gcs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import sys
import subprocess
from time import time
from urllib.request import urlretrieve

def download(gs_path, local_path, async_download=False):
def gs_download(gs_path, local_path, async_download=False):
args = ['gsutil',
'-o', 'GSUtil:parallel_thread_count=1',
'-o', 'GSUtil:sliced_object_download_max_components=8',
Expand All @@ -14,7 +15,7 @@ def download(gs_path, local_path, async_download=False):
subprocess.call(args)


def upload(local_path, gs_path, async_upload=False):
def gs_upload(local_path, gs_path, async_upload=False):
# NOTE: Download and upload have differ -o flags.
# We also use -n to prevent clobbering checkpoints by mistake
assert not local_path.startswith("gs://")
Expand All @@ -27,6 +28,9 @@ def upload(local_path, gs_path, async_upload=False):
else:
subprocess.call(args)

def download(gs_path, local_path):
remote_path = gs_path.replace("gs://", "https://storage.googleapis.com/")
urlretrieve(remote_path, local_path)

def ls(regex):
outputs = subprocess.check_output(['gsutil', 'ls', regex]).decode(sys.stdout.encoding)
Expand Down

0 comments on commit 54af3e1

Please sign in to comment.