corva-worker-python 1.1.1__tar.gz → 1.2.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.
Files changed (81) hide show
  1. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/PKG-INFO +1 -1
  2. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/corva_worker_python.egg-info/PKG-INFO +1 -1
  3. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/setup.py +1 -1
  4. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/app/app_lambda.py +1 -1
  5. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/app/app_partial_rerun_merger.py +2 -2
  6. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/event/event_handler.py +1 -1
  7. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/partial_rerun_merge/merge.py +26 -17
  8. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/partial_rerun_merge/progress.py +6 -3
  9. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/README.md +0 -0
  10. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/corva_worker_python.egg-info/SOURCES.txt +0 -0
  11. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/corva_worker_python.egg-info/dependency_links.txt +0 -0
  12. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/corva_worker_python.egg-info/requires.txt +0 -0
  13. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/corva_worker_python.egg-info/top_level.txt +0 -0
  14. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/pyproject.toml +0 -0
  15. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/setup.cfg +0 -0
  16. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/app/__init__.py +0 -0
  17. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/app/app_constants.py +0 -0
  18. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/app/disable_module.py +0 -0
  19. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/app/drilling_efficiency_app.py +0 -0
  20. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/app/surface_mse_module.py +0 -0
  21. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/state_testing_app/__init__.py +0 -0
  22. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/state_testing_app/app_constants.py +0 -0
  23. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/state_testing_app/app_lambda.py +0 -0
  24. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/state_testing_app/state_modules.py +0 -0
  25. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/testcase/state_testing_app/state_testing_app.py +0 -0
  26. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/__init__.py +0 -0
  27. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/__init__.py +0 -0
  28. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/modules/__init__.py +0 -0
  29. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/modules/activity_module.py +0 -0
  30. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/modules/connection_module.py +0 -0
  31. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/modules/depth_activity_module.py +0 -0
  32. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/modules/scheduler.py +0 -0
  33. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/modules/time_activity_module.py +0 -0
  34. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/app/modules/trigger.py +0 -0
  35. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/constants.py +0 -0
  36. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/__init__.py +0 -0
  37. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/activity/__init__.py +0 -0
  38. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/activity/activity_grouping.py +0 -0
  39. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/alert.py +0 -0
  40. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/api.py +0 -0
  41. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/enums.py +0 -0
  42. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/json_encoder.py +0 -0
  43. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/math.py +0 -0
  44. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/operations.py +0 -0
  45. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/serialization.py +0 -0
  46. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/task_handler.py +0 -0
  47. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/two_way_dict.py +0 -0
  48. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/unit_conversions.py +0 -0
  49. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/data/wits.py +0 -0
  50. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/event/__init__.py +0 -0
  51. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/event/scheduled.py +0 -0
  52. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/event/stream.py +0 -0
  53. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/exceptions.py +0 -0
  54. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/mixins/__init__.py +0 -0
  55. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/mixins/logging.py +0 -0
  56. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/mixins/rollbar.py +0 -0
  57. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/partial_rerun_merge/__init__.py +0 -0
  58. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/partial_rerun_merge/models.py +0 -0
  59. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/state/__init__.py +0 -0
  60. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/state/mixins.py +0 -0
  61. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/state/state.py +0 -0
  62. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/test/__init__.py +0 -0
  63. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/test/lambda_function_test_run.py +0 -0
  64. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/test/local_testing/__init__.py +0 -0
  65. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/test/local_testing/to_local_transfer.py +0 -0
  66. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/test/utils.py +0 -0
  67. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/__init__.py +0 -0
  68. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/factory.py +0 -0
  69. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/measured_depth_finder.py +0 -0
  70. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/__init__.py +0 -0
  71. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/ann.py +0 -0
  72. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/annulus.py +0 -0
  73. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/drillstring.py +0 -0
  74. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/drillstring_components.py +0 -0
  75. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/element.py +0 -0
  76. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/enums.py +0 -0
  77. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/hole.py +0 -0
  78. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/hole_section.py +0 -0
  79. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/model/riser.py +0 -0
  80. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/sections_mixin.py +0 -0
  81. {corva-worker-python-1.1.1 → corva-worker-python-1.2.1}/worker/wellbore/wellbore.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: corva-worker-python
3
- Version: 1.1.1
3
+ Version: 1.2.1
4
4
  Summary: SDK for interacting with Corva
