cycls 0.0.2.85__py3-none-any.whl → 0.0.2.87__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cycls/function.py +11 -19
- cycls/themes/default/assets/index-DOmNqb-2.js +435 -0
- cycls/themes/default/assets/index-oGkkm3Z8.css +1 -0
- cycls/themes/default/index.html +6 -2
- {cycls-0.0.2.85.dist-info → cycls-0.0.2.87.dist-info}/METADATA +6 -4
- cycls-0.0.2.87.dist-info/RECORD +14 -0
- cycls/themes/default/assets/index-C2r4Daz3.js +0 -435
- cycls/themes/default/assets/index-DWGS8zpa.css +0 -1
- cycls-0.0.2.85.dist-info/RECORD +0 -14
- {cycls-0.0.2.85.dist-info → cycls-0.0.2.87.dist-info}/WHEEL +0 -0
- {cycls-0.0.2.85.dist-info → cycls-0.0.2.87.dist-info}/entry_points.txt +0 -0
cycls/function.py
CHANGED
|
@@ -12,10 +12,6 @@ import tarfile
|
|
|
12
12
|
|
|
13
13
|
os.environ["DOCKER_BUILDKIT"] = "1"
|
|
14
14
|
|
|
15
|
-
BASE_IMAGE = "ghcr.io/cycls/base:python3.12"
|
|
16
|
-
BASE_PACKAGES = {"cloudpickle", "cryptography", "fastapi", "fastapi[standard]",
|
|
17
|
-
"pydantic", "pyjwt", "uvicorn", "uvicorn[standard]", "httpx"}
|
|
18
|
-
|
|
19
15
|
ENTRYPOINT_PY = '''import cloudpickle
|
|
20
16
|
with open("/app/function.pkl", "rb") as f:
|
|
21
17
|
func, args, kwargs = cloudpickle.load(f)
|
|
@@ -84,22 +80,17 @@ class Function:
|
|
|
84
80
|
"""Executes functions in Docker containers."""
|
|
85
81
|
|
|
86
82
|
def __init__(self, func, name, python_version=None, pip=None, apt=None,
|
|
87
|
-
run_commands=None, copy=None, base_url=None, api_key=None
|
|
83
|
+
run_commands=None, copy=None, base_url=None, api_key=None):
|
|
88
84
|
self.func = func
|
|
89
85
|
self.name = name.replace('_', '-')
|
|
90
86
|
self.python_version = python_version or f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
87
|
+
self.base_image = f"python:{self.python_version}-slim"
|
|
91
88
|
self.apt = sorted(apt or [])
|
|
92
89
|
self.run_commands = sorted(run_commands or [])
|
|
93
90
|
self.copy = {f: f for f in copy} if isinstance(copy, list) else (copy or {})
|
|
94
|
-
self.base_image = base_image or BASE_IMAGE
|
|
95
91
|
self.base_url = base_url or "https://service-core-280879789566.me-central1.run.app"
|
|
96
92
|
self.api_key = api_key
|
|
97
|
-
|
|
98
|
-
user_packages = set(pip or [])
|
|
99
|
-
if self.base_image == BASE_IMAGE:
|
|
100
|
-
self.pip = sorted(user_packages - BASE_PACKAGES)
|
|
101
|
-
else:
|
|
102
|
-
self.pip = sorted(user_packages | {"cloudpickle"})
|
|
93
|
+
self.pip = sorted(set(pip or []) | {"cloudpickle"})
|
|
103
94
|
|
|
104
95
|
self.image_prefix = f"cycls/{self.name}"
|
|
105
96
|
self.managed_label = "cycls.function"
|
|
@@ -151,11 +142,12 @@ class Function:
|
|
|
151
142
|
return f"{self.image_prefix}:{hashlib.sha256(''.join(parts).encode()).hexdigest()[:16]}"
|
|
152
143
|
|
|
153
144
|
def _dockerfile_preamble(self) -> str:
|
|
154
|
-
lines = [
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
lines = [
|
|
146
|
+
f"FROM {self.base_image}",
|
|
147
|
+
"ENV PIP_ROOT_USER_ACTION=ignore PYTHONUNBUFFERED=1",
|
|
148
|
+
"WORKDIR /app",
|
|
149
|
+
"RUN pip install uv",
|
|
150
|
+
]
|
|
159
151
|
|
|
160
152
|
if self.apt:
|
|
161
153
|
lines.append(f"RUN apt-get update && apt-get install -y --no-install-recommends {' '.join(self.apt)}")
|
|
@@ -173,8 +165,8 @@ class Function:
|
|
|
173
165
|
|
|
174
166
|
def _dockerfile_local(self) -> str:
|
|
175
167
|
return f"""{self._dockerfile_preamble()}
|
|
176
|
-
COPY runner.py /
|
|
177
|
-
ENTRYPOINT ["python", "/
|
|
168
|
+
COPY runner.py /runner.py
|
|
169
|
+
ENTRYPOINT ["python", "/runner.py", "/io"]
|
|
178
170
|
"""
|
|
179
171
|
|
|
180
172
|
def _dockerfile_deploy(self, port: int) -> str:
|