scalable-pypeline 2.0.7__py2.py3-none-any.whl → 2.0.9__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.7"
1
+ __version__ = "2.0.9"
pypeline/dramatiq.py CHANGED
@@ -179,8 +179,7 @@ def register_actors_for_workers(broker: Broker):
179
179
  pipeline_meta["store_results"] = True
180
180
  _ = register_lazy_actor(broker, tmp_handler, pipeline_meta)
181
181
  except Exception as e:
182
- print(e)
183
- print(f"Unable to add a task to dramatiq: {e}")
182
+ logger.exception(f"Unable to add a task to dramatiq: {e}")
184
183
 
185
184
 
186
185
  class Dramatiq:
@@ -260,7 +259,7 @@ class Dramatiq:
260
259
 
261
260
  # Callable function is expected to setBroker()
262
261
  if callable(broker_or_callable):
263
- print(f"Configuring broker via {DEFAULT_BROKER_CALLABLE}")
262
+ logger.info(f"Configuring broker via {DEFAULT_BROKER_CALLABLE}")
264
263
  broker_or_callable()
265
264
  else:
266
265
  raise TypeError("DEFAULT_BROKER_CALLABLE must point to a callable function")
@@ -368,7 +367,15 @@ def list_managed_actors(broker, queues):
368
367
  def cron_scheduler(): # pragma: no cover
369
368
  # Configure our broker that we will schedule registered tasks for
370
369
  scheduler = BlockingScheduler()
371
- configure_default_broker()
370
+ module_name, broker_or_callable = import_object(DEFAULT_BROKER_CALLABLE)
371
+
372
+ # Callable function is expected to setBroker()
373
+ if callable(broker_or_callable):
374
+ logger.info(f"Configuring broker via {DEFAULT_BROKER_CALLABLE}")
375
+ broker_or_callable()
376
+ else:
377
+ raise TypeError("DEFAULT_BROKER_CALLABLE must point to a callable function")
378
+
372
379
  broker = get_broker()
373
380
  jobs = retrieve_latest_schedule_config()
374
381
 
@@ -1,25 +1,46 @@
1
1
  """ Pipeline APIs
2
2
  """
3
+
4
+ import importlib.metadata
3
5
  import logging
4
6
 
5
7
  from flask import jsonify
6
- from flask_smorest import Blueprint
7
8
  from flask.views import MethodView
9
+ from flask_smorest import Blueprint
8
10
  from marshmallow import Schema, fields
9
11
  from marshmallow.exceptions import ValidationError
10
12
  from webargs.flaskparser import abort
11
-
13
+ from packaging import version
12
14
  from pypeline.composition import PipelineResult
13
15
  from pypeline.constants import API_DOC_RESPONSES, API_DOC_PARAMS, API_PATH_V1
14
- from pypeline.utils.pipeline_utils import dag_generator
15
16
  from pypeline.flask.decorators import require_accesskey
16
- from pypeline.utils.config_utils import retrieve_latest_pipeline_config
17
17
  from pypeline.pipeline_config_schema import BasePipelineSchema, PipelineSchemaV1
18
+ from pypeline.utils.config_utils import retrieve_latest_pipeline_config
19
+ from pypeline.utils.pipeline_utils import dag_generator
18
20
 
19
21
  logger = logging.getLogger(__name__)
20
22
  bp = Blueprint("pipelines", __name__, url_prefix=API_PATH_V1 + "/pipelines")
21
23
 
22
24
 
25
+ try:
26
+ flask_smorest_version = importlib.metadata.version("flask-smorest")
27
+ flask_smorest_version_parsed = version.parse(flask_smorest_version)
28
+ except importlib.metadata.PackageNotFoundError:
29
+ flask_smorest_version_parsed = None
30
+
31
+
32
+ def get_response_decorator(bp, status_code, *args, **kwargs):
33
+ if flask_smorest_version is None:
34
+ # Handle the case where flask-smorest is not installed
35
+ raise ImportError("flask-smorest is not installed.")
36
+ elif flask_smorest_version_parsed < version.parse("0.29"):
37
+ # Adjust arguments for older versions if needed
38
+ return bp.response(*args, **kwargs)
39
+ else:
40
+ # Adjust arguments for newer versions if needed
41
+ return bp.response(status_code, *args, **kwargs)
42
+
43
+
23
44
  class InvokePipelineSchema(Schema):
