Skip to content

Commit

Permalink
fix if model is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Aug 21, 2024
1 parent e28d5f4 commit 2c7e0cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pioreactor/background_jobs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def publish(
self,
topic: str,
payload: pt.PublishableSettingDataType | dict | bytes | None,
qos: int = QOS.AT_MOST_ONCE,
qos: int = QOS.EXACTLY_ONCE,
**kwargs,
) -> None:
"""
Expand Down Expand Up @@ -667,7 +667,7 @@ def _publish_attr(self, attr: str) -> None:
f"pioreactor/{self.unit}/{self.experiment}/{self.job_name}/{attr_name}",
getattr(self, attr),
retain=True,
qos=QOS.EXACTLY_ONCE, # TODO: this requires four messages between client and broker. QOS 1 requires two...
qos=QOS.EXACTLY_ONCE,
)

def _set_up_exit_protocol(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/background_jobs/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def pretty_version(info: tuple) -> str:
"rpi_machine": version.rpi_version_info,
"timestamp": current_utc_timestamp(),
"pioreactor_version": version.tuple_to_text(whoami.get_pioreactor_version()),
"pioreactor_model": whoami.get_pioreactor_model(),
"pioreactor_model": whoami.get_pioreactor_model() or None,
}

self.logger.debug(f"Pioreactor software version: {self.versions['app']}")
Expand Down
15 changes: 12 additions & 3 deletions pioreactor/whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,23 @@ def get_pioreactor_version() -> tuple[int, int]:


@cache
def get_pioreactor_model() -> str:
def get_pioreactor_model() -> str | None:
from pioreactor.config import config

return config.get("pioreactor", "model")
maybe_model = config.get("pioreactor", "model", fallback=None)
if maybe_model:
return maybe_model

else:
return None


def get_pioreactor_model_and_version() -> str:
return f"{get_pioreactor_model()} v{'.'.join(map(str, get_pioreactor_version()))}"
maybe_model = get_pioreactor_model()
if maybe_model:
return f"{maybe_model} v{'.'.join(map(str, get_pioreactor_version()))}"
else:
return ""


def get_image_git_hash() -> str:
Expand Down

0 comments on commit 2c7e0cf

Please sign in to comment.