nci-cidc-api-modules 1.1.31__py3-none-any.whl → 1.1.32__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
@@ -3229,12 +3229,15 @@ class PreprocessedFiles(CommonColumns):
3229
3229
  @classmethod
3230
3230
  @with_default_session
3231
3231
  def archive_current_files(cls, file_category: str, session: Session = None):
3232
- """Update any 'current' files in the given category to 'archived'."""
3232
+ """Update any 'current' files in the given category to 'archived'. Returns latest existing version number."""
3233
+ current_version = 0
3233
3234
  current_files = cls.get_files_by_category_and_status(file_category, "current", session=session)
3234
3235
  for file in current_files:
3235
3236
  file.status = "archived"
3236
3237
  file._updated = datetime.now()
3238
+ current_version = file.version if file.version > current_version else current_version
3237
3239
  session.commit()
3240
+ return current_version
3238
3241
 
3239
3242
  @classmethod
3240
3243
  @with_default_session
@@ -237,7 +237,6 @@ def upload_file_to_gcs(file: FileStorage, bucket_name: str, gcs_folder: str) ->
237
237
 
238
238
  def move_gcs_file(bucket_name: str, existing_path: str, to_folder: str, append_timestamp: bool = True) -> str:
239
239
  """Move a file within a GCS bucket to a new folder, optionally appending a timestamp to the filename."""
240
- bucket = _get_bucket(bucket_name)
241
240
  filename = os.path.basename(existing_path)
242
241
  if append_timestamp:
243
242
  filename = _append_iso_timestamp_to_filename(filename)
