dcicutils 8.15.0__py3-none-any.whl → 8.16.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
dcicutils/misc_utils.py CHANGED
@@ -2802,7 +2802,7 @@ def format_duration(seconds: Union[int, float]) -> str:
2802
2802
  durations = [("year", 31536000), ("day", 86400), ("hour", 3600), ("minute", 60), ("second", 1)]
2803
2803
  parts = []
2804
2804
  for name, duration in durations:
2805
- if seconds >= duration:
2805
+ if (seconds == 0) or (seconds >= duration):
2806
2806
  count = seconds // duration
2807
2807
  seconds %= duration
2808
2808
  if count != 1:
dcicutils/portal_utils.py CHANGED
@@ -294,6 +294,12 @@ class Portal:
294
294
  def get_health(self) -> OptionalResponse:
295
295
  return self.get("/health")
296
296
 
297
+ def get_version(self) -> Optional[str]:
298
+ try:
299
+ return self.get_health().json()["project_version"]
300
+ except Exception:
301
+ return None
302
+
297
303
  def ping(self) -> bool:
298
304
  try:
299
305
  return self.get_health().status_code == 200
@@ -360,7 +360,12 @@ def _get_portal_object(portal: Portal, uuid: str,
360
360
  path = f"/{uuid}"
361
361
  else:
362
362
  path = uuid
363
- response = portal.get(path, raw=raw or inserts, database=database)
363
+ if (response := portal.get(path, raw=raw or inserts, database=database)) is not None:
364
+ if response.status_code == 403:
365
+ _exit(f"Permission error getting Portal object from {portal.server}: {uuid}")
366
+ elif response.status_code == 404:
367
+ _exit(f"Not found Portal object from {portal.server}: {uuid}")
368
+
364
369
  except Exception as e:
365
370
  if "404" in str(e) and "not found" in str(e).lower():
366
371
  _print(f"Portal object not found at {portal.server}: {uuid}")
@@ -318,7 +318,7 @@ class StructuredDataSet:
318
318
  order = {Schema.type_name(key): index for index, key in enumerate(self._order)} if self._order else {}
319
319
  for sheet_name in sorted(excel.sheet_names, key=lambda key: order.get(Schema.type_name(key), sys.maxsize)):
320
320
  self._load_reader(excel.sheet_reader(sheet_name), type_name=Schema.type_name(sheet_name))
321
- if self._validator_sheet_hook:
321
+ if self._validator_sheet_hook and self.data.get(sheet_name):
322
322
  self._validator_sheet_hook(self, sheet_name, self.data[sheet_name])
323
323
  # TODO: Do we really need progress reporting for the below?
324
324
  # Check for unresolved reference errors which really are not because of ordering.
@@ -388,13 +388,7 @@ class StructuredDataSet:
388
388
  structured_row = structured_row_template.create_row()
389
389
  for column_name, value in row.items():
390
390
  if self._validator_hook:
391
- value, validator_error = (
392
- self._validator_hook(self, type_name, column_name, reader.row_number, value))
393
- if validator_error:
394
- self._note_error({
395
- "src": create_dict(type=schema_name, row=reader.row_number),
396
- "error": validator_error
397
- }, "validation")
391
+ value = self._validator_hook(self, type_name, column_name, reader.row_number, value)
398
392
  structured_row_template.set_value(structured_row, column_name, value, reader.file, reader.row_number)
399
393
  if self._autoadd_properties:
400
394
  self._add_properties(structured_row, self._autoadd_properties, schema)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.15.0
3
+ Version: 8.16.0
4
4
  Summary: Utility package for interacting with the 4DN Data Portal and other 4DN resources
5
5
  Home-page: https://github.com/4dn-dcic/utils
6
6
  License: MIT
@@ -45,11 +45,11 @@ dcicutils/license_policies/park-lab-gpl-pipeline.jsonc,sha256=vLZkwm3Js-kjV44nug
45
45
  dcicutils/license_policies/park-lab-pipeline.jsonc,sha256=9qlY0ASy3iUMQlr3gorVcXrSfRHnVGbLhkS427UaRy4,283
46
46
  dcicutils/license_utils.py,sha256=2Yxnh1T1iuMe6wluwbvpFO_zYSGPxB4-STAMc-vz-YM,47202
47
47
  dcicutils/log_utils.py,sha256=7pWMc6vyrorUZQf-V-M3YC6zrPgNhuV_fzm9xqTPph0,10883
48
- dcicutils/misc_utils.py,sha256=mO-5i0IUZ2U-P7rnQcC9VURzQ35pz7jFsMZdq6BB_QM,115929
48
+ dcicutils/misc_utils.py,sha256=xNQtavXS6vw_x9rQNhZEryo9b19oWYg-A8TzjhVDuxg,115949
49
49
  dcicutils/obfuscation_utils.py,sha256=fo2jOmDRC6xWpYX49u80bVNisqRRoPskFNX3ymFAmjw,5963
50
50
  dcicutils/opensearch_utils.py,sha256=V2exmFYW8Xl2_pGFixF4I2Cc549Opwe4PhFi5twC0M8,1017
51
51
  dcicutils/portal_object_utils.py,sha256=Az3n1aL-PQkN5gOFE6ZqC2XkYsqiwKlq7-tZggs1QN4,11062
52
- dcicutils/portal_utils.py,sha256=Ub4rlG6Ir4JVSH1KHQRRtJTU_5yBGzVOKrdIkhqJMLQ,45268
52
+ dcicutils/portal_utils.py,sha256=4mHNdMcaQDUVPfiDYwGeIqjerNuDRnNloUDIZl41r9g,45439
53
53
  dcicutils/progress_bar.py,sha256=R3bWLMYM3Xq9PY7U0JadcFT1m7QmCbrbDp9qs9_Kf_c,19472
54
54
  dcicutils/project_utils.py,sha256=qPdCaFmWUVBJw4rw342iUytwdQC0P-XKpK4mhyIulMM,31250
55
55
  dcicutils/qa_checkers.py,sha256=j0kzo_T5VduKTxgsMTp7xjneyNokumZzI_iz55Y0Jjs,20505
@@ -61,12 +61,12 @@ dcicutils/schema_utils.py,sha256=GmRm-XqZKJ6qine16SQF1txcby9WougDav_sYmKNs9E,124
61
61
  dcicutils/scripts/publish_to_pypi.py,sha256=sMd4WASQGlxlh7uLrt2eGkFRXYgONVmvIg8mClMS5RQ,13903
62
62
  dcicutils/scripts/run_license_checker.py,sha256=z2keYnRDZsHQbTeo1XORAXSXNJK5axVzL5LjiNqZ7jE,4184
63
63
  dcicutils/scripts/update_portal_object.py,sha256=BwZw1cZx2zhzp1ivn_DXUxfnmUyC5A9fAotjHV0fXf4,41875
64
- dcicutils/scripts/view_portal_object.py,sha256=mfaWIjVD_dtLNl8Gfue-9Xo1zBrfChe2Tr9J6aoA7sA,41274
64
+ dcicutils/scripts/view_portal_object.py,sha256=uu1w2sPCjrztA_OZAzo-HiPJhju9mICHf-lJ5RC_Ak0,41573
65
65
  dcicutils/secrets_utils.py,sha256=8dppXAsiHhJzI6NmOcvJV5ldvKkQZzh3Fl-cb8Wm7MI,19745
66
66
  dcicutils/sheet_utils.py,sha256=VlmzteONW5VF_Q4vo0yA5vesz1ViUah1MZ_yA1rwZ0M,33629
67
67
  dcicutils/snapshot_utils.py,sha256=YDeI3vD-MhAtHwKDzfEm2q-n3l-da2yRpRR3xp0Ah1M,23021
68
68
  dcicutils/ssl_certificate_utils.py,sha256=F0ifz_wnRRN9dfrfsz7aCp4UDLgHEY8LaK7PjnNvrAQ,9707
69
- dcicutils/structured_data.py,sha256=75f03o6a3LwsP_AA3fN-RVJKwdVjVEsXxCisZvMQBXg,66662
69
+ dcicutils/structured_data.py,sha256=PbsdEdeC01RvBq9SB7ozMu3oNDJrMlVyHQcBnwAzAkU,66382
70
70
  dcicutils/submitr/progress_constants.py,sha256=5bxyX77ql8qEJearfHEvsvXl7D0GuUODW0T65mbRmnE,2895
71
71
  dcicutils/submitr/ref_lookup_strategy.py,sha256=VJN-Oo0LLna6Vo2cu47eC-eU-yUC9NFlQP29xajejVU,4741
72
72
  dcicutils/task_utils.py,sha256=MF8ujmTD6-O2AC2gRGPHyGdUrVKgtr8epT5XU8WtNjk,8082
@@ -75,8 +75,8 @@ dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
75
75
  dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
76
76
  dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
77
77
  dcicutils/zip_utils.py,sha256=_Y9EmL3D2dUZhxucxHvrtmmlbZmK4FpSsHEb7rGSJLU,3265
78
- dcicutils-8.15.0.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
79
- dcicutils-8.15.0.dist-info/METADATA,sha256=jLOHw_5FazXXwiq5HleEzI0tk-2awnFYQzAlTHq-GN0,3442
80
- dcicutils-8.15.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
81
- dcicutils-8.15.0.dist-info/entry_points.txt,sha256=W6kEWdUJk9tQ4myAgpehPdebcwvCAZ7UgB-wyPgDUMg,335
82
- dcicutils-8.15.0.dist-info/RECORD,,
78
+ dcicutils-8.16.0.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
79
+ dcicutils-8.16.0.dist-info/METADATA,sha256=D1R0giTQXkH-FtwUD7oNdZOyCcNYhz5Aksg_uZXgzfM,3442
80
+ dcicutils-8.16.0.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
81
+ dcicutils-8.16.0.dist-info/entry_points.txt,sha256=W6kEWdUJk9tQ4myAgpehPdebcwvCAZ7UgB-wyPgDUMg,335
82
+ dcicutils-8.16.0.dist-info/RECORD,,