Created
September 10, 2018 19:29
-
-
Save wetherc/8d1488051c0dce9985941347a34207da to your computer and use it in GitHub Desktop.
Sample ML Engine deployment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include stuff.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Cloud ML Engine package configuration.''' | |
from setuptools import setup, find_packages | |
setup( | |
name='thing', | |
version='0.1.0', | |
packages=find_packages(), | |
include_package_data=True, | |
zip_safe=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"key": "value" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
from pathlib import Path | |
dir_path = os.path.dirname(os.path.realpath(__file__)) | |
dir_path = Path(dir_path) | |
print('Current working directory is {}'.format(dir_path)) | |
# Outputs: | |
# Current working directory is /root/.local/lib/python3.5/site-packages/trainer | |
for file in dir_path.iterdir(): | |
print(file) | |
# Outputs: | |
# /root/.local/lib/python3.5/site-packages/trainer/task.py | |
# /root/.local/lib/python3.5/site-packages/trainer/stuff.json | |
with open(str(dir_path / 'stuff.json')) as f: | |
_DATA_SPEC = json.load(f) | |
# File exists, and can be seen with [x for x in dir_path.iterdir()] | |
# but operation errors out with: | |
# TypeError: invalid file: PosixPath('/root/.local/lib/python3.5/site-packages/trainer/utils/data_spec.json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment