Skip to content

Commit

Permalink
add from_project parameter
Browse files Browse the repository at this point in the history
start implementing support for running methods outside of the scportrait project structure
  • Loading branch information
sophiamaedler committed Jan 27, 2025
1 parent db03a23 commit e72c336
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/scportrait/pipeline/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,30 @@ class ProcessingStep(Logable):
DEFAULT_SELECTION_DIR_NAME = "selection"

def __init__(
self, config, directory, project_location, debug=False, overwrite=False, project=None, filehandler=None
self,
config,
directory = None,
project_location = None,
debug=False,
overwrite=False,
project=None,
filehandler=None,
from_project:bool = False,
):
super().__init__(directory=directory)

self.debug = debug
self.overwrite = overwrite
self.project_location = project_location
if from_project:
self.project_run = True
self.project_location = project_location
self.project = project
self.filehandler = filehandler
else:
self.project_run = False
self.project_location = None
self.project = None
self.filehandler = None

if isinstance(config, str):
config = read_config(config)
Expand All @@ -195,9 +212,6 @@ def __init__(
self.config = config
self.overwrite = overwrite

self.project = project
self.filehandler = filehandler

self.get_context()

self.deep_debug = False
Expand Down
4 changes: 4 additions & 0 deletions src/scportrait/pipeline/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def _setup_segmentation_f(self, segmentation_f):
overwrite=self.overwrite,
project=None,
filehandler=self.filehandler,
from_project=True,
)

def _setup_extraction_f(self, extraction_f):
Expand Down Expand Up @@ -281,6 +282,7 @@ def _setup_extraction_f(self, extraction_f):
overwrite=self.overwrite,
project=self,
filehandler=self.filehandler,
from_project=True,
)

def _setup_featurization_f(self, featurization_f):
Expand Down Expand Up @@ -308,6 +310,7 @@ def _setup_featurization_f(self, featurization_f):
overwrite=False, #this needs to be set to false as the featurization step should not remove previously created features
project=self,
filehandler=self.filehandler,
from_project=True,
)

def _setup_selection(self, selection_f):
Expand Down Expand Up @@ -335,6 +338,7 @@ def _setup_selection(self, selection_f):
overwrite=self.overwrite,
project=self,
filehandler=self.filehandler,
from_project=True,
)

def update_featurization_f(self, featurization_f):
Expand Down

0 comments on commit e72c336

Please sign in to comment.