orrin-sdk 0.0.1__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.
- orrin_sdk-0.0.1/PKG-INFO +7 -0
- orrin_sdk-0.0.1/orrin_sdk.egg-info/PKG-INFO +7 -0
- orrin_sdk-0.0.1/orrin_sdk.egg-info/SOURCES.txt +7 -0
- orrin_sdk-0.0.1/orrin_sdk.egg-info/dependency_links.txt +1 -0
- orrin_sdk-0.0.1/orrin_sdk.egg-info/top_level.txt +1 -0
- orrin_sdk-0.0.1/sdk/__init__.py +1 -0
- orrin_sdk-0.0.1/sdk/decorators.py +43 -0
- orrin_sdk-0.0.1/setup.cfg +4 -0
- orrin_sdk-0.0.1/setup.py +9 -0
orrin_sdk-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sdk
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .decorators import OrrinSDK
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import requests
|
|
3
|
+
|
|
4
|
+
API_BASE = "https://stellr-company.com"
|
|
5
|
+
_registered_actions = set()
|
|
6
|
+
|
|
7
|
+
class OrrinSDK:
|
|
8
|
+
def __init__(self, developer_api_key: str):
|
|
9
|
+
self.developer_api_key = developer_api_key
|
|
10
|
+
|
|
11
|
+
def action(self, name: str, extra_metadata: dict = {}): # `extra_metadata` will just be extra metadata for the developer
|
|
12
|
+
def decorator(fn):
|
|
13
|
+
if name in _registered_actions:
|
|
14
|
+
return fn # avoid duplicate registration
|
|
15
|
+
|
|
16
|
+
_registered_actions.add(name)
|
|
17
|
+
|
|
18
|
+
try:
|
|
19
|
+
source = inspect.getsource(fn)
|
|
20
|
+
payload = {
|
|
21
|
+
"action_name": name,
|
|
22
|
+
"entrypoint": fn.__name__,
|
|
23
|
+
"runtime": "python",
|
|
24
|
+
"source_code": source
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if not extra_metadata == {}:
|
|
28
|
+
payload['extra_metadata'] = extra_metadata
|
|
29
|
+
|
|
30
|
+
requests.post(
|
|
31
|
+
f"{API_BASE}/actions/register",
|
|
32
|
+
json=payload,
|
|
33
|
+
headers={
|
|
34
|
+
"Authorization": self.developer_api_key,
|
|
35
|
+
'fsdk': 'yes'
|
|
36
|
+
},
|
|
37
|
+
timeout=5 # avoid hanging imports
|
|
38
|
+
)
|
|
39
|
+
except Exception as e:
|
|
40
|
+
print(f"[stellr-sdk] Warning: Failed to register action '{name}': {e}")
|
|
41
|
+
|
|
42
|
+
return fn
|
|
43
|
+
return decorator
|