Skip to content

Commit 3a1b777

Browse files
committed
Use dill importable in all non-interactive scenarios
1 parent 80fa790 commit 3a1b777

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

pkg/cortex/client/cortex/client.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,12 @@ def _save_impl(self, impl, project_dir: Path, filename: str) -> str:
204204
# class is defined in a REPL (e.g. jupyter)
205205
filename += ".pickle"
206206
with open(project_dir / filename, "wb") as pickle_file:
207-
208207
dill.dump(impl, pickle_file)
209208
return filename
210209

211210
filename += ".py"
212-
if not is_interactive and impl.__module__ == "__main__":
213-
# class is defined in the same file as main
214-
with open(project_dir / filename, "w") as f:
215-
f.write(dill.source.importable(impl, source=True))
216-
return filename
217-
218-
if not is_interactive and not impl.__module__ == "__main__":
219-
# class is imported, copy file containing the class
220-
shutil.copy(inspect.getfile(impl), project_dir / filename)
211+
with open(project_dir / filename, "w") as f:
212+
f.write(dill.source.importable(impl, source=True))
221213
return filename
222214

223215
def _deploy(

0 commit comments

Comments
 (0)