UncountablePythonSDK 0.0.13__py3-none-any.whl → 0.0.15__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.

Potentially problematic release.


This version of UncountablePythonSDK might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: UncountablePythonSDK
3
- Version: 0.0.13
3
+ Version: 0.0.15
4
4
  Summary: Uncountable SDK
5
5
  Project-URL: Homepage, https://github.com/uncountableinc/uncountable-python-sdk
6
6
  Project-URL: Repository, https://github.com/uncountableinc/uncountable-python-sdk.git
@@ -71,11 +71,11 @@ uncountable/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
71
  uncountable/core/__init__.py,sha256=GCXRRhhYv-yKzqKjAij7GcNiOr90BBbgdhhpusWtmUc,100
72
72
  uncountable/core/client.py,sha256=jcJBGwe31fOqfGiUJzW_KMcfE0hax55jgVVliALBNLQ,4160
73
73
  uncountable/integration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- uncountable/integration/construct_client.py,sha256=Ojdj6Mh5orAjXZLxb6SzvH4zRmkvqp6nHF_8Ph7h1ho,896
75
- uncountable/integration/cron.py,sha256=QZP4yvxdGUZsOH5wtxZzqja_0UBHL4lwERzEHGTR-E0,917
76
- uncountable/integration/entrypoint.py,sha256=31QJO6pFDvPR8k5Bi7RSm-IUI5kXj_VHdz4XZW3j5DI,1363
77
- uncountable/integration/job.py,sha256=orPmhLWs5mB4U8XweIb1Pa3fUKKE89yUnHXLkHy7KOs,699
78
- uncountable/integration/server.py,sha256=VfbJLFqHl6cQAL8e2EOmrtSRfruskQ89h_2Mu3EMeOI,2998
74
+ uncountable/integration/construct_client.py,sha256=r6M5pnIO0fKcjf5d_AREPtWZ6AkWgcjkdu_jHQEYlT8,1084
75
+ uncountable/integration/cron.py,sha256=TIPqMPMSMtMJTu4aXwLf6QY-OLrpmyITLDp48UIr4Ok,919
76
+ uncountable/integration/entrypoint.py,sha256=sPtUeKJEivf0iqY-H4LHWhyeUHMZK_U4CrDj1Kw8Ld0,1395
77
+ uncountable/integration/job.py,sha256=5QuCjeze9vtEirntP9P9hDD3LVrBn5pApDWh2IZeEiY,817
78
+ uncountable/integration/server.py,sha256=DSYflR8tIo20Kixt4AmQI6nOP_BHeTGUiq7iFKaf31s,3342
79
79
  uncountable/integration/types.py,sha256=n9idu2_qHOA5CQdE6NK8HS6aZ8ugTZKTfTTnm4sy8tI,2066
80
80
  uncountable/integration/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
81
81
  uncountable/integration/db/connect.py,sha256=iI9e8a2hfbFP-dvH0MGLsrG-RpM0dHKCL-oCLkah9hs,181
@@ -139,7 +139,7 @@ uncountable/types/api/recipes/get_recipe_output_metadata.py,sha256=L9s2ykPP4pd02
139
139
  uncountable/types/api/recipes/get_recipes_data.py,sha256=dOKokz6rJp3AiqNrF8rAZFlmJSs3ejdNIJhwKw0Utr0,5317
140
140
  uncountable/types/api/recipes/set_recipe_inputs.py,sha256=sHEwPocBucWRnnoX7nbNaFqdflxFkqdjuVydNezqluY,1326
141
141
  uncountable/types/api/recipes/set_recipe_outputs.py,sha256=QYq39TNchQ80ET1C77OE9fwhbu_HmIoEDmrQJHkkCu0,1609
142
- UncountablePythonSDK-0.0.13.dist-info/METADATA,sha256=m8sJxcGIlD2Bf89mLsaSTITEjN08Ypq7d7MDFhKO4pw,1298
143
- UncountablePythonSDK-0.0.13.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
144
- UncountablePythonSDK-0.0.13.dist-info/top_level.txt,sha256=8ga1DCSWt4Uc_XJ5cR0QrDQuyoeo2uoSzaAJdQT2KBo,36
145
- UncountablePythonSDK-0.0.13.dist-info/RECORD,,
142
+ UncountablePythonSDK-0.0.15.dist-info/METADATA,sha256=mO5xBMNi8X3Ek9wcHUAD8FD-2A3as4klF2PU6R4H2dA,1298
143
+ UncountablePythonSDK-0.0.15.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
144
+ UncountablePythonSDK-0.0.15.dist-info/top_level.txt,sha256=8ga1DCSWt4Uc_XJ5cR0QrDQuyoeo2uoSzaAJdQT2KBo,36
145
+ UncountablePythonSDK-0.0.15.dist-info/RECORD,,
@@ -8,14 +8,19 @@ from uncountable.integration.types import (
8
8
  )
