cycls 0.0.2.35__tar.gz → 0.0.2.37__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cycls
3
- Version: 0.0.2.35
3
+ Version: 0.0.2.37
4
4
  Summary: Cycls SDK
5
5
  Author: Mohammed J. AlRujayi
6
6
  Author-email: mj@cycls.com
@@ -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(name=self.image_prefix):
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
@@ -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":"app/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,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cycls"
3
- version = "0.0.2.35"
3
+ version = "0.0.2.37"
4
4
 
5
5
  packages = [{ include = "cycls" }]
6
6
  include = ["cycls/theme/**/*"]
@@ -17,7 +17,6 @@ jwt = "^1.4.0"
17
17
  docker = "^7.1.0"
18
18
  cloudpickle = "^3.1.1"
19
19
 
20
-
21
20
  [build-system]
22
21
  requires = ["poetry-core"]
23
22
  build-backend = "poetry.core.masonry.api"
File without changes
File without changes
File without changes