scalable-pypeline 2.1.27__py2.py3-none-any.whl → 2.1.28__py2.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 scalable-pypeline might be problematic. Click here for more details.

pypeline/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.1.27"
1
+ __version__ = "2.1.28"
@@ -46,82 +46,74 @@ class PypelineMiddleware(Middleware):
46
46
 
47
47
  graph = get_execution_graph(pipeline_config)
48
48
  children_tasks = pipeline_config["dagAdjacency"].get(task_name, [])
49
-
50
49
  messages = []
51
50
  for child in children_tasks:
52
51
  child_ancestors = sorted(graph.predecessors(child))
52
+ child_ancestors_complete = {a: False for a in child_ancestors}
53
53
 
54
- ancestor_tasks_complete = True
54
+ for scenario in message.options["scenarios"]:
55
+ if scenario["execution_id"] == execution_id:
56
+ tasks_to_run_in_scenario = scenario["tasksToRunInScenario"]
55
57
 
56
58
  for ancestor in child_ancestors:
57
- ancestor_task_key = f"{execution_id}-{ancestor}"
58
-
59
- locking_parallel_barrier = LockingParallelBarrier(
60
- self.redis_url,
61
- task_key=ancestor_task_key,
62
- lock_key=f"{message.options['base_case_execution_id']}-lock",
63
- )
64
- try:
65
- locking_parallel_barrier.acquire_lock(
66
- timeout=PARALLEL_PIPELINE_CALLBACK_BARRIER_TTL
59
+ if ancestor in tasks_to_run_in_scenario:
60
+ current_scenario_ancestor_task_key = f"{execution_id}-{ancestor}"
61
+ locking_parallel_barrier = LockingParallelBarrier(
62
+ self.redis_url,
63
+ task_key=current_scenario_ancestor_task_key,
64
+ lock_key=f"{message.options['base_case_execution_id']}-lock",
67
65
  )
68
-
69
- if locking_parallel_barrier.task_exists():
70
- remaining_tasks = locking_parallel_barrier.get_task_count()
71
- else:
72
- remaining_tasks = None
73
- finally:
74
- locking_parallel_barrier.release_lock()
75
-
76
- # If the lock didn't exist for the current tasks execution id then it would indicate
77
- # that this is the start of a new scenario. Therefore we need to find the ancestor
78
- # that is executed in the base case execution id and make sure it has completed
79
- tasks_to_run_in_scenario = None
80
-
81
- for scenario in message.options["scenarios"]:
82
- if scenario["execution_id"] == execution_id:
83
- tasks_to_run_in_scenario = scenario["tasksToRunInScenario"]
84
-
85
- if ancestor not in tasks_to_run_in_scenario and remaining_tasks is None:
86
- ancestor_task_key = (
66
+ try:
67
+ locking_parallel_barrier.acquire_lock(
68
+ timeout=PARALLEL_PIPELINE_CALLBACK_BARRIER_TTL
69
+ )
70
+ if not locking_parallel_barrier.task_exists():
71
+ child_ancestors_complete[ancestor] = False
72
+ elif locking_parallel_barrier.get_task_count() <= 0:
73
+ child_ancestors_complete[ancestor] = True
74
+ finally:
75
+ locking_parallel_barrier.release_lock()
76
+ else:
77
+ base_scenario_ancestor_task_key = (
87
78
  f"{message.options['base_case_execution_id']}-{ancestor}"
88
79
  )
89
-
90
80
  locking_parallel_barrier = LockingParallelBarrier(
91
81
  self.redis_url,
92
- task_key=ancestor_task_key,
82
+ task_key=base_scenario_ancestor_task_key,
93
83
  lock_key=f"{message.options['base_case_execution_id']}-lock",
94
84
  )
95
85
  try:
96
86
  locking_parallel_barrier.acquire_lock(
97
87
  timeout=PARALLEL_PIPELINE_CALLBACK_BARRIER_TTL
98
88
  )
99
-
100
- if locking_parallel_barrier.task_exists():
101
- remaining_tasks = locking_parallel_barrier.get_task_count()
89
+ if not locking_parallel_barrier.task_exists():
90
+ child_ancestors_complete[ancestor] = False
91
+ elif locking_parallel_barrier.get_task_count() <= 0:
92
+ child_ancestors_complete[ancestor] = True
102
93
  finally:
103
94
  locking_parallel_barrier.release_lock()
104
95
 
105
-
106
- if remaining_tasks is None or remaining_tasks >= 1:
107
- ancestor_tasks_complete = False
108
- break
109
-
110
- # If the child's ancestor tasks aren't complete move onto the next child to check
111
- if not ancestor_tasks_complete:
96
+ if any(complete is False for complete in child_ancestors_complete.values()):
112
97
  continue
113
98
 
114
- # Handle situation where base case kicks off new scenario.
115
99
  if (
116
100
  message.options["base_case_execution_id"]
117
101
  == message.options["execution_id"]
118
102
  ):
119
103
  for scenario in message.options["scenarios"]:
120
- child_predecessors = list(graph.predecessors(child))
104
+ child_ancestors = list(graph.predecessors(child))
105
+ child_has_other_ancestors_in_scenario = False
106
+
107
+ for ancestor in child_ancestors:
108
+ if ancestor in scenario["tasksToRunInScenario"]:
109
+ child_has_other_ancestors_in_scenario = True
110
+ break
111
+
121
112
  if (
122
113
  child in scenario["tasksToRunInScenario"]
123
- and task_name in child_predecessors
114
+ and task_name in child_ancestors
124
115
  and task_name not in scenario["tasksToRunInScenario"]
116
+ and not child_has_other_ancestors_in_scenario
125
117
  ):
126
118
  task_key = f"{scenario['execution_id']}-{child}"
127
119
  locking_parallel_barrier = LockingParallelBarrier(
@@ -168,7 +160,7 @@ class PypelineMiddleware(Middleware):
168
160
  )
169
161
  messages.append(scenario_message)
170
162
 
171
- # If we've made it here all ancestors of this child are complete and it's time to run.
163
+ # If we've made it here all ancestors of this child are complete, and it's time to run.
172
164
  task_key = f"{execution_id}-{child}"
173
165
  locking_parallel_barrier = LockingParallelBarrier(
174
166
  self.redis_url,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scalable-pypeline
3
- Version: 2.1.27
3
+ Version: 2.1.28
4
4
  Summary: PypeLine - Python pipelines for the Real World
5
5
  Home-page: https://gitlab.com/bravos2/pypeline
6
6
  Author: Bravos Power Corporation
@@ -1,4 +1,4 @@
1
- pypeline/__init__.py,sha256=nRu7ZwJqfHD5II0bBxcWlJ8czOdWw1bjjPVhymDs-NE,23
1
+ pypeline/__init__.py,sha256=uJ5T75rsS9yyIgD9aFR6H760hkKMyujptvhmniMPJSY,23
2
2
  pypeline/barrier.py,sha256=ojSgbuZnGKpKiSBYXTV4CxG9j1Z01YdzBSORli4MnzI,2376
3
3
  pypeline/constants.py,sha256=7COt9jfmLDvCNAFeN6ddRpwdvv2LpbYOCIQs6dPXpOQ,3592
4
4
  pypeline/dramatiq.py,sha256=XPpgPgiOaEFK8zORx9eveJ45wzcUXMjVGryFKY5Xiwg,15527
@@ -23,7 +23,7 @@ pypeline/pipelines/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
23
23
  pypeline/pipelines/middleware/get_active_worker_id_middleware.py,sha256=X4ZfRk3L8MD00DTsGHth7oOdy-W7LQV96T8vu5UC42A,755
24
24
  pypeline/pipelines/middleware/graceful_shutdown_middleware.py,sha256=k37zmFk9dOye05BoQP7KcB9MEQgvodI16kOJyYhRyAc,1764
25
25
  pypeline/pipelines/middleware/parallel_pipeline_middleware.py,sha256=kTp6niYoe2nXIiN6EGRfdpxrJyioo0GPxDkfefbGlEk,2821
26
- pypeline/pipelines/middleware/pypeline_middleware.py,sha256=tnQcewRCCaQaNMTx9Kz0gx47YZxBJCDW9UH_8cBLlwY,9317
26
+ pypeline/pipelines/middleware/pypeline_middleware.py,sha256=FjREuPDdTfeYOVGVUjJgx8Szh6yu7g8OnHRc5N__448,9385
27
27
  pypeline/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  pypeline/utils/config_utils.py,sha256=bblh8clRDDNQpQIDkBrtskZBo-csakoO1IJiaqVGyr8,2508
29
29
  pypeline/utils/dramatiq_utils.py,sha256=tbG3o5FD0zUOKtJJJECE2cM2ovDv3OLQ5CplJ9cXfM4,4001
@@ -33,9 +33,9 @@ pypeline/utils/module_utils.py,sha256=-yEJIukDCoXnmlZVXB6Dww25tH6GdPE5SoFqv6pfdV
33
33
  pypeline/utils/pipeline_utils.py,sha256=kGP1QwCJikGC5QNRtzRXCDVewyRMpWIqERTNnxGLlSY,4795
34
34
  pypeline/utils/schema_utils.py,sha256=Fgl0y9Cuo_TZeEx_S3gaSVnLjn6467LTkjb2ek7Ms98,851
35
35
  tests/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- scalable_pypeline-2.1.27.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
37
- scalable_pypeline-2.1.27.dist-info/METADATA,sha256=D-3zqFydd6j3FTAvnz1VSjQBobpx7XcR_Oz4J_-2BU8,5985
38
- scalable_pypeline-2.1.27.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
39
- scalable_pypeline-2.1.27.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
40
- scalable_pypeline-2.1.27.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
41
- scalable_pypeline-2.1.27.dist-info/RECORD,,
36
+ scalable_pypeline-2.1.28.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
37
+ scalable_pypeline-2.1.28.dist-info/METADATA,sha256=f0Ib-ADg8STVoxyrTo1PCy0KbOsGW9PB-jBeo5keGF8,5985
38
+ scalable_pypeline-2.1.28.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
39
+ scalable_pypeline-2.1.28.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
40
+ scalable_pypeline-2.1.28.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
41
+ scalable_pypeline-2.1.28.dist-info/RECORD,,