dcicutils 8.14.0.1b3__tar.gz → 8.14.0.1b5__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/PKG-INFO +1 -1
  2. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/scripts/update_portal_object.py +9 -0
  3. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/scripts/view_portal_object.py +45 -6
  4. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/pyproject.toml +1 -1
  5. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/LICENSE.txt +0 -0
  6. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/README.rst +0 -0
  7. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/__init__.py +0 -0
  8. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/base.py +0 -0
  9. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/beanstalk_utils.py +0 -0
  10. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/bundle_utils.py +0 -0
  11. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/captured_output.py +0 -0
  12. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/cloudformation_utils.py +0 -0
  13. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/codebuild_utils.py +0 -0
  14. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/command_utils.py +0 -0
  15. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/common.py +0 -0
  16. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/contribution_scripts.py +0 -0
  17. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/contribution_utils.py +0 -0
  18. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/creds_utils.py +0 -0
  19. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/data_readers.py +0 -0
  20. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/data_utils.py +0 -0
  21. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/datetime_utils.py +0 -0
  22. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/deployment_utils.py +0 -0
  23. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/diff_utils.py +0 -0
  24. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/docker_utils.py +0 -0
  25. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/ecr_scripts.py +0 -0
  26. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/ecr_utils.py +0 -0
  27. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/ecs_utils.py +0 -0
  28. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/env_base.py +0 -0
  29. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/env_manager.py +0 -0
  30. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/env_scripts.py +0 -0
  31. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/env_utils.py +0 -0
  32. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/env_utils_legacy.py +0 -0
  33. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/es_utils.py +0 -0
  34. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/exceptions.py +0 -0
  35. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/ff_mocks.py +0 -0
  36. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/ff_utils.py +0 -0
  37. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/file_utils.py +0 -0
  38. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/function_cache_decorator.py +0 -0
  39. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/glacier_utils.py +0 -0
  40. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/hack_for_elasticsearch_numpy_usage.py +0 -0
  41. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/http_utils.py +0 -0
  42. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/jh_utils.py +0 -0
  43. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/kibana/dashboards.json +0 -0
  44. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/kibana/readme.md +0 -0
  45. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/lang_utils.py +0 -0
  46. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/license_policies/c4-infrastructure.jsonc +0 -0
  47. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/license_policies/c4-python-infrastructure.jsonc +0 -0
  48. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/license_policies/park-lab-common-server.jsonc +0 -0
  49. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/license_policies/park-lab-common.jsonc +0 -0
  50. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/license_policies/park-lab-gpl-pipeline.jsonc +0 -0
  51. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/license_policies/park-lab-pipeline.jsonc +0 -0
  52. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/license_utils.py +0 -0
  53. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/log_utils.py +0 -0
  54. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/misc_utils.py +0 -0
  55. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/obfuscation_utils.py +0 -0
  56. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/opensearch_utils.py +0 -0
  57. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/portal_object_utils.py +0 -0
  58. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/portal_utils.py +0 -0
  59. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/progress_bar.py +0 -0
  60. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/project_utils.py +0 -0
  61. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/qa_checkers.py +0 -0
  62. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/qa_utils.py +0 -0
  63. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/redis_tools.py +0 -0
  64. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/redis_utils.py +0 -0
  65. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/s3_utils.py +0 -0
  66. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/schema_utils.py +0 -0
  67. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/scripts/publish_to_pypi.py +0 -0
  68. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/scripts/run_license_checker.py +0 -0
  69. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/secrets_utils.py +0 -0
  70. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/sheet_utils.py +0 -0
  71. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/snapshot_utils.py +0 -0
  72. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/ssl_certificate_utils.py +0 -0
  73. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/structured_data.py +0 -0
  74. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/submitr/progress_constants.py +0 -0
  75. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/submitr/ref_lookup_strategy.py +0 -0
  76. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/task_utils.py +0 -0
  77. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/tmpfile_utils.py +0 -0
  78. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/trace_utils.py +0 -0
  79. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/validation_utils.py +0 -0
  80. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/variant_utils.py +0 -0
  81. {dcicutils-8.14.0.1b3 → dcicutils-8.14.0.1b5}/dcicutils/zip_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.14.0.1b3