9
9
 
10
10
 
11
- def construct_uncountable_client(
12
- profile_meta: ProfileMetadata
13
- ) -> Client:
11
+ def _get_env_var(name: str) -> str:
12
+ value = os.getenv(name)
13
+ if value is None:
14
+ raise Exception(f"environment variable {name} is missing")
15
+ return value
16
+
17
+
18
+ def construct_uncountable_client(profile_meta: ProfileMetadata) -> Client:
14
19
  match profile_meta.auth_retrieval:
15
20
  case AuthRetrievalEnv():
16
- api_id = os.getenv(f"UNC_PROFILE_{profile_meta.name}_API_ID")
17
- api_secret_key = os.getenv(
18
- f"UNC_PROFILE_{profile_meta.name}_API_SECRET_KEY"
21
+ api_id = _get_env_var(f"UNC_PROFILE_{profile_meta.name.upper()}_API_ID")
22
+ api_secret_key = _get_env_var(
23
+ f"UNC_PROFILE_{profile_meta.name.upper()}_API_SECRET_KEY"
19
24
  )
20
25
 
21
26
  assert api_id is not None
@@ -23,7 +23,6 @@ def cron_job_executor(**kwargs: dict) -> None:
23
23
  client=construct_uncountable_client(profile_meta=args_passed.profile_metadata),
24
24
  )
25
25
 
26
- job_class = resolve_script_executor(args_passed.definition.executor)
26
+ job = resolve_script_executor(args_passed.definition.executor, args_passed.profile_metadata)
27
27
 
28
- job = job_class()
29
28
  job.run(args)
@@ -36,6 +36,8 @@ def main() -> None:
36
36
  jobs=profile.jobs,
37
37
  )
38
38
 
39
+ server.serve_forever()
40
+
39
41
 
40
42
  if __name__ == "__main__":
41
43
  main()
@@ -26,6 +26,7 @@ class JobResult:
26
26
 
27
27
 
28
28
  class Job(ABC):
29
+ _unc_job_registered: bool = False
29
30
 
30
31
  @abstractmethod
31
32
  def run(self, args: JobArguments) -> JobResult:
@@ -37,3 +38,8 @@ class CronJob(Job):
37
38
  @abstractmethod
38
39
  def run(self, args: CronJobArguments) -> JobResult:
39
40
  ...
41
+
42
+
43
+ def register_job(cls: Job):
44
+ cls._unc_job_registered = True
45
+ return cls
@@ -1,5 +1,7 @@
1
+ import signal
2
+ from types import TracebackType
1
3
  from dataclasses import asdict
2
- from typing import assert_never
4
+ from typing import Optional, assert_never
3
5
  from apscheduler.schedulers.background import BackgroundScheduler
4
6
  from apscheduler.schedulers.base import BaseScheduler
5
7
  from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
@@ -57,7 +59,9 @@ class IntegrationServer:
57
59
  name=job_defn.name,
58
60
  kwargs=job_kwargs,
59
61
  )
60
- existing_job.reschedule(job_defn.cron_spec)
62
+ existing_job.reschedule(
63
+ CronTrigger.from_crontab(job_defn.cron_spec)
64
+ )
61
65
  else:
62
66
  self._scheduler.add_job(
63
67
  cron_job_executor,
@@ -72,6 +76,9 @@ class IntegrationServer:
72
76
  case _:
73
77
  assert_never(job_defn.trigger)
74
78
 
79
+ def serve_forever(self) -> None:
80
+ signal.pause()
81
+
75
82
  def _start_apscheduler(self) -> None:
76
83
  self._scheduler.start()
77
84
 
@@ -82,5 +89,10 @@ class IntegrationServer:
82
89
  self._start_apscheduler()
83
90
  return self
84
91
 
85
- def __exit__(self) -> None:
92
+ def __exit__(
93
+ self,
94
+ exc_type: Optional[type[BaseException]],
95
+ exc_val: Optional[BaseException],
96
+ exc_tb: Optional[TracebackType],
97
+ ) -> None:
86
98
  self._stop_apscheduler()