nci-cidc-api-modules 1.2.35__py3-none-any.whl → 1.2.36__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.
cidc_api/models/models.py CHANGED
@@ -35,7 +35,8 @@ __all__ = [
35
35
  "ADMIN_FILE_CATEGORIES",
36
36
  "FINAL_JOB_STATUS",
37
37
  "INGESTION_JOB_STATUSES",
38
- "INGESTION_JOB_COLORS",
38
+ "ASSAY_JOB_COLORS",
39
+ "CLINICAL_JOB_COLORS",
39
40
  ]
40
41
 
41
42
  import hashlib
@@ -3436,7 +3437,7 @@ INGESTION_JOB_STATUSES = [
3436
3437
  ]
3437
3438
 
3438
3439
  # Business decision to pass hex codes from the backend though that should be done by the front end...
3439
- INGESTION_JOB_COLORS = {
3440
+ CLINICAL_JOB_COLORS = {
3440
3441
  "DRAFT": "",
3441
3442
  "INITIAL SUBMISSION": "#ACCAD7",
3442
3443
  "VALIDATION REVIEW": "#DABE90",
@@ -3444,6 +3445,13 @@ INGESTION_JOB_COLORS = {
3444
3445
  "INGESTION": "#8FCEC7",
3445
3446
  "PUBLISHED": "#90D9E6",
3446
3447
  }
3448
+ ASSAY_JOB_COLORS = {
3449
+ "INITIAL SUBMISSION": "#43807E",
3450
+ "VALIDATION REVIEW": "#906F3F",
3451
+ "REVISION SUBMISSION": "#95358A",
3452
+ "INGESTION": "#542C88",
3453
+ "PUBLISHED": "#1C81A0",
3454
+ }
3447
3455
  # TODO If have "CANCELLED" concept or other final status, add here
3448
3456
  FINAL_JOB_STATUS = ["PUBLISHED"]
3449
3457
  TRIAL_APPENDIX_A_CELL_THAT_ENDS_THE_HEADER = "Data Category"
@@ -53,7 +53,7 @@ def prepare_assay_job(trial_id: str, assay_type: str, batch_id: str) -> tuple[st
53
53
 
54
54
  # Create or retrieve intake bucket corresponding to the trial
55
55
  intake_bucket = gcloud_client.create_intake_bucket(get_current_user().email, trial_id=trial_id)
56
- gcs_path = f"{intake_bucket.name}/{trial_id}/{assay_type}"
56
+ gcs_path = f"{intake_bucket.name}/{assay_type}/{submission_id}"
57
57
 
58
58
  return submission_id, job_status, error_status, start_date, version, gcs_path
59
59
 
cidc_api/shared/auth.py CHANGED
@@ -1,16 +1,14 @@
1
1
  from functools import wraps
2
2
  from typing import List
3
3
 
4
- from packaging import version
5
-
6
4
  from flask import g, request, current_app as app, Flask
5
+ from packaging import version
7
6
  from werkzeug.exceptions import Unauthorized, BadRequest, PreconditionFailed
8
7
 
9
- from ..models import Users, UserSchema
10
-
11
8
  from ..config.logging import get_logger
12
-
9
+ from ..models import Users, UserSchema
13
10
  from ..shared.jose import decode_id_token
11
+ from ..telemetry import trace_
14
12
 
15
13
  logger = get_logger(__name__)
16
14
 
@@ -144,6 +142,7 @@ def get_current_user() -> Users:
144
142
  _user_schema = UserSchema()
145
143
 
146
144
 
145
+ @trace_()
147
146
  def authenticate() -> Users:
148
147
  id_token = _extract_token()
149
148
  token_payload = decode_id_token(id_token)
@@ -172,6 +171,7 @@ def _extract_token() -> str:
172
171
 
173
172
 
174
173
  ### Authorization logic ###
174
+ @trace_()
175
175
  def authorize(user: Users, allowed_roles: List[str], resource: str, method: str) -> bool:
176
176
  """Check if the current user is authorized to act on the current request's resource.
177
177
  Raises Unauthorized
@@ -10,10 +10,12 @@ from ..config.settings import GOOGLE_CLINICAL_DATA_BUCKET
10
10
  from ..models import PreprocessedFiles, TRIAL_APPENDIX_A_CELL_THAT_ENDS_THE_HEADER
11
11
  from ..shared.auth import get_current_user
12
12
  from ..shared.gcloud_client import upload_file_to_gcs, move_gcs_file
13
+ from ..telemetry import trace_
13
14
 
14
15
  logger = get_logger(__name__)
15
16
 
16
17
 
18
+ @trace_()
17
19
  def set_current_file(
18
20
  file: FileStorage, file_category: str, gcs_folder: str, session: Session, uploader_email: str, job_id: int = None
19
21
  ) -> PreprocessedFiles:
@@ -26,6 +28,7 @@ def set_current_file(
26
28
  return latest_file
27
29
 
28
30
 
31
+ @trace_()
29
32
  def create_file(
30
33
  file: FileStorage,
31
34
  gcs_folder: str,
@@ -1,6 +1,6 @@
1
1
  """Utilities for interacting with the Google Cloud Platform APIs."""
2
2
 
3
- # pylint: disable=logging-fstring-interpolation,too-many-lines
3
+ # pylint: disable=logging-fstring-interpolation,too-many-lines, broad-exception-raised
4
4
 
5
5
  import base64
6
6
  import datetime
@@ -634,6 +634,7 @@ def _build_trial_upload_prefixes(
634
634
  trial_set: Set[str] = set()
635
635
  upload_set: Set[str] = set()
636
636
  if not trial_id:
637
+ # import is here becasue of circular import
637
638
  from ..models.models import TrialMetadata
638
639
 
639
640
  trial_set = {str(t.trial_id) for t in session.query(TrialMetadata).add_columns(TrialMetadata.trial_id)}
@@ -940,7 +941,8 @@ def get_signed_url(
940
941
 
941
942
  def _encode_and_publish(content: str, topic: str) -> Future:
942
943
  """Convert `content` to bytes and publish it to `topic`."""
943
- pubsub_publisher = pubsub.PublisherClient()
944
+ publisher_options = pubsub.types.PublisherOptions(enable_open_telemetry_tracing=ENV == "dev-int")
945
+ pubsub_publisher = pubsub.PublisherClient(publisher_options=publisher_options)
944
946
  topic = pubsub_publisher.topic_path(GOOGLE_CLOUD_PROJECT, topic)
945
947
  data = bytes(content, "utf-8")
946
948
 
cidc_api/shared/utils.py CHANGED
@@ -1,11 +1,19 @@
1
- def strip_whitespaces(df):
2
- def stripper(x):
3
- if x and isinstance(x, str):
4
- return x.strip()
5
- else:
6
- return x
7
-
8
- df.rename(columns=stripper, inplace=True)
9
- df = df.map(stripper)
1
+ from cidc_api.telemetry import trace_
2
+
3
+
4
+ def _stripper(x):
5
+ if x and isinstance(x, str):
6
+ return x.strip()
7
+ else:
8
+ return x
9
+
10
+
11
+ @trace_("sheet")
12
+ def strip_whitespaces(df, sheet=None):
13
+ if sheet:
14
+ df = df[sheet]
15
+
16
+ df.rename(columns=_stripper, inplace=True)
17
+ df = df.map(_stripper)
10
18
 
11
19
  return df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nci_cidc_api_modules
3
- Version: 1.2.35
3
+ Version: 1.2.36
4
4
  Summary: SQLAlchemy data models and configuration tools used in the NCI CIDC API
5
5
  Home-page: https://github.com/NCI-CIDC/cidc-api-gae
6
6
  License: MIT license
@@ -33,6 +33,14 @@ Requires-Dist: requests>=2.32.5
33
33
  Requires-Dist: sqlalchemy>=2.0.44
34
34
  Requires-Dist: sqlalchemy-mixins~=2.0.5
35
35
  Requires-Dist: werkzeug>=3.1.4
36
+ Requires-Dist: opentelemetry-api>=1.38.0
37
+ Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.38.0
38
+ Requires-Dist: opentelemetry-sdk>=1.38.0
39
+ Requires-Dist: opentelemetry-instrumentation-flask>=0.59b0
40
+ Requires-Dist: opentelemetry-instrumentation-requests>=0.59b0
41
+ Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.59b0
42
+ Requires-Dist: opentelemetry-exporter-gcp-trace>=1.11.0
43
+ Requires-Dist: opentelemetry-propagator-gcp>=1.11.0
36
44
  Requires-Dist: nci-cidc-schemas==0.28.10
37
45
  Dynamic: description
38
46
  Dynamic: description-content-type
@@ -6,7 +6,7 @@ cidc_api/config/settings.py,sha256=ttOGvk_6zVMn4dtxIZ2-0w3wF2fpAUVfGpVZbKJ2b6s,4
6
6
  cidc_api/models/__init__.py,sha256=cTyK0Z1ttLo9itwZVRFr-d6aX-zX633YhqipqPgoGfE,115
7
7
  cidc_api/models/data.py,sha256=uLkgAJ6tCtsi3bOGt8I9esYrZqgbsTYM1rGfL2gx5sY,837
8
8
  cidc_api/models/migrations.py,sha256=UlS5How3J4ryaRuZT6F5VQtAKikkl0LTv9MgMO_ltiQ,11161
9
- cidc_api/models/models.py,sha256=HFy3_CheDe_tfVCQkC88BMdi9C27tnd_H-MGvYqUv44,152709
9
+ cidc_api/models/models.py,sha256=QLVxftl9vEgHEPA5au0lh2usTTsh5lI8vWjuS2Twxdk,152921
10
10
  cidc_api/models/schemas.py,sha256=6IE2dJoEMcMbi0Vr1V3cYKnPKU0hv9vRKBixOZHe88s,2766
11
11
  cidc_api/models/types.py,sha256=nq_PvzDz67HzceOI_ve9AxReExAZ-XFE7T3G2bbpqJ4,29667
12
12
  cidc_api/models/db/base_orm.py,sha256=EV78qFBcOR7spK_PhjbkpsGcmcP33AQItX61SidDa_8,813
@@ -94,17 +94,17 @@ cidc_api/reference/icd10cm.py,sha256=K1vbTQB75uAQeKgj0U9izhtMKVb2vqp69_hyx3z_jro
94
94
  cidc_api/reference/icdo3.py,sha256=A19yNX5-9Gs3X83kXcTlGgsXDTTJ9yR2dxEIoBVmpmU,296
95
95
  cidc_api/reference/uberon.py,sha256=BO2mYNDvPzZyLdhL_ZjCyEgHSLHuVifnTJvfktUfVWA,148
96
96
  cidc_api/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
- cidc_api/shared/assay_handling.py,sha256=kjxPGt4Dw-EkHGHfce32EXAPvWoPfPNFQCTso4Z0ez4,2892
98
- cidc_api/shared/auth.py,sha256=PHqmVGkqDjbmUofytVFwD_9ssgUomESl3fFtFHPwZYQ,9062
97
+ cidc_api/shared/assay_handling.py,sha256=zzWSqQ-ddLVzX5IuHvsaSib2H1lnjXpo9LbxaoqaHHs,2897
98
+ cidc_api/shared/auth.py,sha256=EIP9AKokLNrI79Fkpv3P7WdzaddJIsuGGICc1W494X0,9110
99
99
  cidc_api/shared/email_layout.html,sha256=pBoTNw3ACHH-ncZFaNvcy5bXMqPwizR78usb0uCYtIc,7670
100
100
  cidc_api/shared/emails.py,sha256=8kNFEaSnKpY-GX_iE59QUhSp3c4_uzy3SpHYt2QjuqI,6121
101
- cidc_api/shared/file_handling.py,sha256=UP3KZ61Km5RNmNfk126_upKv-jGkDzpc5Pvk1s7cU2Q,5585
102
- cidc_api/shared/gcloud_client.py,sha256=SI8fcKAavLlIsU_5XMKe4ebjYkl-qantX07zihsgkaU,38140
101
+ cidc_api/shared/file_handling.py,sha256=ahzVZnhg23DloaopKVvCzgw_vHc6c8vxxZdAKR38sjI,5636
102
+ cidc_api/shared/gcloud_client.py,sha256=fDNgRpU7jAeDtYfY-Zz09KE-__jHo6v0J7fI3eLgyhM,38353
103
103
  cidc_api/shared/jose.py,sha256=-qzGzEDAlokEp9E7WtBtQkXyyfPWTYXlwYpCqVJWmqM,1830
104
104
  cidc_api/shared/rest_utils.py,sha256=RwR30WOUAYCxL7V-i2totEyeriG30GbBDvBcpLXhM9w,6594
105
- cidc_api/shared/utils.py,sha256=FdZJiynmh6BIzWyCTcUAcUMKCAtzEyp_HLdXEticNcI,237
106
- nci_cidc_api_modules-1.2.35.dist-info/licenses/LICENSE,sha256=pNYWVTHaYonnmJyplmeAp7tQAjosmDpAWjb34jjv7Xs,1102
107
- nci_cidc_api_modules-1.2.35.dist-info/METADATA,sha256=r7t33YqkP9xxzOGvJ_9auttusdTNOU3gdsre1qpl7t4,39792
108
- nci_cidc_api_modules-1.2.35.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
109
- nci_cidc_api_modules-1.2.35.dist-info/top_level.txt,sha256=rNiRzL0lJGi5Q9tY9uSoMdTbJ-7u5c_D2E86KA94yRA,9
110
- nci_cidc_api_modules-1.2.35.dist-info/RECORD,,
105
+ cidc_api/shared/utils.py,sha256=Po14K_7cvMKI9zJVzS0YDP1IqDBQS5Mvs6UMvS0RT4g,328
106
+ nci_cidc_api_modules-1.2.36.dist-info/licenses/LICENSE,sha256=pNYWVTHaYonnmJyplmeAp7tQAjosmDpAWjb34jjv7Xs,1102
107
+ nci_cidc_api_modules-1.2.36.dist-info/METADATA,sha256=94lsTOKAtCJgZoANklikdDqfp-R7UQoU2qCOobI2sHI,40229
108
+ nci_cidc_api_modules-1.2.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
109
+ nci_cidc_api_modules-1.2.36.dist-info/top_level.txt,sha256=rNiRzL0lJGi5Q9tY9uSoMdTbJ-7u5c_D2E86KA94yRA,9
110
+ nci_cidc_api_modules-1.2.36.dist-info/RECORD,,