UncountablePythonSDK 0.0.119__py3-none-any.whl → 0.0.120__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,3 +1,5 @@
1
+ import time
2
+
1
3
  from uncountable.integration.job import CronJob, JobArguments, register_job
2
4
  from uncountable.types import entity_t
3
5
  from uncountable.types.job_definition_t import JobResult
@@ -15,4 +17,5 @@ class MyCronJob(CronJob):
15
17
  if field_val.field_ref_name == "name":
16
18
  name = field_val.value
17
19
  args.logger.log_info(f"material family found with name: {name}")
20
+ time.sleep(1.5)
18
21
  return JobResult(success=True)
@@ -96,6 +96,35 @@ class DatastoreSqlite(Datastore):
96
96
 
97
97
  return queued_job_metadata
98
98
 
99
+ def get_next_queued_job_for_ref_name(
100
+ self, job_ref_name: str
101
+ ) -> queued_job_t.QueuedJob | None:
102
+ with self.session_maker() as session:
103
+ select_stmt = (
104
+ select(
105
+ QueuedJob.id,
106
+ QueuedJob.payload,
107
+ QueuedJob.num_attempts,
108
+ QueuedJob.job_ref_name,
109
+ QueuedJob.submitted_at,
110
+ )
111
+ .filter(QueuedJob.job_ref_name == job_ref_name)
112
+ .limit(1)
113
+ .order_by(QueuedJob.submitted_at)
114
+ )
115
+
116
+ for row in session.execute(select_stmt):
117
+ parsed_payload = queued_job_payload_parser.parse_storage(row.payload)
118
+ return queued_job_t.QueuedJob(
119
+ queued_job_uuid=row.id,
120
+ job_ref_name=row.job_ref_name,
121
+ num_attempts=row.num_attempts,
122
+ submitted_at=row.submitted_at,
123
+ payload=parsed_payload,
124
+ )
125
+
126
+ return None
127
+
99
128
  def load_job_queue(self) -> list[queued_job_t.QueuedJob]:
100
129
  with self.session_maker() as session:
