-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8eab12
commit a1bb742
Showing
1 changed file
with
22 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
) | ||
|
||
DEFAULT_USER = "8.3.2" # In case there's not proposal number | ||
|
||
UNKNWON_EMAIL = "[email protected]" | ||
ingest_spec = "als832_dx_3" | ||
|
||
logger = logging.getLogger("scicat_ingest") | ||
|
@@ -38,6 +38,7 @@ def ingest( | |
scicat_client: ScicatClient, | ||
file_path: str, | ||
issues: List[Issue], | ||
log_level: str = "INFO", | ||
) -> str: | ||
"""Ingests a file into scicat | ||
|
@@ -60,7 +61,7 @@ def ingest( | |
str | ||
Dataset id of the new | ||
""" | ||
|
||
logger.setLevel(log_level) | ||
INGEST_STORAGE_ROOT_PATH = os.getenv("INGEST_STORAGE_ROOT_PATH") | ||
INGEST_SOURCE_ROOT_PATH = os.getenv("INGEST_SOURCE_ROOT_PATH") | ||
|
||
|
@@ -154,6 +155,7 @@ def upload_raw_dataset( | |
creationTime=file_mod_time, | ||
**ownable.dict(), | ||
) | ||
logger.debug(f"dataset: {dataset}") | ||
dataset_id = scicat_client.upload_new_dataset(dataset) | ||
return dataset_id | ||
|
||
|
@@ -264,8 +266,13 @@ def _get_data_sample(file, sample_size=10): | |
|
||
return data_sample | ||
|
||
|
||
def clean_email(email: str): | ||
if email: | ||
if not email or email.upper() == "NONE": | ||
# this is a brutal case, but the beamline sometimes puts in "None" and | ||
# the new scicat backend hates that. | ||
return UNKNWON_EMAIL | ||
return email.replace(" ", "").replace(",", "").replace("'", "") | ||
return None | ||
|
||
|
@@ -345,17 +352,16 @@ def clean_email(email: str): | |
] | ||
|
||
|
||
# if __name__ == "__main__": | ||
# import os | ||
|
||
# ingest( | ||
# ScicatClient( | ||
# # "http://localhost:3000/api/v3", | ||
# os.environ.get("SCICAT_API_URL"), | ||
# None, | ||
# os.environ.get("SCICAT_INGEST_USER"), | ||
# os.environ.get("SCICAT_INGEST_PASSWORD"), | ||
# ), | ||
# "/Users/dylanmcreynolds/data/beamlines/8.3.2/raw/20230927_165759_ddd.h5", | ||
# [], | ||
# ) | ||
if __name__ == "__main__": | ||
ingest( | ||
ScicatClient( | ||
# "http://localhost:3000/api/v3", | ||
os.environ.get("SCICAT_API_URL"), | ||
None, | ||
os.environ.get("SCICAT_INGEST_USER"), | ||
os.environ.get("SCICAT_INGEST_PASSWORD"), | ||
), | ||
"/Users/dylanmcreynolds/data/beamlines/8.3.2/raw/20231013_065251_MSB_Book1_Proj77_Cell3_Gen2_Li_R2G_FastCharge_DuringCharge0.h5", | ||
[], | ||
log_level="DEBUG", | ||
) |