Skip to content

Commit 1a0e89d

Browse files
authored
fix: Use Jobs api for book-keeping task. (#739)
* Add call to jobs api. * Added Ingestion URL. * Updated utils and worker and used utils functionality for bookkeeping. * Rebased. * Address review comment. * Added try except block on trigger_workflow.
1 parent c07d525 commit 1a0e89d

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

bayesian/utils.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from f8a_worker.setup_celery import init_celery
2020
from .default_config import STACK_ANALYSIS_REQUEST_TIMEOUT
2121
from sqlalchemy.exc import SQLAlchemyError
22+
from f8a_utils.ingestion_utils import trigger_workerflow
2223

2324
logger = logging.getLogger(__name__)
2425

@@ -65,20 +66,26 @@ def get_user_email(user_profile):
6566

6667
def create_component_bookkeeping(ecosystem, packages_list, request_args, headers):
6768
"""Run the component analysis for given ecosystem+package+version."""
68-
args = {
69-
'external_request_id': headers.get('X-Request-Id', None),
70-
'data': {
71-
'api_name': 'component_analyses_post',
72-
'manifest_hash': request_args.get('utm_content', None),
73-
'ecosystem': ecosystem,
74-
'packages_list': packages_list,
75-
'user_id': headers.get('uuid', None),
76-
'user_agent': headers.get('User-Agent', None),
77-
'source': request_args.get('utm_source', None),
78-
'telemetry_id': headers.get('X-Telemetry-Id', None)
69+
payload = {
70+
"external_request_id": headers.get('X-Request-Id', None),
71+
"flowname": "componentApiFlow",
72+
"data": {
73+
"api_name": "component_analyses_post",
74+
"manifest_hash": request_args.get('utm_content', None),
75+
"ecosystem": ecosystem,
76+
"packages_list": packages_list,
77+
"user_id": headers.get('uuid', None),
78+
"user_agent": headers.get('User-Agent', None),
79+
"source": request_args.get('utm_source', None),
80+
"telemetry_id": headers.get('X-Telemetry-Id', None)
7981
}
8082
}
81-
return server_run_flow('componentApiFlow', args)
83+
84+
try:
85+
trigger_workerflow(payload)
86+
except Exception as e:
87+
logger.error('Failed to trigger worker flow for payload %s with error %s',
88+
payload, e)
8289

8390

8491
def server_create_analysis(ecosystem, package, version, user_profile,

requirements.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ gevent
2424
#packages discovered after running the image on cluster
2525
psycopg2-binary
2626

27-
f8a_worker @ git+https://github.com/fabric8-analytics/fabric8-analytics-worker.git@af1680a#egg=f8a_worker
27+
f8a_worker @ git+https://github.com/fabric8-analytics/fabric8-analytics-worker.git@c74145b#egg=f8a_worker
2828
f8a_auth @ git+https://github.com/fabric8-analytics/fabric8-analytics-auth.git@5ff9438#egg=fabric8a_auth
29-
f8a_utils @ git+https://github.com/fabric8-analytics/fabric8-analytics-utils.git@839e022#egg=f8a_utils
3029
f8a_version_comparator @ git+https://github.com/fabric8-analytics/fabric8-analytics-version-comparator.git@8a57ac7#egg=f8a_version_comparator
30+
f8a_utils @ git+https://github.com/fabric8-analytics/fabric8-analytics-utils.git@f4fef58#egg=f8a_utils

requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ dataclasses==0.8
6464
# via pydantic
6565
deprecated==1.2.11
6666
# via pygithub
67-
git+https://github.com/fabric8-analytics/fabric8-analytics-utils.git@839e022#egg=f8a_utils
67+
git+https://github.com/fabric8-analytics/fabric8-analytics-utils.git@f4fef58#egg=f8a_utils
6868
# via
6969
# -r requirements.in
7070
# f8a-worker
7171
git+https://github.com/fabric8-analytics/fabric8-analytics-version-comparator.git@8a57ac7#egg=f8a_version_comparator
7272
# via
7373
# -r requirements.in
7474
# f8a-utils
75-
git+https://github.com/fabric8-analytics/fabric8-analytics-worker.git@af1680a#egg=f8a_worker
75+
git+https://github.com/fabric8-analytics/fabric8-analytics-worker.git@c74145b#egg=f8a_worker
7676
# via -r requirements.in
7777
git+https://github.com/fabric8-analytics/fabric8-analytics-auth.git@5ff9438#egg=fabric8a_auth
7878
# via -r requirements.in
@@ -234,7 +234,6 @@ six==1.15.0
234234
# via
235235
# anymarkup-core
236236
# configobj
237-
# cryptography
238237
# flask-appconfig
239238
# flask-cors
240239
# flask-restful

0 commit comments

Comments
 (0)