Skip to content

Commit

Permalink
Fix logical comparisons for nullable values
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-f-cruz committed Aug 30, 2024
1 parent 3ca1762 commit d95e3c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/aind_behavior_services/aind_services/data_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def mapper(
daq_names=devices,
stream_modalities=modalities,
stream_start_time=session_model.date,
stream_end_time=session_end_time or session_model.date,
stream_end_time=session_end_time if session_end_time else session_model.date,
camera_names=list(cameras.keys()),
),
],
Expand Down Expand Up @@ -189,7 +189,7 @@ def mapper(
],
script=Software(
name=Path(script_path).stem,
version=session_model.commit_hash or repository_sha,
version=session_model.commit_hash if session_model.commit_hash else repository_sha,
url=f"{repository_remote_url}/blob/{repository_sha}/{repository_relative_script_path}",
parameters=task_logic_model.model_dump(),
),
Expand All @@ -215,7 +215,7 @@ def _mapper_calibration(
device_name=calibration.device_name,
input=calibration.input.model_dump() if calibration.input else {},
output=calibration.output.model_dump() if calibration.output else {},
calibration_date=calibration.date or default_date,
calibration_date=calibration.date if calibration.date else default_date,
description=calibration.description if calibration.description else "",
notes=calibration.notes,
)
22 changes: 11 additions & 11 deletions src/aind_behavior_services/aind_services/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ def create_manifest_config(
**kwargs,
) -> ManifestConfig:
"""Create a ManifestConfig object"""
project_name = kwargs.pop("project_name", None) or self.project_name
schedule_time = kwargs.pop("schedule_time", None) or self.schedule_time
platform = kwargs.pop("platform", None) or self.platform
capsule_id = kwargs.pop("capsule_id", None) or self.capsule_id
script = kwargs.pop("script", None) or self.script
s3_bucket = kwargs.pop("s3_bucket", None) or self.s3_bucket
mount = kwargs.pop("mount", None) or self.mount
force_cloud_sync = kwargs.pop("force_cloud_sync", None) or self.force_cloud_sync
transfer_endpoint = kwargs.pop("transfer_endpoint", None) or self.transfer_endpoint
validate_project_name = kwargs.pop("validate_project_name", None) or self._validate_project_name
project_name = kwargs.pop("project_name", self.project_name)
schedule_time = kwargs.pop("schedule_time", self.schedule_time)
platform = kwargs.pop("platform", self.platform)
capsule_id = kwargs.pop("capsule_id", self.capsule_id)
script = kwargs.pop("script", self.script)
s3_bucket = kwargs.pop("s3_bucket", self.s3_bucket)
mount = kwargs.pop("mount", self.mount)
force_cloud_sync = kwargs.pop("force_cloud_sync", self.force_cloud_sync)
transfer_endpoint = kwargs.pop("transfer_endpoint", self.transfer_endpoint)
validate_project_name = kwargs.pop("validate_project_name", self._validate_project_name)
processor_full_name = (
kwargs.pop("processor_full_name", None)
or ",".join(ads_session.experimenter_full_name)
Expand Down Expand Up @@ -174,7 +174,7 @@ def force_restart(self, kill_if_running: bool = True) -> subprocess.Popen[bytes]
def dump_manifest_config(
self, manifest_config: ManifestConfig, path: Optional[os.PathLike] = None, make_dir: bool = True
) -> Path:
path = Path(path or self.watched_dir / f"manifest_{manifest_config.name}.yaml").resolve()
path = Path(path if path else self.watched_dir / f"manifest_{manifest_config.name}.yaml").resolve()
if "manifest" not in path.name:
raise ValueError("The file name must contain the string 'manifest' for the watchdog to work.")
if make_dir and not path.parent.exists():
Expand Down
4 changes: 1 addition & 3 deletions src/aind_behavior_services/launcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,7 @@ def post_run_hook(self, *args, **kwargs):
session_name=self.session_schema.session_name,
)

_manifest_name = (
f"manifest_{self.session_schema.session_name or format_datetime(self.session_schema.date)}.yaml"
)
_manifest_name = f"manifest_{self.session_schema.session_name if self.session_schema.session_name else format_datetime(self.session_schema.date)}.yaml"
_manifest_path = self.watchdog.dump_manifest_config(
watchdog_manifest_config, path=Path(self.watchdog.watched_dir) / _manifest_name
)
Expand Down

0 comments on commit d95e3c3

Please sign in to comment.