scalable-pypeline 2.0.3__py2.py3-none-any.whl → 2.0.5__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.
pypeline/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.0.3"
1
+ __version__ = "2.0.5"
pypeline/composition.py CHANGED
@@ -51,9 +51,8 @@ class parallel_pipeline:
51
51
 
52
52
  self.execution_graph = execution_graph
53
53
 
54
- for message_group in self.messages:
55
- for m in message_group:
56
- m.options["execution_graph"] = execution_graph
54
+ for m in self.messages[0]:
55
+ m.options["execution_graph"] = execution_graph
57
56
 
58
57
  def __len__(self):
59
58
  """Returns the length of the parallel_pipeline."""
pypeline/constants.py CHANGED
@@ -1,5 +1,6 @@
1
1
  """ Pypeline Constants
2
2
  """
3
+
3
4
  import os
4
5
 
5
6
  # Pypeline configuration defaults
@@ -26,7 +27,15 @@ DEFAULT_TASK_MIN_BACKOFF = int(os.getenv("DEFAULT_TASK_MIN_BACKOFF", 15)) # sec
26
27
  DEFAULT_TASK_MAX_BACKOFF = int(
27
28
  os.getenv("DEFAULT_TASK_MAX_BACKOFF", 3600)
28
29
  ) # seconds (1 hour)
29
-
30
+ DEFAULT_BROKER_CONNECTION_HEARTBEAT = int(
31
+ os.getenv("DEFAULT_BROKER_CONNECTION_HEARTBEAT", 5)
32
+ )
33
+ DEFAULT_BROKER_CONNECTION_ATTEMPTS = int(
34
+ os.getenv("DEFAULT_BROKER_CONNECTION_ATTEMPTS", 5)
35
+ )
36
+ DEFAULT_BROKER_BLOCKED_CONNECTION_TIMEOUT = int(
37
+ os.getenv("DEFAULT_BROKER_BLOCKED_CONNECTION_TIMEOUT", 30)
38
+ )
30
39
 
31
40
  MS_IN_SECONDS = 1000
32
41
  API_PATH_V1 = "/api/v1"
pypeline/dramatiq.py CHANGED
@@ -2,7 +2,10 @@ import importlib
2
2
  import os.path
3
3
  import sys
4
4
  import typing
5
+ import pika
5
6
  import logging
7
+ from urllib.parse import urlparse
8
+
6
9
  import click
7
10
  from pypeline.extensions import pypeline_config
8
11
  from warnings import warn
@@ -19,7 +22,7 @@ from dramatiq.cli import (
19
22
  make_argument_parser as dramatiq_argument_parser,
20
23
  import_object,
21
24
  )
22
- from dramatiq.middleware import default_middleware
25
+ from dramatiq.middleware import default_middleware, CurrentMessage
23
26
  from dramatiq.results import Results
24
27
  from dramatiq.results.backends.redis import RedisBackend
25
28
  from flask import current_app, Flask
@@ -35,6 +38,9 @@ from pypeline.constants import (
35
38
  DEFAULT_TASK_MAX_RETRY,
36
39
  DEFAULT_TASK_MIN_BACKOFF,
37
40
  DEFAULT_TASK_MAX_BACKOFF,
41
+ DEFAULT_BROKER_CONNECTION_HEARTBEAT,
42
+ DEFAULT_BROKER_BLOCKED_CONNECTION_TIMEOUT,
43
+ DEFAULT_BROKER_CONNECTION_ATTEMPTS,
38
44
  )
39
45
  from pypeline.middleware import ParallelPipeline
