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
This commit is contained in:
2026-05-14 17:21:07 +02:00
parent e1d5dfa487
commit 1ce381f341

View File

@@ -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")