Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format Python code with psf/black push #241

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions dacapo/experiments/datasplits/datasets/arrays/zarr_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def __init__(self, array_config):
self._attributes = self.data.attrs
self._axes = array_config._axes
self.snap_to_grid = array_config.snap_to_grid


def __str__(self):
"""
Expand Down Expand Up @@ -144,7 +143,7 @@ def __repr__(self):

"""
return f"ZarrArray({self.file_name}, {self.dataset})"

@property
def mode(self):
if not hasattr(self, "_mode"):
Expand Down Expand Up @@ -421,7 +420,7 @@ def create_from_array_identifier(
num_channels,
voxel_size,
dtype,
mode = "a",
mode="a",
write_size=None,
name=None,
overwrite=False,
Expand Down
4 changes: 2 additions & 2 deletions dacapo/experiments/datasplits/datasplit_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def get_right_resolution_array_config(
file_name=container,
dataset=str(current_dataset_path),
snap_to_grid=target_resolution,
mode = "r"
mode="r",
)
zarr_array = ZarrArray(zarr_config)
while (
Expand All @@ -138,7 +138,7 @@ def get_right_resolution_array_config(
file_name=container,
dataset=str(Path(dataset, f"s{level}")),
snap_to_grid=target_resolution,
mode = "r"
mode="r",
)

zarr_array = ZarrArray(zarr_config)
Expand Down
27 changes: 23 additions & 4 deletions dacapo/experiments/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(self, run_config, load_starter_model: bool = True):

"""
self.name = run_config.name
self._config = run_config
self.train_until = run_config.num_iterations
self.validation_interval = run_config.validation_interval

Expand All @@ -106,17 +107,17 @@ def __init__(self, run_config, load_starter_model: bool = True):
self.task = task_type(run_config.task_config)
self.architecture = architecture_type(run_config.architecture_config)
self.trainer = trainer_type(run_config.trainer_config)
self.datasplit = datasplit_type(run_config.datasplit_config)

# lazy load datasplit
self._datasplit = None

# combined pieces
self.model = self.task.create_model(self.architecture)
self.optimizer = self.trainer.create_optimizer(self.model)

# tracking
self.training_stats = TrainingStats()
self.validation_scores = ValidationScores(
self.task.parameters, self.datasplit.validate, self.task.evaluation_scores
)
self._validation_scores = None

if not load_starter_model:
self.start = None
Expand All @@ -142,6 +143,24 @@ def __init__(self, run_config, load_starter_model: bool = True):

self.start.initialize_weights(self.model, new_head=new_head)

@property
def datasplit(self):
if self._datasplit is None:
self._datasplit = self._config.datasplit_config.datasplit_type(
self._config.datasplit_config
)
return self._datasplit

@property
def validation_scores(self):
if self._validation_scores is None:
self._validation_scores = ValidationScores(
self.task.parameters,
self.datasplit.validate,
self.task.evaluation_scores,
)
return self._validation_scores

@staticmethod
def get_validation_scores(run_config) -> ValidationScores:
"""
Expand Down
Loading