@@ -250,6 +249,7 @@ def move_gcs_file(bucket_name: str, existing_path: str, to_folder: str, append_t
250
249
  logger.info(f"Would've moved {existing_path} to {new_gcs_file_path} in {bucket_name}")
251
250
  return new_gcs_file_path
252
251
 
252
+ bucket = _get_bucket(bucket_name)
253
253
  source_blob = bucket.blob(existing_path)
254
254
  if not source_blob.exists():
255
255
  raise Exception("Expected file not found in GCS")
@@ -263,10 +263,10 @@ def move_gcs_file(bucket_name: str, existing_path: str, to_folder: str, append_t
263
263
 
264
264
  def delete_items_from_folder(bucket_name: str, folder: str):
265
265
  """Deletes all blobs from the specified folder in the specified bucket."""
266
- bucket = _get_bucket(bucket_name)
267
266
  if ENV == "dev" and not DEV_USE_GCS:
268
267
  logger.info(f"Would've deleted file(s) from {folder} in {bucket_name}")
269
268
  return
269
+ bucket = _get_bucket(bucket_name)
270
270
  existing_blobs = bucket.list_blobs(prefix=folder)
271
271
  for blob in existing_blobs:
272
272
  blob.delete()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nci_cidc_api_modules
3
- Version: 1.1.31
3
+ Version: 1.1.32
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
@@ -25,10 +25,10 @@ Requires-Dist: pyarrow==14.0.1
25
25
  Requires-Dist: numpy<2,>=1.16.5
26
26
  Requires-Dist: pandas==1.5.3
27
27
  Requires-Dist: python-dotenv==0.10.3
28
- Requires-Dist: requests==2.32.3
28
+ Requires-Dist: requests==2.32.4
29
29
  Requires-Dist: jinja2==3.1.6
30
30
  Requires-Dist: certifi==2024.7.4
31
- Requires-Dist: nci-cidc-schemas==0.27.21
31
+ Requires-Dist: nci-cidc-schemas==0.27.22
32
32
  Dynamic: description
33
33
  Dynamic: description-content-type
34
34
  Dynamic: home-page
@@ -5,7 +5,7 @@ cidc_api/config/secrets.py,sha256=jRFj7W43pWuPf9DZQLCKF7WPXf5cUv-BAaS3ASqhV_Q,14
5
5
  cidc_api/config/settings.py,sha256=mA-4r7oB60uFepYtl5abbPigjwX8aBz__qCJXdcWWbs,4272
6
6
  cidc_api/models/__init__.py,sha256=bl445G8Zic9YbhZ8ZBni07wtBMhLJRMBA-JqjLxx2bw,66
7
7
  cidc_api/models/migrations.py,sha256=gp9vtkYbA9FFy2s-7woelAmsvQbJ41LO2_DY-YkFIrQ,11464
8
- cidc_api/models/models.py,sha256=JAvKhX2VnbhavfPkGelBIa3M8Qi6JaFKvydJmmvqZ1U,131795
8
+ cidc_api/models/models.py,sha256=WU9nCAyYJEi1_TWyjSCrJ8XX1btPNa2xO7tpDWGccdU,131992
9
9
  cidc_api/models/schemas.py,sha256=7tDYtmULuzTt2kg7RorWhte06ffalgpQKrFiDRGcPEQ,2711
10
10
  cidc_api/models/files/__init__.py,sha256=8BMTnUSHzUbz0lBeEQY6NvApxDD3GMWMduoVMos2g4Y,213
11
11
  cidc_api/models/files/details.py,sha256=WrWPxJqlsteinoNbGTaQ3fcxgvChqLGJ9vY7H829jtk,62842
@@ -13,11 +13,11 @@ cidc_api/models/files/facets.py,sha256=JqCmwcjYYSz7XK4bAokSE9i71C8t9EQ4Jtbv7npth
13
13
  cidc_api/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  cidc_api/shared/auth.py,sha256=PHqmVGkqDjbmUofytVFwD_9ssgUomESl3fFtFHPwZYQ,9062
15
15
  cidc_api/shared/emails.py,sha256=GY-l0EkoVU_3hjV0g-xo7N9d1iyCdluyq_arftEPPe0,4989
16
- cidc_api/shared/gcloud_client.py,sha256=ko-3kGRyHI0RcIgoA0r_qVZUcDUGjd9t6-5pXJc3A7s,35634
16
+ cidc_api/shared/gcloud_client.py,sha256=oD7Y3Glp1ZrPYkonv7DvX1koGtF30lgm3ENXYQ7G5cI,35634
17
17
  cidc_api/shared/jose.py,sha256=-qzGzEDAlokEp9E7WtBtQkXyyfPWTYXlwYpCqVJWmqM,1830
18
18
  cidc_api/shared/rest_utils.py,sha256=RwR30WOUAYCxL7V-i2totEyeriG30GbBDvBcpLXhM9w,6594
19
- nci_cidc_api_modules-1.1.31.dist-info/licenses/LICENSE,sha256=pNYWVTHaYonnmJyplmeAp7tQAjosmDpAWjb34jjv7Xs,1102
20
- nci_cidc_api_modules-1.1.31.dist-info/METADATA,sha256=92LzhqUCRQiUvKbuj0Gs_lZ3OrmPBzBHfrNZQ_EjrwQ,41285
21
- nci_cidc_api_modules-1.1.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- nci_cidc_api_modules-1.1.31.dist-info/top_level.txt,sha256=rNiRzL0lJGi5Q9tY9uSoMdTbJ-7u5c_D2E86KA94yRA,9
23
- nci_cidc_api_modules-1.1.31.dist-info/RECORD,,
19
+ nci_cidc_api_modules-1.1.32.dist-info/licenses/LICENSE,sha256=pNYWVTHaYonnmJyplmeAp7tQAjosmDpAWjb34jjv7Xs,1102
20
+ nci_cidc_api_modules-1.1.32.dist-info/METADATA,sha256=K5SKeS-yZim2JWbhfsbrFo7G2vSegE4uYk5xy3lgtIA,41285
21
+ nci_cidc_api_modules-1.1.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ nci_cidc_api_modules-1.1.32.dist-info/top_level.txt,sha256=rNiRzL0lJGi5Q9tY9uSoMdTbJ-7u5c_D2E86KA94yRA,9
23
+ nci_cidc_api_modules-1.1.32.dist-info/RECORD,,