5
5
  Home-page: https://github.com/corva-ai/corva-worker-python
6
6
  Author: Jordan Ambra <jordan.ambra@corva.ai>, Mohammadreza Kamyab <m.kamyab@corva.ai>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.2
2
2
  Name: corva-worker-python
3
- Version: 1.1.1
3
+ Version: 1.2.1
4
4
  Summary: SDK for interacting with Corva
5
5
  Home-page: https://github.com/corva-ai/corva-worker-python
6
6
  Author: Jordan Ambra <jordan.ambra@corva.ai>, Mohammadreza Kamyab <m.kamyab@corva.ai>
@@ -18,7 +18,7 @@ setup(
18
18
  name='corva-worker-python',
19
19
  author='Jordan Ambra <jordan.ambra@corva.ai>, Mohammadreza Kamyab <m.kamyab@corva.ai>',
20
20
  url='https://github.com/corva-ai/corva-worker-python',
21
- version='1.1.1',
21
+ version='1.2.1',
22
22
  classifiers=classifiers,
23
23
  python_requires='>=3.8',
24
24
  description='SDK for interacting with Corva',
@@ -20,7 +20,7 @@ def lambda_handler(event, context):
20
20
 
21
21
  app = DrillingEfficiency()
22
22
 
23
- merger = AppPartialRerunMerger(app, API(), context, Logger.get_logger())
23
+ merger = AppPartialRerunMerger(app, API(), Logger.get_logger())
24
24
 
25
25
  event_handler = EventHandler(app, merger)
26
26
  event_handler.process(event)
@@ -10,10 +10,10 @@ SCHEMA = MergingSchemaModel(collections=collections, modules=None)
10
10
 
11
11
 
12
12
  class AppPartialRerunMerger(PartialRerunMerge):
13
- def __init__(self, app, api, context, logger):
13
+ def __init__(self, app, api, logger):
14
14
  # adding the required modules to the schema
15
15
  schema = SCHEMA
16
16
  # app itself has a cache so it needs to be added to the schema as well
17
17
  schema.modules = [app] + app.get_active_modules()
18
18
 
19
- super().__init__(schema, api, context, logger)
19
+ super().__init__(schema, api, logger)
@@ -47,7 +47,7 @@ class EventHandler:
47
47
  """Full run of the events based on their asset id"""
48
48
  for _asset_id, event in self.event_by_asset_id.items():
49
49
  if self.event_type == EventType.PARTIAL_RERUN:
50
- self.merger.perform_merge(event)
50
+ self.merger.perform_merge(event.get("data", {}))
51
51
  continue
52
52
 
53
53
  self.app.load(self.event_type, event)
@@ -37,7 +37,6 @@ class PartialRerunMerge:
37
37
  self,
38
38
  schema: MergingSchemaModel,
39
39
  api: API,
40
- context,
41
40
  logger,
42
41
  ):
43
42
  """
@@ -46,7 +45,6 @@ class PartialRerunMerge:
46
45
  self.schema = schema
47
46
 
48
47
  self.api = api
49
- self.lambda_context = context
50
48
  self.logger = logger
51
49
 
52
50
  remaining_seconds_threshold = os.getenv("PARTIAL_RERUN_REMAINING_SECONDS_THRESHOLD")
@@ -61,6 +59,7 @@ class PartialRerunMerge:
61
59
  self.start_timestamp: Optional[int] = None
62
60
  self.end_timestamp: Optional[int] = None
63
61
  self.rerun_mode: Optional[RerunMode] = None
62
+ self.run_until: Optional[int] = None
64
63
 
65
64
  self.start_hole_depth: Optional[float] = None
66
65
  self.end_hole_depth: Optional[float] = None
@@ -72,6 +71,10 @@ class PartialRerunMerge:
72
71
  Performs a merge operation by updating the cache state,
73
72
  merging collections, and updating the status.
74
73
 
74
+ :param event: the event which should be the data part of
75
+ a an event dict, or a python sdk partial rerun event object
76
+ that is converted to a dict
77
+
75
78
  :raises Exception: if an error occurs during the merge operation
76
79
  """
77
80
  self.preprocess(event)
@@ -88,20 +91,23 @@ class PartialRerunMerge:
88
91
  def preprocess(self, event: dict) -> None:
89
92
  """
90
93
  Performs any necessary preprocessing before the merge operation.
91
- """
92
- # Add your preprocessing logic here
93
- event = event.get("data") or {}
94
94
 
