cycls 0.0.2.38__py3-none-any.whl → 0.0.2.40__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/__init__.py +1 -1
- cycls/sdk.py +14 -5
- cycls/theme/assets/index-CtrsaaFE.js +378 -0
- cycls/theme/index.html +1 -1
- cycls/web.py +22 -9
- {cycls-0.0.2.38.dist-info → cycls-0.0.2.40.dist-info}/METADATA +1 -1
- cycls-0.0.2.40.dist-info/RECORD +9 -0
- cycls/theme/assets/index-D0-uI8sw.js +0 -364
- cycls-0.0.2.38.dist-info/RECORD +0 -9
- {cycls-0.0.2.38.dist-info → cycls-0.0.2.40.dist-info}/WHEEL +0 -0
cycls/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
from .sdk import Agent
|
|
1
|
+
from .sdk import Agent, function
|
|
2
2
|
from .runtime import Runtime
|
cycls/sdk.py
CHANGED
|
@@ -7,6 +7,16 @@ import importlib.resources
|
|
|
7
7
|
theme_path = importlib.resources.files('cycls').joinpath('theme')
|
|
8
8
|
cycls_path = importlib.resources.files('cycls')
|
|
9
9
|
|
|
10
|
+
def function(python_version=None, pip=None, apt=None, run_commands=None, copy=None, name=None, base_url=None, api_key=None):
|
|
11
|
+
# """
|
|
12
|
+
# A decorator factory that transforms a Python function into a containerized,
|
|
13
|
+
# remotely executable object.
|
|
14
|
+
def decorator(func):
|
|
15
|
+
Name = name or func.__name__
|
|
16
|
+
copy_dict = {i:i for i in copy or []}
|
|
17
|
+
return Runtime(func, Name.replace('_', '-'), python_version, pip, apt, run_commands, copy_dict, base_url, api_key)
|
|
18
|
+
return decorator
|
|
19
|
+
|
|
10
20
|
class Agent:
|
|
11
21
|
def __init__(self, theme=theme_path, org=None, api_token=None, pip=[], apt=[], copy=[], keys=["",""], api_key=None):
|
|
12
22
|
self.org, self.api_token = org, api_token
|
|
@@ -28,7 +38,7 @@ class Agent:
|
|
|
28
38
|
return f
|
|
29
39
|
return decorator
|
|
30
40
|
|
|
31
|
-
def
|
|
41
|
+
def local(self, port=8080):
|
|
32
42
|
if not self.registered_functions:
|
|
33
43
|
print("Error: No @agent decorated function found.")
|
|
34
44
|
return
|
|
@@ -41,7 +51,7 @@ class Agent:
|
|
|
41
51
|
uvicorn.run(web(i["func"], *i["config"]), host="0.0.0.0", port=port)
|
|
42
52
|
return
|
|
43
53
|
|
|
44
|
-
def
|
|
54
|
+
def deploy(self, prod=False, port=8080):
|
|
45
55
|
if not self.registered_functions:
|
|
46
56
|
print("Error: No @agent decorated function found.")
|
|
47
57
|
return
|
|
@@ -55,7 +65,6 @@ class Agent:
|
|
|
55
65
|
|
|
56
66
|
i["config"][6] = False
|
|
57
67
|
|
|
58
|
-
# copy={str(cycls_path.joinpath('theme')):"public", str(cycls_path)+"/web.py":"web.py"}
|
|
59
68
|
copy={str(self.theme):"public", str(cycls_path)+"/web.py":"web.py"}
|
|
60
69
|
copy.update({i:i for i in self.copy})
|
|
61
70
|
|
|
@@ -70,7 +79,7 @@ class Agent:
|
|
|
70
79
|
new.deploy(port=port) if prod else new.run(port=port)
|
|
71
80
|
return
|
|
72
81
|
|
|
73
|
-
def
|
|
82
|
+
def modal(self, prod=False):
|
|
74
83
|
self.client = modal.Client.from_credentials(*self.keys)
|
|
75
84
|
image = (modal.Image.debian_slim()
|
|
76
85
|
.pip_install("fastapi[standard]", "pyjwt", "cryptography", *self.pip)
|
|
@@ -105,5 +114,5 @@ class Agent:
|
|
|
105
114
|
|
|
106
115
|
# docker system prune -af
|
|
107
116
|
# poetry config pypi-token.pypi <your-token>
|
|
108
|
-
# poetry run python agent-
|
|
117
|
+
# poetry run python agent-deploy.py
|
|
109
118
|
# poetry publish --build
|