40
46
  from pypeline.utils.config_utils import (
@@ -50,14 +56,29 @@ else:
50
56
  P = TypeVar("P")
51
57
  R = TypeVar("R")
52
58
 
59
+ logging.basicConfig(level=logging.INFO)
53
60
  logger = logging.getLogger(__name__)
54
61
 
55
62
 
56
63
  def configure_default_broker(broker: Broker = None):
57
64
  redis_backend = RedisBackend(url=REDIS_URL)
58
- rabbit_broker = broker if broker is not None else RabbitmqBroker(url=RABBIT_URL)
65
+ parsed_url = urlparse(RABBIT_URL)
66
+ credentials = pika.PlainCredentials(parsed_url.username, parsed_url.password)
67
+ rabbit_broker = (
68
+ broker
69
+ if broker is not None
70
+ else RabbitmqBroker(
71
+ host=parsed_url.host,
72
+ port=parsed_url.port,
73
+ credentials=credentials,
74
+ heartbeat=DEFAULT_BROKER_CONNECTION_HEARTBEAT,
75
+ connection_attempts=DEFAULT_BROKER_CONNECTION_ATTEMPTS,
76
+ blocked_connection_timeout=DEFAULT_BROKER_BLOCKED_CONNECTION_TIMEOUT,
77
+ )
78
+ )
59
79
  rabbit_broker.add_middleware(Results(backend=redis_backend))
60
80
  rabbit_broker.add_middleware(ParallelPipeline(redis_url=REDIS_URL))
81
+ rabbit_broker.add_middleware(CurrentMessage())
61
82
  register_actors_for_workers(rabbit_broker)
62
83
  set_broker(rabbit_broker)
63
84
 
@@ -129,7 +150,6 @@ def register_actors_for_workers(broker: Broker):
129
150
  if not service:
130
151
  return
131
152
  for task in service.get("registeredTasks", []):
132
- print(task)
133
153
  pipeline_meta = None
134
154
  for pipeline_key, pipeline in pypeline_config["pipelines"].items():
135
155
  pipeline_config = pipeline["config"]
@@ -317,9 +337,11 @@ class LazyActor(object):
317
337
  return getattr(self.actor, name)
318
338
 
319
339
  def register(self, broker):
320
- self.actor = register_actor(broker=broker, **self.kw)(
321
- ensure_return_value(default_value=True)(self.fn)
322
- )
340
+ self.actor = register_actor(
341
+ actor_name=f"{self.fn.__module__}.{self.fn.__name__}",
342
+ broker=broker,
343
+ **self.kw,
344
+ )(ensure_return_value(default_value=True)(self.fn))
323
345
 
324
346
  # Next is regular actor API.
325
347
  def send(self, *a, **kw):
@@ -463,8 +485,8 @@ def pypeline_worker(
463
485
  command += ["--queues"] + queues
464
486
  command += verbose * ["-v"]
465
487
  args = parser.parse_args(command)
466
- current_app.logger.info("Able to execute the following actors:")
488
+ logger.info("Able to execute the following actors:")
467
489
  for actor in list_managed_actors(broker, queues):
468
- current_app.logger.info(" %s.", format_actor(actor))
490
+ logger.info(" %s.", format_actor(actor))
469
491
 
470
492
  dramatiq_worker(args)
pypeline/middleware.py CHANGED
@@ -1,6 +1,4 @@
1
1
  import copy
2
- import os
3
-
4
2
  from dramatiq.middleware import Middleware
5
3
 
6
4
  from pypeline.barrier import LockingParallelBarrier
@@ -29,7 +27,6 @@ class ParallelPipeline(Middleware):
29
27
  remaining_tasks = locking_parallel_barrier.decrement_task_count()
30
28
  finally:
31
29
  locking_parallel_barrier.release_lock()
32
-
33
30
  if remaining_tasks <= 0:
34
31
  execution_graph = message.options.get("execution_graph")
35
32
 
@@ -54,8 +51,10 @@ class ParallelPipeline(Middleware):
54
51
  lock_key=f"{completion_uuid}-lock",
55
52
  )
56
53
  locking_parallel_barrier.set_task_count(len(next_group))
54
+ execution_graph_copy = copy.deepcopy(execution_graph)
55
+
57
56
  for next_message in next_group:
58
57
  next_message["options"][
59
58
  "execution_graph"
60
- ] = copy.deepcopy(execution_graph)
59
+ ] = execution_graph_copy
61
60
  broker.enqueue(Message(**next_message))
