nci-cidc-api-modules 1.2.42__py3-none-any.whl → 1.2.43__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/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.42"
1
+ __version__ = "1.2.43"
@@ -376,6 +376,10 @@ assay_facets: Facets = {
376
376
  "Channels": FacetConfig(["/maldi_glycan/channels.csv", "Channels csv file for MALDI Glycan run"]),
377
377
  "Tiff Zip": FacetConfig(["/maldi_glycan/tiff.zip", "Tiff zip for MALDI Glycan run"]),
378
378
  },
379
+ "TCRseq RNA": {
380
+ "Alpha Results": FacetConfig(["/tcrseq_rna/alpha.csv"]),
381
+ "Beta Results": FacetConfig(["/tcrseq_rna/beta.csv"]),
382
+ },
379
383
  "mIHC": {
380
384
  "Samples Report": FacetConfig(["/mihc/sample_report.csv"], "Samples report for mIHC run"),
381
385
  "Multitiffs": FacetConfig(["/mihc/multitiffs.tar.gz"], "Multi Tiffs file from mIHC run"),
cidc_api/models/models.py CHANGED
@@ -28,6 +28,7 @@ __all__ = [
28
28
  "JobFileCategories",
29
29
  "CategoryDataElements",
30
30
  "ValidationConfigs",
31
+ "MASTER_APPENDIX_A",
31
32
  "TRIAL_APPENDIX_A",
32
33
  "TRIAL_APPENDIX_A_CELL_THAT_ENDS_THE_HEADER",
33
34
  "REQUEST_LETTER",
@@ -3262,6 +3263,7 @@ def upload_manifest_json(
3262
3263
  return manifest_upload.id
3263
3264
 
3264
3265
 
3266
+ MASTER_APPENDIX_A = "master_appendix_a"
3265
3267
  TRIAL_APPENDIX_A = "trial_appendix_a"
3266
3268
  REQUEST_LETTER = "request_letter"
3267
3269
  DETAILED_VALIDATION = "detailed_validation"
@@ -3361,6 +3363,16 @@ class PreprocessedFiles(CommonColumns):
3361
3363
  query = cls.add_job_filter(query, job_id)
3362
3364
  return query.all()
3363
3365
 
3366
+ @classmethod
3367
+ @with_default_session
3368
+ def get_latest_current_file(
3369
+ cls, file_category: str, job_id: int = None, session: Session = None
3370
+ ) -> Optional["PreprocessedFiles"]:
3371
+ """Return the latest 'current' file for the given category and job_id. Returns None if no file exists."""
3372
+ query = session.query(cls).filter_by(file_category=file_category, status="current")
3373
+ query = cls.add_job_filter(query, job_id)
3374
+ return query.order_by(cls.version.desc()).first()
3375
+
3364
3376
  @classmethod
3365
3377
  @with_default_session
3366
3378
  def get_file_by_category_and_version(
cidc_api/models/types.py CHANGED
@@ -113,6 +113,7 @@ AssayType = Literal[
113
113
  "snRNA-Seq",
114
114
  "Visium",
115
115
  "Olink HT",
116
+ "TCRseq RNA",
116
117
  ]
117
118
 
118
119
 
@@ -17,14 +17,22 @@ logger = get_logger(__name__)
17
17
 
18
18
  @trace_()
19
19
  def set_current_file(
20
- file: FileStorage, file_category: str, gcs_folder: str, session: Session, uploader_email: str, job_id: int = None
20
+ file: FileStorage,
21
+ file_category: str,
22
+ gcs_folder: str,
23
+ session: Session,
24
+ uploader_email: str,
25
+ job_id: int = None,
26
+ append_timestamp: bool = None,
21
27
  ) -> PreprocessedFiles:
22
28
  """
23
29
  Archives any existing 'current' files for the given category and job,
24
30
  then uploads the new file as the latest 'current' version.
25
31
  """
26
32
  latest_version = PreprocessedFiles.archive_current_files(file_category, job_id=job_id, session=session)
27
- latest_file = create_file(file, gcs_folder, file_category, session, uploader_email, job_id, latest_version + 1)
33
+ latest_file = create_file(
34
+ file, gcs_folder, file_category, session, uploader_email, job_id, latest_version + 1, append_timestamp
35
+ )
28
36
  return latest_file
29
37
 
30
38
 
@@ -37,11 +45,12 @@ def create_file(
37
45
  uploader_email: str,
38
46
  job_id: int = None,
39
47
  version: int = None,
48
+ append_timestamp: bool = None,
40
49
  ) -> PreprocessedFiles:
41
50
  """Upload file to GCS and create corresponding metadata record in the database."""
42
51
  status = "pending" if gcs_folder.endswith("pending/") else "current"
43
- # only need timestamp for current/versioned files
44
- append_timestamp = status == "current"
52
+ # only need timestamp for current/versioned files, if not specified otherwise
53
+ append_timestamp = append_timestamp if append_timestamp is not None else (status == "current")
45
54
  # create file in GCS
46
55
  gcs_file_path = upload_file_to_gcs(file, GOOGLE_CLINICAL_DATA_BUCKET, gcs_folder, append_timestamp=append_timestamp)
47
56
  # create corresponding record in db
@@ -907,6 +907,7 @@ def get_signed_url(
907
907
  bucket_name: str = GOOGLE_ACL_DATA_BUCKET,
908
908
  method: str = "GET",
909
909
  expiry_mins: int = 30,
910
+ use_short_filename: bool = False,
910
911
  ) -> str:
911
912
  """
912
913
  Generate a signed URL for `object_name` to give a client temporary access.
@@ -921,7 +922,11 @@ def get_signed_url(
921
922
 
922
923
  # Generate the signed URL, allowing a client to use `method` for `expiry_mins` minutes
923
924
  expiration = datetime.timedelta(minutes=expiry_mins)
924
- full_filename = object_name.replace("/", "_").replace('"', "_").replace(" ", "_")
925
+ if use_short_filename:
926
+ filename = os.path.basename(object_name)
927
+ else:
928
+ # full filename with path included
929
+ filename = object_name.replace("/", "_").replace('"', "_").replace(" ", "_")
925
930
  other_kwargs = {}
926
931
  if os.environ.get("DEV_GOOGLE_STORAGE", None):
927
932
  other_kwargs["api_access_endpoint"] = (os.environ.get("DEV_GOOGLE_STORAGE") or "") + (
@@ -931,7 +936,7 @@ def get_signed_url(
931
936
  version="v2",
932
937
  expiration=expiration,
933
938
  method=method,
934
- response_disposition=f'attachment; filename="{full_filename}"',
939
+ response_disposition=f'attachment; filename="{filename}"',
935
940
  **other_kwargs,
936
941
  )
937
942
  logger.info(f"generated signed URL for {object_name}: {url}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nci_cidc_api_modules
3
- Version: 1.2.42
3
+ Version: 1.2.43
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
@@ -41,7 +41,7 @@ Requires-Dist: opentelemetry-instrumentation-requests>=0.59b0
41
41
  Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.59b0
42
42
  Requires-Dist: opentelemetry-exporter-gcp-trace>=1.11.0
43
43
  Requires-Dist: opentelemetry-propagator-gcp>=1.11.0
44
- Requires-Dist: nci-cidc-schemas==0.28.10
44
+ Requires-Dist: nci-cidc-schemas==0.28.11
45
45
  Dynamic: description
46
46
  Dynamic: description-content-type
47
47
  Dynamic: home-page
@@ -1,4 +1,4 @@
1
- cidc_api/__init__.py,sha256=Ng7mLXI95GEYWOWi3HpHuVabVYSs3igDIcqorkuDZds,23
1
+ cidc_api/__init__.py,sha256=cQdKSyCwNmNJIc8_WJGeQUnEEs6ocLSyIpRm10uJ9OU,23
2
2
  cidc_api/telemetry.py,sha256=LuZWkG8CKCn23O41RTNxEOQwMmfpp-fQ6zSInZhVJg8,3333
3
3
  cidc_api/config/__init__.py,sha256=5mX8GAPxUKV84iS-aGOoE-4m68LsOCGCDptXNdlgvj0,148
4
4
  cidc_api/config/db.py,sha256=mEz8ugjvRNGylCqDYHaaMqaZfDh7sbd76BowmfBvq5c,2428
@@ -8,9 +8,9 @@ cidc_api/config/settings.py,sha256=ttOGvk_6zVMn4dtxIZ2-0w3wF2fpAUVfGpVZbKJ2b6s,4
8
8
  cidc_api/models/__init__.py,sha256=bl445G8Zic9YbhZ8ZBni07wtBMhLJRMBA-JqjLxx2bw,66
9
9
  cidc_api/models/data.py,sha256=mySTpsG4qEBSh5c7dpQZJ2xTxHiYdFYuXO_a_B2gPXE,1313
10
10
  cidc_api/models/migrations.py,sha256=UlS5How3J4ryaRuZT6F5VQtAKikkl0LTv9MgMO_ltiQ,11161
11
- cidc_api/models/models.py,sha256=h8AvXuxXYuekCwPhiEpYbVGG7jHQog3wnWiEXLIaXdY,153111
11
+ cidc_api/models/models.py,sha256=DTt0eFkFVVxVn23Aqr6TA8CQ7qb2hdqQ0xVJ3RakBBw,153684
12
12
  cidc_api/models/schemas.py,sha256=6IE2dJoEMcMbi0Vr1V3cYKnPKU0hv9vRKBixOZHe88s,2766
13
- cidc_api/models/types.py,sha256=Zv9eUs7XUysJa_lzimbl7jSOEhvNozAkgPGGbvMIafo,30040
13
+ cidc_api/models/types.py,sha256=WVOTEH61FH5aGVwRbEcfNOce8NLjiEnl1ixtPWav2OA,30058
14
14
  cidc_api/models/db/stage1/__init__.py,sha256=zsxOSoogzL_xZ8B5OwcwLXvAmm6g2GYx1Zf6LLw8dq8,1917
15
15
  cidc_api/models/db/stage1/additional_treatment_orm.py,sha256=aiimE27oj96sE4F9LwZAlkHNLMwH8dNS5GTYA4DnSIU,968
16
16
  cidc_api/models/db/stage1/adverse_event_orm.py,sha256=dgFdFQliPMzoYa5yf8TlX0XM1tcyu4zfu9Xq8Hbmzwc,1956
@@ -78,7 +78,7 @@ cidc_api/models/db/stage2/treatment_orm.py,sha256=xGgLSzIgoWpNylnCZAWQ2NElHCGKFm
78
78
  cidc_api/models/db/stage2/trial_orm.py,sha256=OPUwv9lm8zLHvQYJ-XPtNqsppwn8IYXAyuyGoYhlpB4,2897
79
79
  cidc_api/models/files/__init__.py,sha256=8BMTnUSHzUbz0lBeEQY6NvApxDD3GMWMduoVMos2g4Y,213
80
80
  cidc_api/models/files/details.py,sha256=sZkGM7iEV4-J6IDQCdiMV6KBDLbPxCOqUMaU3aY9rX8,65153
81
- cidc_api/models/files/facets.py,sha256=rG99wUpHvWHkcRDxTcXz40502Er47l_5hKzP-ORvXGE,33621
81
+ cidc_api/models/files/facets.py,sha256=vieZ3z_tYB29NqtvNzvKqajVwxM5ZLLZKeyQTq5lheU,33776
82
82
  cidc_api/models/pydantic/base.py,sha256=6Lsf4fekIS1E-DwZmgCXlfm3Qq9_23dA_v3iz1w2JoA,1427
83
83
  cidc_api/models/pydantic/stage1/__init__.py,sha256=H-NDjCd8isHTgZ7sqz-MIbzC-PpW1kEtR-x-Dyc8r6Q,1667
84
84
  cidc_api/models/pydantic/stage1/additional_treatment.py,sha256=TFVzjd1NPLSfH9UnL2W3aZhpZSzDsg97j9IK8t882YA,1050
@@ -153,13 +153,13 @@ cidc_api/shared/assay_handling.py,sha256=zzWSqQ-ddLVzX5IuHvsaSib2H1lnjXpo9Lbxaoq
153
153
  cidc_api/shared/auth.py,sha256=EIP9AKokLNrI79Fkpv3P7WdzaddJIsuGGICc1W494X0,9110
154
154
  cidc_api/shared/email_layout.html,sha256=pBoTNw3ACHH-ncZFaNvcy5bXMqPwizR78usb0uCYtIc,7670
155
155
  cidc_api/shared/emails.py,sha256=8kNFEaSnKpY-GX_iE59QUhSp3c4_uzy3SpHYt2QjuqI,6121
156
- cidc_api/shared/file_handling.py,sha256=ahzVZnhg23DloaopKVvCzgw_vHc6c8vxxZdAKR38sjI,5636
157
- cidc_api/shared/gcloud_client.py,sha256=l40qQ0lo2QQkWfarXlApmI7iPeYzYoEEXBvemyizYnc,38421
156
+ cidc_api/shared/file_handling.py,sha256=ObsLvBrkwHo6Nv48GvFXDKElNNl4inGpxv--001H_xc,5843
157
+ cidc_api/shared/gcloud_client.py,sha256=flRIot4wt__JOkn_DP6XE8YW--t-30K7P8TMgB0UGUs,38582
158
158
  cidc_api/shared/jose.py,sha256=-qzGzEDAlokEp9E7WtBtQkXyyfPWTYXlwYpCqVJWmqM,1830
159
159
  cidc_api/shared/rest_utils.py,sha256=RwR30WOUAYCxL7V-i2totEyeriG30GbBDvBcpLXhM9w,6594
160
160
  cidc_api/shared/utils.py,sha256=-gLnzxCR9E6h0plt2xrNisUG5_Y6GhhVwz3DgDIzpvs,367
161
- nci_cidc_api_modules-1.2.42.dist-info/licenses/LICENSE,sha256=pNYWVTHaYonnmJyplmeAp7tQAjosmDpAWjb34jjv7Xs,1102
162
- nci_cidc_api_modules-1.2.42.dist-info/METADATA,sha256=SroeJFGQ9eCHO-1d02bhZXpVul_6QIYn1t7s_Df4ySI,40229
163
- nci_cidc_api_modules-1.2.42.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
- nci_cidc_api_modules-1.2.42.dist-info/top_level.txt,sha256=rNiRzL0lJGi5Q9tY9uSoMdTbJ-7u5c_D2E86KA94yRA,9
165
- nci_cidc_api_modules-1.2.42.dist-info/RECORD,,
161
+ nci_cidc_api_modules-1.2.43.dist-info/licenses/LICENSE,sha256=pNYWVTHaYonnmJyplmeAp7tQAjosmDpAWjb34jjv7Xs,1102
162
+ nci_cidc_api_modules-1.2.43.dist-info/METADATA,sha256=oSYq0wyk9VSMtXGmLql3apEZK2Fw4X8_gHbblXdSM4g,40229
163
+ nci_cidc_api_modules-1.2.43.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
+ nci_cidc_api_modules-1.2.43.dist-info/top_level.txt,sha256=rNiRzL0lJGi5Q9tY9uSoMdTbJ-7u5c_D2E86KA94yRA,9
165
+ nci_cidc_api_modules-1.2.43.dist-info/RECORD,,