From 1ce381f34141be35e7de170479af3b3903d15e3bcec9abf1da842c14c811329b Mon Sep 17 00:00:00 2001 From: PioApocalypse Date: Thu, 14 May 2026 17:21:07 +0200 Subject: [PATCH] quality improvements API key prompt is now "echo on" - echo off was useless given the context sample name gets trimmed so only STD-ID is preserved in the filename filename now contains technique (PLD) and ends in .nxs all should be right in the world - and nffa-di data research policy compliant, spec.lly sect. 3.1.7-3.1.9 --- src/main.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.py b/src/main.py index bf2df72..fe404c2 100755 --- a/src/main.py +++ b/src/main.py @@ -871,7 +871,7 @@ def build_nexus_file(pld_fabrication, output_path="output/nffa-di_unnamed.h5"): if __name__ == "__main__": load_dotenv() - api_key = os.getenv("api_key") or getpass("Paste API key here: ") + api_key = os.getenv("api_key") or getpass("Paste API key here: ", echo_char="*") elabid = ( os.getenv("elabid") or input("Enter elabid of your starting sample [default = 1111]: ") @@ -880,8 +880,12 @@ if __name__ == "__main__": handler = APIHandler(api_key) data = handler.get_entry_from_elabid(elabid) sample = Entrypoint(data) - sample_name = sample.name.strip().replace(" ", "_") + sample_name = sample.name.strip().replace( + " ", "-" + ) # returns error if no "title" or title is not str operative_unit = os.getenv("operative_unit") or None + if operative_unit: + operative_unit = operative_unit.strip().replace(" ", "-") if sample.proposal: sample_proposal = call_proposal_from_elabid(sample.proposal) else: @@ -894,12 +898,12 @@ if __name__ == "__main__": "nffa-di_" + (f"{sample_proposal}_" if sample_proposal else "") + (f"{operative_unit}_" if operative_unit else "") - + "_" - + sample_name + + "PLD_" + + sample_name[:9] ) result = make_nexus_schema_dictionary(substrate_object, layers) with open(f"output/{fn_base}.json", "w") as f: json.dump(result, f, indent=3) - build_nexus_file(result, output_path=f"output/{fn_base}.h5") + build_nexus_file(result, output_path=f"output/{fn_base}.nxs")