101
130
  select_stmt = select(
@@ -18,6 +18,11 @@ class Datastore(ABC):
18
18
  @abstractmethod
19
19
  def load_job_queue(self) -> list[queued_job_t.QueuedJob]: ...
20
20
 
21
+ @abstractmethod
22
+ def get_next_queued_job_for_ref_name(
23
+ self, job_ref_name: str
24
+ ) -> queued_job_t.QueuedJob | None: ...
25
+
21
26
  @abstractmethod
22
27
  def list_queued_job_metadata(
23
28
  self, offset: int, limit: int | None
@@ -114,17 +114,11 @@ async def start_scheduler(
114
114
  queued_job_t.InvocationContextManual,
115
115
  ),
116
116
  ):
117
- existing_queued_jobs = datastore.load_job_queue()
118
- duplicate_job = next(
119
- (
120
- job
121
- for job in existing_queued_jobs
122
- if job.job_ref_name == job_ref_name
123
- ),
124
- None,
117
+ existing_queued_job = datastore.get_next_queued_job_for_ref_name(
118
+ job_ref_name=job_ref_name
125
119
  )
126
- if duplicate_job is not None:
127
- return duplicate_job.queued_job_uuid
120
+ if existing_queued_job is not None:
121
+ return existing_queued_job.queued_job_uuid
128
122
  queued_job = datastore.add_job_to_queue(
129
123
  job_payload=payload,
130
124
  job_ref_name=job_ref_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UncountablePythonSDK
3
- Version: 0.0.119
3
+ Version: 0.0.120
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
@@ -25,7 +25,7 @@ examples/set_recipe_output_file_sdk.py,sha256=Lz1amqppnWTX83z-C090wCJ4hcKmCD3kb-
25
25
  examples/upload_files.py,sha256=qMaSvMSdTMPOOP55y1AwEurc0SOdZAMvEydlqJPsGpg,432
26
26
  examples/integration-server/pyproject.toml,sha256=-ZZ1R3B-Pf-F6gQX0-Me6u3G9cVW2B2_eechemCe7_4,9149
27
27
  examples/integration-server/jobs/materials_auto/concurrent_cron.py,sha256=xsK3H9ZEaniedC2nJUB0rqOcFI8y-ojfl_nLSJb9AMM,312
28
- examples/integration-server/jobs/materials_auto/example_cron.py,sha256=7VVQ-UJsq3DbGpN3XPnorRVZYo-vCwbfSU3VVDluIzA,699
28
+ examples/integration-server/jobs/materials_auto/example_cron.py,sha256=spUMiiTEFaepbVXecjD_4aEEfqEtZGGZuWTKs9J6Xcw,736
29
29
  examples/integration-server/jobs/materials_auto/example_http.py,sha256=eVq-Fss_AhmztxOMqqO-GYGF3KvPt1O5HbNwwC2arh8,1037
30
30
  examples/integration-server/jobs/materials_auto/example_instrument.py,sha256=czJF3qBFay1S8fuESOvmkvBv1wCtZGAlHjwvCyYr-Mw,2336
31
31
  examples/integration-server/jobs/materials_auto/example_runsheet_wh.py,sha256=_wILTnbzzLf9zrcQb_KQKytxxcya1ej6MqQnoUSS4fA,1180
@@ -120,7 +120,7 @@ uncountable/integration/executors/script_executor.py,sha256=BBQ9f0l7uH2hgKf60jtm
120
120
  uncountable/integration/http_server/__init__.py,sha256=WY2HMcL0UCAGYv8y6Pz-j0azbDGXwubFF21EH_zNPkc,189
121
121
  uncountable/integration/http_server/types.py,sha256=zVXXN8FPstrF9qFduwQBtxPG8I4AOK41nXAnxrtSgxw,1832
122
122
  uncountable/integration/queue_runner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
- uncountable/integration/queue_runner/job_scheduler.py,sha256=3HE9inu3scwRtxh4wrProKR0P7ghjxlXlo57b706rC4,6259
123
+ uncountable/integration/queue_runner/job_scheduler.py,sha256=Roh7-mTj6rwMzFhBXv7hASNS2dMeTcAZEynJGVjkhEs,6080
124
124
  uncountable/integration/queue_runner/queue_runner.py,sha256=N4sUXmlGzVquybiJ7NQZavCJOBGrxBj6k7mb-TITaN0,1139
125
125
  uncountable/integration/queue_runner/types.py,sha256=8qTq29BTSa5rmW6CBlBntP0pNIiDcwu1wHa78pjroS0,219
126
126
  uncountable/integration/queue_runner/worker.py,sha256=WnFeDQN53QRhiF255ThIT2EeHdPw3QZ503_wPeWRqNE,4493
@@ -135,8 +135,8 @@ uncountable/integration/queue_runner/command_server/protocol/command_server_pb2.
135
135
  uncountable/integration/queue_runner/command_server/protocol/command_server_pb2.pyi,sha256=lWWZuDGoWwtP-gzhADnJi40_lFbO35fUPqNkoOXVnkA,2954
136
136
  uncountable/integration/queue_runner/command_server/protocol/command_server_pb2_grpc.py,sha256=I2kU_anlxOqfaiUR9IcMTuQYvCXa8xliY4sbvXgLYAE,7504
137
137
  uncountable/integration/queue_runner/datastore/__init__.py,sha256=6BefApqN8D2zlVOH14QAeVzwQ8j5NIb41-njT02Za0k,88
138
- uncountable/integration/queue_runner/datastore/datastore_sqlite.py,sha256=M5cg5pC0FokaRZPhmWDTS_JCzrmSE5yNChN15J47klw,4802
139
- uncountable/integration/queue_runner/datastore/interface.py,sha256=IrKdA7i_PWYKb4HXYYsggR589vn-6y408r6Bz8qFFOY,685
138
+ uncountable/integration/queue_runner/datastore/datastore_sqlite.py,sha256=YG3BuivjkAl__ZRwfMnyfx5W_zgQTwSaIPBsl-6s--0,5863
139
+ uncountable/integration/queue_runner/datastore/interface.py,sha256=tNlnY00D_OyuNOL3x_FtHXcJZAAON3SeX7fEU5C8z1U,824
140
140
  uncountable/integration/queue_runner/datastore/model.py,sha256=8-RI5A2yPZVGBLWINVmMd6VOl_oHtqGtnaNXcapAChw,577
141
141
  uncountable/integration/secret_retrieval/__init__.py,sha256=3QXVj35w8rRMxVvmmsViFYDi3lcb3g70incfalOEm6o,87
142
142
  uncountable/integration/secret_retrieval/retrieve_secret.py,sha256=LBEf18KHtXZxg-ZZ80stJ1vW39AWf0CQllP6pNu3Eq8,2994
@@ -324,7 +324,7 @@ uncountable/types/api/triggers/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr
324
324
  uncountable/types/api/triggers/run_trigger.py,sha256=dgDX_sRWSJ36UuzMZhG25oHV1HIOUKYY2G3fjKugZrw,1204
325
325
  uncountable/types/api/uploader/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr8APdZYUniAor8,55
326
326
  uncountable/types/api/uploader/invoke_uploader.py,sha256=Bj7Dq4A90k00suacwk3bLA_dCb2aovS1kAbVam2AQnM,1395
327
- uncountablepythonsdk-0.0.119.dist-info/METADATA,sha256=N4fhXwC1KXS0W6OVTqwJE8XhTlZt6elWg26adle9KFk,2174
328
- uncountablepythonsdk-0.0.119.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
329
- uncountablepythonsdk-0.0.119.dist-info/top_level.txt,sha256=1UVGjAU-6hJY9qw2iJ7nCBeEwZ793AEN5ZfKX9A1uj4,31
330
- uncountablepythonsdk-0.0.119.dist-info/RECORD,,
327
+ uncountablepythonsdk-0.0.120.dist-info/METADATA,sha256=v5j4j9nJrkLYfdm8h9Q-nEIwqmFiDSWSAGGlWUAO8bw,2174
328
+ uncountablepythonsdk-0.0.120.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
329
+ uncountablepythonsdk-0.0.120.dist-info/top_level.txt,sha256=1UVGjAU-6hJY9qw2iJ7nCBeEwZ793AEN5ZfKX9A1uj4,31
330
+ uncountablepythonsdk-0.0.120.dist-info/RECORD,,