@@ -79,8 +79,6 @@ def process_non_none_value(value: T) -> None:
79
79
  """
80
80
  if value is None:
81
81
  raise ValueError("None value is not allowed")
82
- # Process the value
83
- print(f"Processing value: {value}")
84
82
 
85
83
 
86
84
  def topological_sort_with_parallelism(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scalable-pypeline
3
- Version: 2.0.3
3
+ Version: 2.0.5
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,10 +1,10 @@
1
- pypeline/__init__.py,sha256=_GEKEa6BYjBV34SZkSlAR87aCM5Y9G0aSI0LXL52iJg,22
1
+ pypeline/__init__.py,sha256=xEb7Z4b8xalXXExBg42XPAhbJKniHzcsEPjp-6S3ppg,22
2
2
  pypeline/barrier.py,sha256=dLDaprH5NB-C7MQjZqPpBBhMjmO0VV_kTonlgweznHc,1096
3
- pypeline/composition.py,sha256=tnSe9CHejayBGI__VMFpQ6NYuebTqoPTWuKiBMnANKc,13025
4
- pypeline/constants.py,sha256=vi4UZz1xd0ZeIuelp4QgCQsMlIHW65-lVB8l_iA8kBE,2578
5
- pypeline/dramatiq.py,sha256=jr9WORqtusC1gnbvF59CNXny8ORk2Lmlbmf1qsbiLXo,14799
3
+ pypeline/composition.py,sha256=pTw9Xb9h4JnV4siFc3JStm5lB-i9djUADo3Kh5K3s7g,12976
4
+ pypeline/constants.py,sha256=coiF8dMP25qIwoNYSnS7oy7hCd4-5yqPFmdPsN93Q1A,2892
5
+ pypeline/dramatiq.py,sha256=K633IDydEwO0tfLmRU48B2jhymUbcC3EON3JVKJ74J4,15578
6
6
  pypeline/extensions.py,sha256=BzOTnXhNxap3N7uIUUh_hO6dDwx08Vc_RJDE93_K0Lo,610
7
- pypeline/middleware.py,sha256=6vWNCoRVqnASJ40CAOEpe0JcYRpB6BTkLz8E51q4z2Y,2756
7
+ pypeline/middleware.py,sha256=kTp6niYoe2nXIiN6EGRfdpxrJyioo0GPxDkfefbGlEk,2821
8
8
  pypeline/pipeline_config_schema.py,sha256=DQ_RMucnA0AyrndlW6lkb0orGromcO6C9GgLHyG6lJ0,8013
9
9
  pypeline/pypeline_yaml.py,sha256=Og08sUKwOjq7JYPnkg-NIcGbHravYCkC5Arz22rZEtA,16981
10
10
  pypeline/schedule_config_schema.py,sha256=vtZV-5wpGcAiYcXxdBPRkrjsbR6x_9E-1PC2elrKKbE,3611
@@ -17,11 +17,11 @@ pypeline/flask/api/schedules.py,sha256=31lwoFlGv-S-2ahGUCnD5YbmKws8yddj6_PEzzdBi
17
17
  pypeline/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  pypeline/utils/config_utils.py,sha256=rAIATyoW7kGETZ_Z2DqiXtGd7bJp5uPfcLtfNPOYsNs,2167
19
19
  pypeline/utils/module_utils.py,sha256=boEP9IYr4p_ick7HlVUfIxOYHQlEmo7dgvDBCQc-C28,2914
20
- pypeline/utils/pipeline_utils.py,sha256=dewzkMajs7uyPHyHjJfISA9pc2-1J5A99Hm4XqNw5qM,6031
20
+ pypeline/utils/pipeline_utils.py,sha256=tt71hLEFgPieokJZlC1rP2dmCTctrOPt7K1rGlbnT4o,5967
21
21
  tests/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- scalable_pypeline-2.0.3.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
23
- scalable_pypeline-2.0.3.dist-info/METADATA,sha256=5P802DsrRS3QyRxK07sls35o6P7_gHJBEkuhb8GGPwQ,6239
24
- scalable_pypeline-2.0.3.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
25
- scalable_pypeline-2.0.3.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
26
- scalable_pypeline-2.0.3.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
27
- scalable_pypeline-2.0.3.dist-info/RECORD,,
22
+ scalable_pypeline-2.0.5.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
23
+ scalable_pypeline-2.0.5.dist-info/METADATA,sha256=-YlluvvoDLhu8q8Ey2lYdynmjPb_MMO2i2pdIVH8z_A,6239
24
+ scalable_pypeline-2.0.5.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
25
+ scalable_pypeline-2.0.5.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
26
+ scalable_pypeline-2.0.5.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
27
+ scalable_pypeline-2.0.5.dist-info/RECORD,,