Skip to content

Commit 20d6548

Browse files
authored
Cleaning exospherehost python sdk and adding first exospherehost runtime (#141)
* minor change in api server * cleaned Node Creation logic * fixing runtime and BaseNode * fixed errors * fixed docstings * Add initial implementation of cloud-storage-runtime - Created .gitignore to exclude unnecessary files. - Added .python-version to specify Python version 3.12. - Implemented main.py to load environment variables and start the runtime. - Defined project metadata in pyproject.toml with dependencies. - Created README.md and uv.lock for project documentation and dependency locking. - Added nodes package with ListS3FilesNode to list files in S3 buckets. * version updated * fixed README * fixed issues pointed by @coderabbitai
1 parent 42c6dfc commit 20d6548

14 files changed

Lines changed: 557 additions & 206 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Virtual Environment
24+
venv/
25+
env/
26+
ENV/
27+
.env
28+
.venv/
29+
30+
# IDE
31+
.vscode/
32+
*.swp
33+
*.swo
34+
.idea/
35+
*.iws
36+
*.iml
37+
*.ipr
38+
39+
40+
# Local development
41+
.env.local
42+
.env.development.local
43+
.env.test.local
44+
.env.production.local
45+
46+
# Database
47+
*.db
48+
*.sqlite3
49+
50+
# OS generated files
51+
.DS_Store
52+
.DS_Store?
53+
._*
54+
.Spotlight-V100
55+
.Trashes
56+
ehthumbs.db
57+
Thumbs.db
58+
59+
#logs
60+
*.log
61+
logs/*.*
62+
!logs/.gitkeep
63+
64+
# local files
65+
files/
66+
!files/.gitkeep
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

exosphere-runtimes/cloud-storage-runtime/README.md

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from dotenv import load_dotenv
2+
from exospherehost import Runtime
3+
from nodes.list_s3_files import ListS3FilesNode
4+
5+
# Load environment variables from .env file
6+
# EXOSPHERE_STATE_MANAGER_URI is the URI of the state manager
7+
# EXOSPHERE_API_KEY is the key of the runtime
8+
load_dotenv()
9+
10+
Runtime(
11+
name="cloud-storage-runtime",
12+
namespace="exospherehost",
13+
nodes=[ListS3FilesNode]
14+
).start()

exosphere-runtimes/cloud-storage-runtime/nodes/__init__.py

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import boto3
2+
import os
3+
4+
from exospherehost import BaseNode
5+
from typing import List
6+
from pydantic import BaseModel
7+
8+
9+
class ListS3FilesNode(BaseNode):
10+
11+
class Inputs(BaseModel):
12+
bucket_name: str
13+
prefix: str = ''
14+
files_only: bool = False
15+
recursive: bool = False
16+
17+
class Outputs(BaseModel):
18+
key: str
19+
20+
class Secrets(BaseModel):
21+
aws_access_key_id: str = os.getenv("S3_ACCESS_KEY_ID")
22+
aws_secret_access_key: str = os.getenv("S3_SECRET_ACCESS_KEY")
23+
aws_region: str = os.getenv("S3_REGION")
24+
25+
async def execute(self) -> List[Outputs]:
26+
print(self.inputs)
27+
28+
s3_client = boto3.client(
29+
's3',
30+
aws_access_key_id=os.getenv("S3_ACCESS_KEY_ID"),
31+
aws_secret_access_key=os.getenv("S3_SECRET_ACCESS_KEY"),
32+
region_name=os.getenv("S3_REGION")
33+
)
34+
response = s3_client.list_objects_v2(Bucket=self.inputs.bucket_name, Prefix=self.inputs.prefix)
35+
36+
return [
37+
self.Outputs(key=data['Key'])
38+
for data in response['Contents']
39+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[project]
2+
name = "cloud-storage-runtime"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"boto3>=1.40.1",
9+
"python-dotenv>=1.1.1",
10+
]

exosphere-runtimes/cloud-storage-runtime/uv.lock

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)