Skip to content

Commit

Permalink
Merge pull request #908 from BCDA-APS/876-NXWriter-title-default
Browse files Browse the repository at this point in the history
NXWriter should link title from metadata, if available
  • Loading branch information
prjemian authored Jan 9, 2024
2 parents d4bb2cf + 717b1c4 commit 93694e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ jobs:
- name: Run tests with pytest & coverage
shell: bash -l {0}
run: |
# set -vxeuo pipefail
coverage run --concurrency=thread --parallel-mode -m pytest -vvv --exitfirst .
coverage combine
coverage report --precision 3
Expand Down
7 changes: 4 additions & 3 deletions apstools/callbacks/nexus_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ def get_sample_title(self):
"""
return the title for this sample
default title: {plan_name}-S{scan_id}-{short_uid}
default title: S{scan_id}-{plan_name}-{short_uid}
"""
return f"{self.plan_name}-S{self.scan_id:04d}-{self.uid[:7]}"
return f"S{self.scan_id:04d}-{self.plan_name}-{self.uid[:7]}"

def get_stream_link(self, signal, stream=None, ref=None):
"""
Expand Down Expand Up @@ -444,7 +444,8 @@ def write_entry(self):
if self.warn_on_missing_content:
logger.warning("No data for /entry/run_cycle")

nxentry["title"] = self.get_sample_title()
title = self.root.get("/entry/instrument/bluesky/metadata/title")
nxentry["title"] = title or self.get_sample_title()
nxentry["plan_name"] = self.root["/entry/instrument/bluesky/metadata/plan_name"]
nxentry["entry_identifier"] = self.root["/entry/instrument/bluesky/uid"]

Expand Down

0 comments on commit 93694e7

Please sign in to comment.