Skip to content

Commit

Permalink
Change artifact folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Oct 13, 2023
1 parent bd285bb commit dcc9340
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/python-sdk/e2b/templates/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def __init__(self, **data: Any):
super().__init__(**data)
self._session = data["_session"]

def __hash__(self):
return hash(self.name)

def read(self) -> bytes:
return self._session.download_file(self.name)

Expand Down Expand Up @@ -72,7 +75,7 @@ def register_artifacts(event: Any):
except Exception as e:
logger.error("Failed to process artifact", exc_info=e)

watcher = self.filesystem.watch_dir("/tmp")
watcher = self.filesystem.watch_dir("/home/user/artifacts")
watcher.add_event_listener(register_artifacts)
watcher.start()

Expand All @@ -86,10 +89,7 @@ def register_artifacts(event: Any):

watcher.stop()

artifacts = list(
map(lambda artifact: Artifact(name=artifact, _session=self), artifacts)
)
return process.output.stdout, process.output.stderr, artifacts
return process.output.stdout, process.output.stderr, list(artifacts)

def install_python_package(self, package_names: Union[str, List[str]]):
if isinstance(package_names, list):
Expand Down
13 changes: 7 additions & 6 deletions packages/python-sdk/tests/templates/test_data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

def test_create_graph():
s = DataAnalysis()
_, _, artifacts = s.run_python(
a, b, artifacts = s.run_python(
"""
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
"""
)
print(a, b, artifacts)
s.close()
assert len(artifacts) == 1

0 comments on commit dcc9340

Please sign in to comment.