cycls 0.0.2.94__tar.gz → 0.0.2.95__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.94
3
+ Version: 0.0.2.95
4
4
  Summary: Distribute Intelligence
5
5
  Author-email: "Mohammed J. AlRujayi" <mj@cycls.com>
6
6
  Requires-Python: >=3.10
@@ -399,7 +399,30 @@ CMD ["python", "entrypoint.py"]
399
399
  def _deploy(self, *args, **kwargs):
400
400
  import requests
401
401
 
402
+ base_url = self.base_url
402
403
  port = kwargs.pop('port', 8080)
404
+
405
+ # Check name availability before uploading
406
+ print(f"Checking '{self.name}'...")
407
+ try:
408
+ check_resp = requests.get(
409
+ f"{base_url}/v1/deployment/check-name",
410
+ params={"name": self.name},
411
+ headers={"X-API-Key": self.api_key},
412
+ timeout=30,
413
+ )
414
+ if check_resp.status_code == 401:
415
+ print("Error: Invalid API key")
416
+ return None
417
+ check_resp.raise_for_status()
418
+ check_data = check_resp.json()
419
+ if not check_data.get("available"):
420
+ print(f"Error: {check_data.get('reason', 'Name unavailable')}")
421
+ return None
422
+ except requests.exceptions.RequestException as e:
423
+ print(f"Error checking name: {e}")
424
+ return None
425
+
403
426
  print(f"Deploying '{self.name}'...")
404
427
 
405
428
  payload = cloudpickle.dumps((self.func, args, {**kwargs, 'port': port}))
@@ -418,7 +441,7 @@ CMD ["python", "entrypoint.py"]
418
441
  print("Uploading...")
419
442
  with open(archive_path, 'rb') as f:
420
443
  response = requests.post(
421
- "https://api-572247013948.me-central1.run.app/v1/deploy",
444
+ f"{base_url}/v1/deploy",
422
445
  data={"function_name": self.name, "port": port},
423
446
  files={'source_archive': (archive_name, f, 'application/gzip')},
424
447
  headers={"X-API-Key": self.api_key},
@@ -426,6 +449,14 @@ CMD ["python", "entrypoint.py"]
426
449
  stream=True,
427
450
  )
428
451
 
452
+ if not response.ok:
453
+ print(f"Deploy failed: {response.status_code}")
454
+ try:
455
+ print(f" {response.json()['detail']}")
456
+ except (json.JSONDecodeError, KeyError):
457
+ print(f" {response.text}")
458
+ return None
459
+
429
460
  # Parse NDJSON stream
430
461
  url = None
431
462
  for line in response.iter_lines(decode_unicode=True):
@@ -436,6 +467,7 @@ CMD ["python", "entrypoint.py"]
436
467
  print(f" [{status}] {msg}")
437
468
  if status == "DONE":
438
469
  url = event.get("url")
470
+ print(f"Deployed: {url}")
439
471
  elif status == "ERROR":
440
472
  return None
441
473
  return url
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cycls"
3
- version = "0.0.2.94"
3
+ version = "0.0.2.95"
4
4
  description = "Distribute Intelligence"
5
5
  authors = [{ name = "Mohammed J. AlRujayi", email = "mj@cycls.com" }]
6
6
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes