Skip to content

Instantly share code, notes, and snippets.

@wetherc
Created September 10, 2018 19:29
Show Gist options
  • Save wetherc/8d1488051c0dce9985941347a34207da to your computer and use it in GitHub Desktop.
Save wetherc/8d1488051c0dce9985941347a34207da to your computer and use it in GitHub Desktop.
Sample ML Engine deployment
include stuff.json
'''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)
{
"key": "value"
}
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