Skip to content

Commit

Permalink
Merge pull request #40 from nemocrys:arvedes/issue39
Browse files Browse the repository at this point in the history
Catch exception with missing git
  • Loading branch information
arvedes authored Apr 11, 2023
2 parents 9050026 + d5159fd commit 78937fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,13 @@ For the discord bot there are the following additional dependencies:

- pyoptris and dependencies installed according to https://github.com/nemocrys/pyOptris/blob/dev/README.md

### Logging of own version

- git (will be called as a subprocess if available)

## NOMAD support

NOMAD support and the option to uploade measurement data to [NOMAD](https://nomad-lab.eu/) is under implementation. Currently, various yaml-files containing a machine-readable description of the measurement data are generated.
NOMAD support and the option to upload measurement data to [NOMAD](https://nomad-lab.eu/) is under implementation. Currently, various yaml-files containing a machine-readable description of the measurement data are generated.

## Documentation

Expand Down
32 changes: 20 additions & 12 deletions multilog/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,17 @@ def write_nomad_file(self):
with open("./multilog/nomad/archive_template_main.yml") as f:
nomad_dict = yaml.safe_load(f)
data = nomad_dict.pop("data")
multilog_version = (
subprocess.check_output(
["git", "describe", "--tags", "--dirty", "--always"]
try:
multilog_version = (
subprocess.check_output(
["git", "describe", "--tags", "--dirty", "--always"]
)
.strip()
.decode("utf-8")
)
.strip()
.decode("utf-8")
)
except FileNotFoundError:
logger.warning("Unable to determine multilog version.", exc_info=True)
multilog_version = "unknown"
data["timestamp"] = datetime.datetime.now(datetime.timezone.utc).astimezone().isoformat(timespec='milliseconds').replace('T', ' ')
data["tasks"][0].update(
{
Expand Down Expand Up @@ -357,13 +361,17 @@ def write_metadata(self):
"""Write a csv file with information about multilog version,
python version and operating system.
"""
multilog_version = (
subprocess.check_output(
["git", "describe", "--tags", "--dirty", "--always"]
try:
multilog_version = (
subprocess.check_output(
["git", "describe", "--tags", "--dirty", "--always"]
)
.strip()
.decode("utf-8")
)
.strip()
.decode("utf-8")
)
except FileNotFoundError:
logger.warning("Unable to determine multilog version.", exc_info=True)
multilog_version = "unknown"
metadata = f"multilog version,python version,system information,\n"
metadata += f"{multilog_version},{platform.python_version()},{str(platform.uname()).replace(',',';')},\n"
with open(f"{self.directory}/config.yml", "w", encoding="utf-8") as f:
Expand Down

0 comments on commit 78937fa

Please sign in to comment.