95
- self.partial_well_rerun_id = event.get("partial_well_rerun_id")
96
- self.app_id = event.get("app_id")
97
- self.original_asset_id = event.get("asset_id")
98
- self.rerun_asset_id = event.get("rerun_asset_id")
95
+ :param event: the event which should be the data part of
96
+ a an event dict, or a python sdk partial rerun event object
97
+ that is converted to a dict
98
+ """
99
+ self.partial_well_rerun_id = event["partial_well_rerun_id"]
100
+ self.app_id = event["app_id"]
101
+ self.original_asset_id = event["asset_id"]
102
+ self.rerun_asset_id = event["rerun_asset_id"]
99
103
 
100
104
  segment = event.get("source_type")
101
105
  if segment != "drilling":
102
106
  raise ValueError(f"Invalid source type: {segment}")
103
107
 
104
- self.start_timestamp = event.get("start")
108
+ self.run_until = event["run_until"]
109
+
110
+ self.start_timestamp = event["start"]
105
111
  start_wits = self.get_wits_at_or(self.rerun_asset_id, self.start_timestamp, "after")
106
112
 
107
113
  if end := event.get("end"):
@@ -111,10 +117,13 @@ class PartialRerunMerge:
111
117
  end_wits = self.get_wits_at_or(self.rerun_asset_id, self.MAX_TIMESTAMP, "before")
112
118
  self.end_timestamp = end_wits.get("timestamp")
113
119
 
114
- self.start_hole_depth = start_wits.get("data").get("hole_depth")
115
- self.end_hole_depth = end_wits.get("data").get("hole_depth")
120
+ if not self.end_timestamp:
121
+ self.end_timestamp = self.MAX_TIMESTAMP
122
+
123
+ self.start_hole_depth = start_wits.get("data", {}).get("hole_depth")
124
+ self.end_hole_depth = end_wits.get("data", {}).get("hole_depth")
116
125
 
117
- self.rerun_mode = RerunMode(event.get("rerun_mode"))
126
+ self.rerun_mode = RerunMode(event["rerun_mode"])
118
127
 
119
128
  self.merging_progress = MergingProgress(self.partial_well_rerun_id, self.app_id, self.api)
120
129
 
@@ -267,19 +276,19 @@ class PartialRerunMerge:
267
276
  :param apply_half: whether to apply half of the remaining seconds threshold
268
277
  :return: True if there is enough time, False otherwise
269
278
  """
270
- if not self.lambda_context:
279
+ if not self.run_until:
271
280
  return True
272
281
 
273
- remaining_seconds = self.get_remaining_seconds()
282
+ remaining_seconds = self._get_remaining_seconds()
274
283
  threshold = self.REMAINING_SECONDS_THRESHOLD_HALF if apply_half else self.REMAINING_SECONDS_THRESHOLD
275
284
  return remaining_seconds > threshold
276
285
 
277
- def get_remaining_seconds(self) -> int:
286
+ def _get_remaining_seconds(self) -> float:
278
287
  """
279
288
  Gets the remaining seconds before the Lambda function times out.
280
289
  :return: the remaining seconds
281
290
  """
282
- return self.lambda_context.get_remaining_time_in_millis() // 1000
291
+ return self.run_until - time.time()
283
292
 
284
293
  def get_wits_at_or(self, asset_id: int, timestamp: Optional[int], direction: Literal["before", "after"]) -> dict:
285
294
  """
@@ -130,7 +130,7 @@ class MergingProgress:
130
130
  def parse_progress(self, request: dict) -> None:
131
131
  """
132
132
  Parses the progress information retrieved from the API and populates the
133
- 'datasetProgresses' list.
133
+ 'dataset_progresses' list.
134
134
 
135
135
  Args:
136
136
  request (dict): The progress information retrieved from the API.
@@ -138,10 +138,13 @@ class MergingProgress:
138
138
  Returns:
139
139
  None
140
140
  """
141
- collections = request["included"]
141
+ collections = request.get("included") or []
142
142
 
143
143
  for collection in collections:
144
- if not (attributes := collection.get("attributes")):
144
+ attributes = collection.get("attributes") or {}
145
+ dataset_name = attributes.get("dataset_name")
146
+
147
+ if not dataset_name:
145
148
  continue
146
149
 
147
150
  dataset_progress = DatasetProgress.set_from_dict(attributes)