From bda506736401bb39a603e921c41737ca352a9324 Mon Sep 17 00:00:00 2001 From: Marwan Zouinkhi Date: Mon, 18 Mar 2024 17:37:23 -0400 Subject: [PATCH 1/2] fix serialization --- dacapo/experiments/starts/cosem_start.py | 15 ++------------- dacapo/experiments/starts/cosem_start_config.py | 8 +++----- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/dacapo/experiments/starts/cosem_start.py b/dacapo/experiments/starts/cosem_start.py index d8dd8f8af..f871cc0bc 100644 --- a/dacapo/experiments/starts/cosem_start.py +++ b/dacapo/experiments/starts/cosem_start.py @@ -7,21 +7,10 @@ logger = logging.getLogger(__file__) -def format_name(name): - if "/" in name: - run, criterion = name.split("/") - return run, criterion - else: - raise ValueError( - f"Invalid starter name format {name}. Must be in the format run/criterion" - ) - - class CosemStart(Start): def __init__(self, start_config): - run, criterion = format_name(start_config.name) - self.name = start_config.name - super().__init__(run, criterion) + self.name = f"{self.run}/{self.criterion}" + super().__init__(start_config) def initialize_weights(self, model): from dacapo.store.create_store import create_weights_store diff --git a/dacapo/experiments/starts/cosem_start_config.py b/dacapo/experiments/starts/cosem_start_config.py index bd1a9014f..32405658a 100644 --- a/dacapo/experiments/starts/cosem_start_config.py +++ b/dacapo/experiments/starts/cosem_start_config.py @@ -1,14 +1,12 @@ import attr from .cosem_start import CosemStart - +from .start_config import StartConfig @attr.s -class CosemStartConfig: +class CosemStartConfig(StartConfig): """Starter for COSEM pretained models. This is a subclass of `StartConfig` and should be used to initialize the model with pretrained weights from a previous run. """ - start_type = CosemStart - - name: str = attr.ib(metadata={"help_text": "The COSEM checkpoint name to use."}) + start_type = CosemStart \ No newline at end of file From 4a6ddc91603bc992c1b1849d923fe8dc652cf10c Mon Sep 17 00:00:00 2001 From: mzouink Date: Mon, 18 Mar 2024 21:38:10 +0000 Subject: [PATCH 2/2] :art: Format Python code with psf/black --- dacapo/experiments/starts/cosem_start_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dacapo/experiments/starts/cosem_start_config.py b/dacapo/experiments/starts/cosem_start_config.py index 32405658a..de16477b1 100644 --- a/dacapo/experiments/starts/cosem_start_config.py +++ b/dacapo/experiments/starts/cosem_start_config.py @@ -2,6 +2,7 @@ from .cosem_start import CosemStart from .start_config import StartConfig + @attr.s class CosemStartConfig(StartConfig): """Starter for COSEM pretained models. This is a subclass of `StartConfig` and @@ -9,4 +10,4 @@ class CosemStartConfig(StartConfig): run. """ - start_type = CosemStart \ No newline at end of file + start_type = CosemStart