24
45
  """Incoming schema for invoking a pipeline"""
25
46
 
@@ -135,7 +156,7 @@ class PipelineInvoke(MethodView):
135
156
  tags=["Pipelines"],
136
157
  )
137
158
  @bp.arguments(InvokePipelineSchema)
138
- @bp.response(InvokePipelineResponseSchema)
159
+ @get_response_decorator(bp, "200", InvokePipelineResponseSchema)
139
160
  def post(self, payload: dict, pipeline_id: str):
140
161
  """Invoke a pipeline by it's ID; optionally provide pipeline arguments."""
141
162
  pipeline_config = retrieve_latest_pipeline_config(pipeline_id=pipeline_id)
@@ -191,7 +212,7 @@ class PipelineResults(MethodView):
191
212
  ],
192
213
  tags=["Pipelines"],
193
214
  )
194
- @bp.response(GetPipelineResultResponseSchema)
215
+ @get_response_decorator(bp, "200", GetPipelineResultResponseSchema)
195
216
  def get(self, execution_id: str):
196
217
  """Retrieve results of a pipeline's execution based on execution_id
197
218
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scalable-pypeline
3
- Version: 2.0.7
3
+ Version: 2.0.9
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
@@ -8,30 +8,24 @@ License: Apache License 2.0
8
8
  Description-Content-Type: text/markdown
9
9
  License-File: LICENSE
10
10
  Requires-Dist: PyYAML (<7,>=6.0.1)
11
- Requires-Dist: click (==8.0.4)
12
11
  Requires-Dist: marshmallow (<4,>=3.2.1)
13
12
  Requires-Dist: redis (<5,>=4.5.4)
14
- Requires-Dist: db-medley[redis] (<2,>=1.0.2)
15
13
  Requires-Dist: croniter (<2,>=1.0.15)
14
+ Requires-Dist: db-medley[redis] (<2,>=1.0.2)
16
15
  Provides-Extra: build
17
16
  Requires-Dist: wheel ; extra == 'build'
18
17
  Requires-Dist: twine ; extra == 'build'
19
18
  Provides-Extra: dev
20
- Requires-Dist: blackd ; extra == 'dev'
19
+ Requires-Dist: black ; extra == 'dev'
21
20
  Provides-Extra: flask
22
- Requires-Dist: Werkzeug (==2.0.3) ; extra == 'flask'
23
- Requires-Dist: itsdangerous (==2.0.1) ; extra == 'flask'
24
- Requires-Dist: Flask (<2,>=1.1.2) ; extra == 'flask'
25
- Requires-Dist: flask-smorest (<0.29,>=0.23.0) ; extra == 'flask'
26
- Requires-Dist: Jinja2 (==3.0.3) ; extra == 'flask'
21
+ Requires-Dist: markupsafe (==2.0.1) ; extra == 'flask'
22
+ Requires-Dist: flask-smorest (<1,>=0.23.0) ; extra == 'flask'
27
23
  Provides-Extra: test
28
24
  Requires-Dist: pytest-cov (<3,>=2.6.1) ; extra == 'test'
29
25
  Requires-Dist: tox (<4,>=3.14.1) ; extra == 'test'
30
26
  Requires-Dist: mock (<2,>=1) ; extra == 'test'
31
- Requires-Dist: moto (<4,>=1.3.16) ; extra == 'test'
32
27
  Requires-Dist: responses (<0.11,>=0.10.16) ; extra == 'test'
33
28
  Requires-Dist: fakeredis (<3,>=2.10.3) ; extra == 'test'
34
- Requires-Dist: importlib-metadata (<5,>=4.12) ; extra == 'test'
35
29
  Provides-Extra: web
36
30
  Requires-Dist: gunicorn ; extra == 'web'
37
31
  Requires-Dist: gevent (<22,>=21.12.0) ; extra == 'web'
@@ -1,8 +1,8 @@
1
- pypeline/__init__.py,sha256=L4aOgvDE9n_eqL_mM_j5bO3bQ73q6ulNpnVuG8OmqWE,22
1
+ pypeline/__init__.py,sha256=pZib55qStLeBfZabni1F1OCNxdT02xP-5e34LjIBswQ,22
2
2
  pypeline/barrier.py,sha256=dLDaprH5NB-C7MQjZqPpBBhMjmO0VV_kTonlgweznHc,1096
3
3
  pypeline/composition.py,sha256=pTw9Xb9h4JnV4siFc3JStm5lB-i9djUADo3Kh5K3s7g,12976
4
4
  pypeline/constants.py,sha256=coiF8dMP25qIwoNYSnS7oy7hCd4-5yqPFmdPsN93Q1A,2892
5
- pypeline/dramatiq.py,sha256=jghG2F57Z3NSxHvHz1yyYvdLwje0KdhcWQQEhBGOTf4,15583
5
+ pypeline/dramatiq.py,sha256=Y909HoNhH5Berd61N6nHrpE1dTU-zmvimH91SldP-SI,15912
6
6
  pypeline/extensions.py,sha256=BzOTnXhNxap3N7uIUUh_hO6dDwx08Vc_RJDE93_K0Lo,610
7
7
  pypeline/middleware.py,sha256=kTp6niYoe2nXIiN6EGRfdpxrJyioo0GPxDkfefbGlEk,2821
8
8
  pypeline/pipeline_config_schema.py,sha256=DQ_RMucnA0AyrndlW6lkb0orGromcO6C9GgLHyG6lJ0,8013
@@ -12,16 +12,16 @@ pypeline/flask/__init__.py,sha256=AdljRh0lMiS8ExgDmgzObwVs8jW7hqQuf83Ml8kn8GQ,49
12
12
  pypeline/flask/decorators.py,sha256=ki6jkjZwbDbCWuj7ET7N-ncZwrASp4Fy7257WIYiAAQ,1102
13
13
  pypeline/flask/flask_pypeline.py,sha256=Uqyu3PnSP3DoVZUJPqV9chjT4xdRgvcL3OMXxkbdTEg,5490
14
14
  pypeline/flask/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- pypeline/flask/api/pipelines.py,sha256=sPvEoNwmnJPSA96lZHYS2fwKqZlVyE2OSjUmOPFi91o,7267
15
+ pypeline/flask/api/pipelines.py,sha256=RzRmSL5Zaia7ftXmXyDAC0ZAkPoFsvyefzHfIyWhRqk,8118
16
16
  pypeline/flask/api/schedules.py,sha256=31lwoFlGv-S-2ahGUCnD5YbmKws8yddj6_PEzzdBi9s,1321
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
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.7.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
23
- scalable_pypeline-2.0.7.dist-info/METADATA,sha256=5FZyD2MeoKgb1XFTswjO8MTP5RfVuoOXz33mdVHa0dc,6239
24
- scalable_pypeline-2.0.7.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
25
- scalable_pypeline-2.0.7.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
26
- scalable_pypeline-2.0.7.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
27
- scalable_pypeline-2.0.7.dist-info/RECORD,,
22
+ scalable_pypeline-2.0.9.dist-info/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
23
+ scalable_pypeline-2.0.9.dist-info/METADATA,sha256=Kw2kj-CbTmuRdM8FJALTtgfg-JlW-DG87GQ0HLGMzd4,5929
24
+ scalable_pypeline-2.0.9.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
25
+ scalable_pypeline-2.0.9.dist-info/entry_points.txt,sha256=uWs10ODfHSBKo2Cx_QaUjPHQTpZ3e77j9VlAdRRmMyg,119
26
+ scalable_pypeline-2.0.9.dist-info/top_level.txt,sha256=C7dpkEOc_-nnsAQb28BfQknjD6XHRyS9ZrvVeoIbV7s,15
27
+ scalable_pypeline-2.0.9.dist-info/RECORD,,