caltechdata-api 1.10.6__tar.gz → 1.11.0__tar.gz
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.
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/PKG-INFO +2 -1
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/caltechdata_edit.py +28 -12
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/cli.py +10 -20
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api.egg-info/PKG-INFO +2 -1
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api.egg-info/requires.txt +1 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/setup.cfg +2 -1
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/LICENSE +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/README.md +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/__init__.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/caltechdata_write.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/customize_schema.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/download_file.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/get_files.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/get_metadata.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/md_to_json.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/utils.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/date_types.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/description_types.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/identifier_types.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/licenses.csv +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/relation_types.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/resource_types.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/roles.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/title_types.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies.yaml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api.egg-info/SOURCES.txt +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api.egg-info/dependency_links.txt +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api.egg-info/entry_points.txt +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api.egg-info/top_level.txt +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/pyproject.toml +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/setup.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/tests/test_download.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/tests/test_rdm.py +0 -0
- {caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/tests/test_unit.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: caltechdata_api
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.0
|
|
4
4
|
Summary: Python wrapper for CaltechDATA API.
|
|
5
5
|
Home-page: https://github.com/caltechlibrary/caltechdata_api
|
|
6
6
|
Author: Thomas E Morrell, Rohan Bhattarai, Elizabeth Won, Alexander A Abakah, Kshemaahna Nagi
|
|
@@ -24,6 +24,7 @@ Requires-Dist: pyyaml
|
|
|
24
24
|
Requires-Dist: s3fs
|
|
25
25
|
Requires-Dist: cryptography
|
|
26
26
|
Requires-Dist: s3cmd
|
|
27
|
+
Requires-Dist: jsonschema-specifications
|
|
27
28
|
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
# CaltechDATA API Python Library
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import copy, os, json
|
|
1
|
+
import copy, os, json, time
|
|
2
2
|
|
|
3
3
|
import requests
|
|
4
4
|
from requests import session
|
|
@@ -193,7 +193,14 @@ def caltechdata_edit(
|
|
|
193
193
|
headers=headers,
|
|
194
194
|
)
|
|
195
195
|
if existing.status_code != 200:
|
|
196
|
-
|
|
196
|
+
# Try back again to the record
|
|
197
|
+
existing = requests.get(
|
|
198
|
+
url + "/api/records/" + idv,
|
|
199
|
+
headers=headers,
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if existing.status_code != 200:
|
|
203
|
+
raise Exception(f"Record {idv} does not exist, cannot edit")
|
|
197
204
|
|
|
198
205
|
existing = existing.json()
|
|
199
206
|
status = existing["status"]
|
|
@@ -326,17 +333,16 @@ def caltechdata_edit(
|
|
|
326
333
|
# We make a draft
|
|
327
334
|
result = requests.post(
|
|
328
335
|
url + "/api/records/" + idv + "/draft",
|
|
329
|
-
json=data,
|
|
330
336
|
headers=headers,
|
|
331
337
|
)
|
|
332
338
|
if result.status_code != 201:
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
339
|
+
time.sleep(3)
|
|
340
|
+
result = requests.post(
|
|
341
|
+
url + "/api/records/" + idv + "/draft",
|
|
342
|
+
headers=headers,
|
|
343
|
+
)
|
|
344
|
+
if result.status_code != 201:
|
|
345
|
+
raise Exception(result.text)
|
|
340
346
|
# We want files to stay the same as the existing record
|
|
341
347
|
data["files"] = existing["files"]
|
|
342
348
|
if default_preview:
|
|
@@ -348,13 +354,23 @@ def caltechdata_edit(
|
|
|
348
354
|
json=data,
|
|
349
355
|
)
|
|
350
356
|
if result.status_code != 200:
|
|
351
|
-
|
|
357
|
+
time.sleep(3)
|
|
358
|
+
result = requests.put(
|
|
359
|
+
url + "/api/records/" + idv + "/draft",
|
|
360
|
+
headers=headers,
|
|
361
|
+
json=data,
|
|
362
|
+
)
|
|
363
|
+
if result.status_code != 200:
|
|
364
|
+
raise Exception(result.text)
|
|
352
365
|
|
|
353
366
|
if publish:
|
|
354
367
|
publish_link = f"{url}/api/records/{idv}/draft/actions/publish"
|
|
355
368
|
result = requests.post(publish_link, headers=headers)
|
|
356
369
|
if result.status_code != 202:
|
|
357
|
-
|
|
370
|
+
time.sleep(3)
|
|
371
|
+
result = requests.post(publish_link, headers=headers)
|
|
372
|
+
if result.status_code != 202:
|
|
373
|
+
raise Exception(result.text)
|
|
358
374
|
if return_id:
|
|
359
375
|
return result.json()["id"]
|
|
360
376
|
else:
|
|
@@ -173,11 +173,9 @@ def get_funding_details():
|
|
|
173
173
|
award_number = get_user_input("Enter the award number for funding: ")
|
|
174
174
|
award_exists = check_award_number(award_number)
|
|
175
175
|
if not award_exists:
|
|
176
|
-
print(
|
|
177
|
-
f"""Error: No award with number '{award_number}' found in
|
|
176
|
+
print(f"""Error: No award with number '{award_number}' found in
|
|
178
177
|
CaltechDATA. You will need to provide more details about the
|
|
179
|
-
funding."""
|
|
180
|
-
)
|
|
178
|
+
funding.""")
|
|
181
179
|
award_title = get_user_input("Enter the award title for funding: ")
|
|
182
180
|
while True:
|
|
183
181
|
funder_identifier = get_user_input("Enter the funder ROR (https://ror.org): ")
|
|
@@ -185,11 +183,9 @@ def get_funding_details():
|
|
|
185
183
|
if name:
|
|
186
184
|
break
|
|
187
185
|
else:
|
|
188
|
-
print(
|
|
189
|
-
"""This funder identifier is not a ROR. Please enter a valid
|
|
186
|
+
print("""This funder identifier is not a ROR. Please enter a valid
|
|
190
187
|
ROR identifier (without the url). For example the ROR for the
|
|
191
|
-
NSF is 021nxhr62."""
|
|
192
|
-
)
|
|
188
|
+
NSF is 021nxhr62.""")
|
|
193
189
|
print("-" * 10)
|
|
194
190
|
return {
|
|
195
191
|
"awardNumber": award_number,
|
|
@@ -349,14 +345,12 @@ def write_s3cmd_config(endpoint):
|
|
|
349
345
|
access_key = get_user_input("Enter the access key: ")
|
|
350
346
|
secret_key = get_user_input("Enter the secret key: ")
|
|
351
347
|
with open(configf, "w") as file:
|
|
352
|
-
file.write(
|
|
353
|
-
f"""[default]
|
|
348
|
+
file.write(f"""[default]
|
|
354
349
|
access_key = {access_key}
|
|
355
350
|
host_base = {endpoint}
|
|
356
351
|
host_bucket = %(bucket).{endpoint}
|
|
357
352
|
secret_key = {secret_key}
|
|
358
|
-
"""
|
|
359
|
-
)
|
|
353
|
+
""")
|
|
360
354
|
|
|
361
355
|
|
|
362
356
|
def upload_supporting_file(record_id=None):
|
|
@@ -431,11 +425,9 @@ def upload_supporting_file(record_id=None):
|
|
|
431
425
|
elif filename in files:
|
|
432
426
|
file_size = os.path.getsize(filename)
|
|
433
427
|
if file_size > 1024 * 1024 * 1024:
|
|
434
|
-
print(
|
|
435
|
-
"""The file is greater than 1 GB. Please upload the
|
|
428
|
+
print("""The file is greater than 1 GB. Please upload the
|
|
436
429
|
metadata to CaltechDATA, and you'll be provided
|
|
437
|
-
instructions to upload the files to S3 directly."""
|
|
438
|
-
)
|
|
430
|
+
instructions to upload the files to S3 directly.""")
|
|
439
431
|
else:
|
|
440
432
|
filepath = os.path.abspath(filename)
|
|
441
433
|
filepaths.append(filepath)
|
|
@@ -643,12 +635,10 @@ def print_upload_message(rec_id, production):
|
|
|
643
635
|
if production
|
|
644
636
|
else "https://data.caltechlibrary.dev/uploads/"
|
|
645
637
|
)
|
|
646
|
-
print(
|
|
647
|
-
f"""You can view and publish this record at
|
|
638
|
+
print(f"""You can view and publish this record at
|
|
648
639
|
{base_url}{rec_id}
|
|
649
640
|
If you need to upload large files to S3, you can type
|
|
650
|
-
`s3cmd put DATA_FILE s3://ini230004-bucket01/{rec_id}/`"""
|
|
651
|
-
)
|
|
641
|
+
`s3cmd put DATA_FILE s3://ini230004-bucket01/{rec_id}/`""")
|
|
652
642
|
|
|
653
643
|
|
|
654
644
|
def edit_record(production):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: caltechdata_api
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.0
|
|
4
4
|
Summary: Python wrapper for CaltechDATA API.
|
|
5
5
|
Home-page: https://github.com/caltechlibrary/caltechdata_api
|
|
6
6
|
Author: Thomas E Morrell, Rohan Bhattarai, Elizabeth Won, Alexander A Abakah, Kshemaahna Nagi
|
|
@@ -24,6 +24,7 @@ Requires-Dist: pyyaml
|
|
|
24
24
|
Requires-Dist: s3fs
|
|
25
25
|
Requires-Dist: cryptography
|
|
26
26
|
Requires-Dist: s3cmd
|
|
27
|
+
Requires-Dist: jsonschema-specifications
|
|
27
28
|
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
# CaltechDATA API Python Library
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[metadata]
|
|
6
6
|
name = caltechdata_api
|
|
7
|
-
version = 1.
|
|
7
|
+
version = 1.11.0
|
|
8
8
|
author = Thomas E Morrell, Rohan Bhattarai, Elizabeth Won, Alexander A Abakah, Kshemaahna Nagi
|
|
9
9
|
author_email = tmorrell@caltech.edu, aabakah@caltech.edu, knagi@caltech.edu
|
|
10
10
|
description = Python wrapper for CaltechDATA API.
|
|
@@ -33,6 +33,7 @@ install_requires =
|
|
|
33
33
|
s3fs
|
|
34
34
|
cryptography
|
|
35
35
|
s3cmd
|
|
36
|
+
jsonschema-specifications
|
|
36
37
|
include_package_data = True
|
|
37
38
|
|
|
38
39
|
[options.packages.find]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/date_types.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/identifier_types.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/relation_types.yaml
RENAMED
|
File without changes
|
{caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/resource_types.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api/vocabularies/title_types.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{caltechdata_api-1.10.6 → caltechdata_api-1.11.0}/caltechdata_api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|