Skip to content

Commit

Permalink
updating so submodules init finding works
Browse files Browse the repository at this point in the history
  • Loading branch information
glamp committed Dec 9, 2016
1 parent bb92984 commit 1259e2d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/test_submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import numpy as np
from yhat import Yhat, YhatModel
from yhat.submodules import detect_explicit_submodules
import os
import json

class TestModel(YhatModel):
FILES = [
"sub-sub-modules/run.py"
os.path.join(os.path.dirname(__file__), "sub-sub-modules/run.py")
]

class TestYhatJson(unittest.TestCase):
Expand All @@ -21,7 +22,8 @@ def test_detect_explicit_submodule(self):

def test_detect_submodule_in_deployment(self):
yh = Yhat("greg", "test", "http://api.yhathq.com/")
yh.deploy("TestModel", TestModel, globals(), sure=True, dry_run=True)
_, bundle = yh.deploy("TestModel", TestModel, globals(), sure=True, dry_run=True)
self.assertEqual(len(bundle['modules']), 6)

if __name__=="__main__":
unittest.main()
1 change: 1 addition & 0 deletions yhat/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def _extract_model(self, name, model, session, autodetect, is_tensorflow=False,
if new_filename not in existing_filenames:
modules.append(submodule)

modules = sorted(modules, key=lambda x: os.path.join(x['parent_dir'], x['name']))
if modules:
print("model source files")
for module in modules:
Expand Down
2 changes: 1 addition & 1 deletion yhat/submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def detect_explicit_submodules(model_object):
submodules.append(submodule)

directories = parent_dir.split('/')
for i in range(len(directories)):
for i in range(len(directories) + 1):
submodules.append({
"parent_dir": "/".join(directories[:i]),
"name": "__init__.py",
Expand Down
2 changes: 1 addition & 1 deletion yhat/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.9.12"
__version__ = "1.9.13"

0 comments on commit 1259e2d

Please sign in to comment.