cycls 0.0.2.35__py3-none-any.whl → 0.0.2.37__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/runtime.py
CHANGED
|
@@ -118,6 +118,7 @@ class Runtime:
|
|
|
118
118
|
sys.exit(1)
|
|
119
119
|
return self._docker_client
|
|
120
120
|
|
|
121
|
+
# docker system prune -af
|
|
121
122
|
def _perform_auto_cleanup(self):
|
|
122
123
|
"""Performs a simple, automatic cleanup of old Docker resources."""
|
|
123
124
|
try:
|
|
@@ -125,7 +126,7 @@ class Runtime:
|
|
|
125
126
|
container.remove(force=True)
|
|
126
127
|
|
|
127
128
|
cleaned_images = 0
|
|
128
|
-
for image in self.docker_client.images.list(
|
|
129
|
+
for image in self.docker_client.images.list(all=True, filters={"label": self.managed_label}):
|
|
129
130
|
is_current = self.tag in image.tags
|
|
130
131
|
is_deployable = any(t.startswith(f"{self.image_prefix}:deploy-") for t in image.tags)
|
|
131
132
|
|
|
@@ -168,11 +169,7 @@ class Runtime:
|
|
|
168
169
|
if self.apt_packages else ""
|
|
169
170
|
)
|
|
170
171
|
run_shell_commands = "\n".join([f"RUN {cmd}" for cmd in self.run_commands]) if self.run_commands else ""
|
|
171
|
-
|
|
172
|
-
# fixes absolute path copy, but causes collision
|
|
173
|
-
copy_lines = "\n".join([f"COPY {Path(src).name} {dst}" for src, dst in self.copy.items()])
|
|
174
|
-
# copy_lines = "\n".join([f"COPY {src} {dst}" for src, dst in self.copy.items()])
|
|
175
|
-
|
|
172
|
+
copy_lines = "\n".join([f"COPY context_files/{dst} {dst}" for dst in self.copy.values()])
|
|
176
173
|
expose_line = f"EXPOSE {port}" if port else ""
|
|
177
174
|
|
|
178
175
|
return f"""
|
|
@@ -184,6 +181,7 @@ RUN mkdir -p {self.io_dir}
|
|
|
184
181
|
{run_apt_install}
|
|
185
182
|
{run_pip_install}
|
|
186
183
|
{run_shell_commands}
|
|
184
|
+
WORKDIR app
|
|
187
185
|
{copy_lines}
|
|
188
186
|
COPY {self.runner_filename} {self.runner_path}
|
|
189
187
|
ENTRYPOINT ["python", "{self.runner_path}", "{self.io_dir}"]
|
|
@@ -198,6 +196,16 @@ COPY {self.payload_file} {self.io_dir}/
|
|
|
198
196
|
"""Prepares a complete build context in the given directory."""
|
|
199
197
|
port = kwargs.get('port') if kwargs else None
|
|
200
198
|
|
|
199
|
+
# Create a dedicated subdirectory for all user-copied files
|
|
200
|
+
context_files_dir = workdir / "context_files"
|
|
201
|
+
context_files_dir.mkdir()
|
|
202
|
+
|
|
203
|
+
if self.copy:
|
|
204
|
+
for src, dst in self.copy.items():
|
|
205
|
+
src_path = Path(src).resolve() # Resolve to an absolute path
|
|
206
|
+
dest_in_context = context_files_dir / dst
|
|
207
|
+
_copy_path(src_path, dest_in_context)
|
|
208
|
+
|
|
201
209
|
(workdir / "Dockerfile").write_text(self._generate_dockerfile(port=port))
|
|
202
210
|
(workdir / self.runner_filename).write_text(self.runner_script)
|
|
203
211
|
|
|
@@ -205,16 +213,6 @@ COPY {self.payload_file} {self.io_dir}/
|
|
|
205
213
|
payload_bytes = cloudpickle.dumps((self.func, args or [], kwargs or {}))
|
|
206
214
|
(workdir / self.payload_file).write_bytes(payload_bytes)
|
|
207
215
|
|
|
208
|
-
if self.copy:
|
|
209
|
-
# for src in self.copy.keys():
|
|
210
|
-
# _copy_path(Path(src), workdir / src)
|
|
211
|
-
|
|
212
|
-
# fixes absolute path copy
|
|
213
|
-
for src in self.copy.keys():
|
|
214
|
-
src_path = Path(src)
|
|
215
|
-
dest_path = workdir / src_path.name if src_path.is_absolute() else workdir / src
|
|
216
|
-
_copy_path(src_path, dest_path)
|
|
217
|
-
|
|
218
216
|
def _build_image_if_needed(self):
|
|
219
217
|
"""Checks if the base Docker image exists locally and builds it if not."""
|
|
220
218
|
try:
|
|
@@ -235,7 +233,8 @@ COPY {self.payload_file} {self.io_dir}/
|
|
|
235
233
|
tag=self.tag,
|
|
236
234
|
forcerm=True,
|
|
237
235
|
decode=True,
|
|
238
|
-
target='base' # Only build the 'base' stage
|
|
236
|
+
target='base', # Only build the 'base' stage
|
|
237
|
+
labels={self.managed_label: "true"}, # image label
|
|
239
238
|
)
|
|
240
239
|
try:
|
|
241
240
|
for chunk in response_generator:
|
|
@@ -269,7 +268,7 @@ COPY {self.payload_file} {self.io_dir}/
|
|
|
269
268
|
image=self.tag,
|
|
270
269
|
volumes={str(tmpdir): {'bind': self.io_dir, 'mode': 'rw'}},
|
|
271
270
|
ports=ports_mapping,
|
|
272
|
-
labels={self.managed_label: "true"}
|
|
271
|
+
labels={self.managed_label: "true"} # container label
|
|
273
272
|
)
|
|
274
273
|
container.start()
|
|
275
274
|
yield container, result_path
|
cycls/sdk.py
CHANGED
|
@@ -55,7 +55,7 @@ class Agent:
|
|
|
55
55
|
|
|
56
56
|
i["config"][6] = False
|
|
57
57
|
|
|
58
|
-
copy={str(cycls_path.joinpath('theme')):"public", str(cycls_path)+"/web.py":"
|
|
58
|
+
copy={str(cycls_path.joinpath('theme')):"public", str(cycls_path)+"/web.py":"web.py"}
|
|
59
59
|
copy.update({i:i for i in self.copy})
|
|
60
60
|
|
|
61
61
|
new = Runtime(
|
|
@@ -102,6 +102,7 @@ class Agent:
|
|
|
102
102
|
with modal.enable_output(), run_app(app=self.app, client=self.client):
|
|
103
103
|
while True: time.sleep(10)
|
|
104
104
|
|
|
105
|
+
# docker system prune -af
|
|
105
106
|
# poetry config pypi-token.pypi <your-token>
|
|
106
|
-
# poetry run python agent.py
|
|
107
|
+
# poetry run python agent-cycls.py
|
|
107
108
|
# poetry publish --build
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
cycls/__init__.py,sha256=ysfA4R_r_INokmpZGK2S8wf2ypLCqwyj0WdfX-hx0bs,51
|
|
2
|
-
cycls/runtime.py,sha256=
|
|
3
|
-
cycls/sdk.py,sha256=
|
|
2
|
+
cycls/runtime.py,sha256=GoRfyPn2uKTIMb4FSowjfo02DsL0VrunDuybdeZxsvM,18221
|
|
3
|
+
cycls/sdk.py,sha256=unZA9v-4YKbuzpsQuQI1A2Xj2PywpS-43S2MtZXUoAM,4601
|
|
4
4
|
cycls/theme/assets/index-D0-uI8sw.js,sha256=aUsqm9HZtEJz38o-0MW12ZVeOlSeKigwc_fYJBntiyI,1068551
|
|
5
5
|
cycls/theme/index.html,sha256=epB4cgSjC7xJOXpVuCwt9r7ivoGvLiXSrxsoOgINw58,895
|
|
6
6
|
cycls/web.py,sha256=nSEJMUQoPaz8qjgVmsC1JiDRv9Y1UKVzTH4_pRHp_VE,4260
|
|
7
|
-
cycls-0.0.2.
|
|
8
|
-
cycls-0.0.2.
|
|
9
|
-
cycls-0.0.2.
|
|
7
|
+
cycls-0.0.2.37.dist-info/METADATA,sha256=bqiLU5K3egK78iGN6v9E0CodfvFQQlgkzKBpYJvsX3M,5666
|
|
8
|
+
cycls-0.0.2.37.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
9
|
+
cycls-0.0.2.37.dist-info/RECORD,,
|
|
File without changes
|