3
+ Version: 8.14.0.1b5
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
@@ -236,6 +236,7 @@ def _post_or_patch_or_upsert(portal: Portal, file_or_directory: str,
236
236
  _print(f"DEBUG: File ({file}) contains a dictionary of schema names.")
237
237
  for schema_name in data:
238
238
  if isinstance(schema_data := data[schema_name], list):
239
+ schema_data = _impose_special_ordering(schema_data, schema_name)
239
240
  if debug:
240
241
  _print(f"DEBUG: Processing {update_action_name}s for type: {schema_name}")
241
242
  for index, item in enumerate(schema_data):
@@ -250,6 +251,8 @@ def _post_or_patch_or_upsert(portal: Portal, file_or_directory: str,
250
251
  elif isinstance(data, list):
251
252
  if debug:
252
253
  _print(f"DEBUG: File ({file}) contains a list of objects of type: {schema_name}")
254
+ import pdb ; pdb.set_trace() # noqa
255
+ data = _impose_special_ordering(data, schema_name)
253
256
  for index, item in enumerate(data):
254
257
  update_function(portal, item, schema_name, file=file, index=index,
255
258
  patch_delete_fields=patch_delete_fields,
@@ -286,6 +289,12 @@ def _post_or_patch_or_upsert(portal: Portal, file_or_directory: str,
286
289
  _print(f"ERROR: Cannot find file or directory: {file_or_directory}")
287
290
 
288
291
 
292
+ def _impose_special_ordering(data: List[dict], schema_name: str) -> List[dict]:
293
+ if schema_name == "FileFormat":
294
+ return sorted(data, key=lambda item: "extra_file_formats" in item)
295
+ return data
296
+
297
+
289
298
  def post_data(portal: Portal, data: dict, schema_name: str,
290
299
  file: Optional[str] = None, index: int = 0,
291
300
  patch_delete_fields: Optional[str] = None,
@@ -66,7 +66,7 @@ from typing import Callable, List, Optional, TextIO, Tuple, Union
66
66
  import yaml
67
67
  from dcicutils.captured_output import captured_output, uncaptured_output
68
68
  from dcicutils.command_utils import yes_or_no
69
- from dcicutils.misc_utils import get_error_message, is_uuid, PRINT
69
+ from dcicutils.misc_utils import get_error_message, is_uuid, PRINT, to_snake_case
70
70
  from dcicutils.portal_utils import Portal
71
71
 
72
72
 
@@ -104,6 +104,8 @@ def main():
104
104
  parser.add_argument("--raw", action="store_true", required=False, default=False, help="Raw output.")
105
105
  parser.add_argument("--inserts", action="store_true", required=False, default=False,
106
106
  help="Format output for subsequent inserts.")
107
+ parser.add_argument("--insert-files", action="store_true", required=False, default=False,
108
+ help="Output for to insert files.")
107
109
  parser.add_argument("--ignore", nargs="+", help="Ignore these fields for --inserts.")
108
110
  parser.add_argument("--tree", action="store_true", required=False, default=False, help="Tree output for schemas.")
109
111
  parser.add_argument("--database", action="store_true", required=False, default=False,
@@ -117,6 +119,7 @@ def main():
117
119
  parser.add_argument("--indent", required=False, default=False, help="Indent output.", type=int)
118
120
  parser.add_argument("--summary", action="store_true", required=False, default=False,
119
121
  help="Summary output (for schema only).")
122
+ parser.add_argument("--force", action="store_true", required=False, default=False, help="Debugging output.")
120
123
  parser.add_argument("--terse", action="store_true", required=False, default=False, help="Terse output.")
121
124
  parser.add_argument("--verbose", action="store_true", required=False, default=False, help="Verbose output.")
122
125
  parser.add_argument("--debug", action="store_true", required=False, default=False, help="Debugging output.")
@@ -129,6 +132,15 @@ def main():
129
132
  _print("UUID or schema or path required.")
130
133
  _exit(1)
131
134
 
135
+ if args.insert_files:
136
+ args.inserts = True
137
+ if args.output:
138
+ if not os.path.isdir(args.output):
139
+ _print(f"Specified output directory for insert files does not exist: {args.output}")
140
+ exit(1)
141
+ args.insert_files = args.output
142
+ args.output = None
143
+
132
144
  if args.output:
133
145
  if os.path.exists(args.output):
134
146
  if os.path.isdir(args.output):
@@ -136,7 +148,7 @@ def main():
136
148
  _exit(1)
137
149
  elif os.path.isfile(args.output):
138
150
  _print(f"Specified output file already exists: {args.output}")
139
- if not yes_or_no(f"Do you want to overwrite this file?"):
151
+ if (not args.force) and not yes_or_no(f"Do you want to overwrite this file?"):
140
152
  _exit(0)
141
153
  _output_file = io.open(args.output, "w")
142
154
 
@@ -191,8 +203,12 @@ def main():
191
203
  all=args.all, summary=args.summary, yaml=args.yaml)
192
204
  return
193
205
 
194
- data = _get_portal_object(portal=portal, uuid=args.uuid, raw=args.raw, inserts=args.inserts,
195
- ignore=args.ignore, database=args.database, check=args.bool, verbose=args.verbose)
206
+ data = _get_portal_object(portal=portal, uuid=args.uuid, raw=args.raw, database=args.database,
207
+ inserts=args.inserts, insert_files=args.insert_files,
208
+ ignore=args.ignore, check=args.bool, force=args.force, verbose=args.verbose)
209
+ if args.insert_files:
210
+ return
211
+
196
212
  if args.bool:
197
213
  if data:
198
214
  _print(f"{args.uuid}: found")
@@ -242,9 +258,10 @@ def _create_portal(ini: str, env: Optional[str] = None,
242
258
 
243
259
 
244
260
  def _get_portal_object(portal: Portal, uuid: str,
245
- raw: bool = False, inserts: bool = False, database: bool = False,
261
+ raw: bool = False, database: bool = False,
262
+ inserts: bool = False, insert_files: bool = False,
246
263
  ignore: Optional[List[str]] = None,
247
- check: bool = False, verbose: bool = False) -> dict:
264
+ check: bool = False, force: bool = False, verbose: bool = False) -> dict:
248
265
 
249
266
  def prune_data(data: dict) -> dict:
250
267
  nonlocal ignore
@@ -324,6 +341,28 @@ def _get_portal_object(portal: Portal, uuid: str,
324
341
  elif ((response_cooked := portal.get(path, database=database)) and
325
342
  (isinstance(response_type := response_cooked.json().get("@type"), list) and response_type)):
326
343
  response = {f"{response_type[0]}": [prune_data(response)]}
344
+ if insert_files:
345
+ output_directory = insert_files if isinstance(insert_files, str) else os.getcwd()
346
+ for schema_name in response:
347
+ schema_data = response[schema_name]
348
+ file_name = f"{to_snake_case(schema_name)}.json"
349
+ file_path = os.path.join(output_directory, file_name)
350
+ if os.path.exists(file_path):
351
+ if os.path.isdir(file_path):
352
+ _print(f"WARNING: Output file already exists as a directory. SKIPPING: {file_path}")
353
+ continue
354
+ if force:
355
+ if verbose:
356
+ _print(f"Overwriting extant file (per --force option): {file_path}")
357
+ else:
358
+ _print(f"Output file already exists: {file_path}")
359
+ if (not force) and not yes_or_no(f"Overwrite this file?"):
360
+ continue
361
+ if verbose:
362
+ _print(f"Writing {schema_name} (object{'s' if len(schema_data) != 1 else ''}:"
363
+ f" {len(schema_data)}) file: {file_path}")
364
+ with io.open(file_path, "w") as f:
365
+ json.dump(schema_data, f, indent=4)
327
366
  elif raw:
328
367
  response.pop("schema_version", None)
329
368
  return response
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dcicutils"
3
- version = "8.14.0.1b3" # TODO: To become 8.14.1
3
+ version = "8.14.0.1b5" # TODO: To become 8.14.1
4
4
  description = "Utility package for interacting with the 4DN Data Portal and other 4DN resources"
5
5
  authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
6
6
  license = "MIT"