Skip to content

Commit

Permalink
Use new env
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Oct 12, 2023
1 parent 93636c9 commit 2acf166
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
17 changes: 2 additions & 15 deletions packages/python-sdk/data_analysis_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,9 @@
def main():
s = DataAnalysis(api_key=E2B_API_KEY)

with open("data/e2b_matplotlib_backend", "r") as f:
r = f.read()

s.filesystem.write("/usr/lib/python3.10/e2b_matplotlib_backend.py", r)

with open("data/matplotlibrc", "r") as f:
r = f.read()

s.filesystem.write("/home/user/matplotlibrc", r)

with open("data/spotify-2023.csv", "rb") as f:
s.upload_file(file=f)

s.process.start("sudo chown -R user:user /root").wait()

s.install_python_package(["numpy", "pandas", "matplotlib", "seaborn"])
stdout, stderr, artifacts = s.run_python(
"""
import numpy as np # linear algebra
Expand Down Expand Up @@ -57,8 +44,8 @@ def main():
)

for artifact in artifacts:
content = s.download_file(artifact)
with open(artifact, "wb") as f:
content = artifact.read()
with open(artifact.name, "wb") as f:
f.write(content)

s.close()
Expand Down
3 changes: 3 additions & 0 deletions packages/python-sdk/e2b/session/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class ProcessMessage(BaseModel):
Unix epoch in nanoseconds
"""

def __str__(self):
return self.line


class ProcessOutput(BaseModel):
"""
Expand Down
2 changes: 1 addition & 1 deletion packages/python-sdk/e2b/templates/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def download(self, path: Optional[str] = None) -> None:

class DataAnalysis(SyncSession):
# TODO: Create custom env
env_id = "Python3"
env_id = "Python3-DataAnalysis"

def __init__(
self,
Expand Down

0 comments on commit 2acf166

Please sign in to comment.