Skip to content

Commit

Permalink
Update adding task decorator to init imports (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicasyu committed Mar 28, 2023
1 parent 36517de commit b25cf78
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions src/abm_shape_collection/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import importlib
import os
import sys

from prefect import task

for module_file in os.listdir(os.path.dirname(__file__)):
if "__" in module_file or not module_file.endswith(".py"):
continue
from .calculate_shape_stats import calculate_shape_stats
from .calculate_size_stats import calculate_size_stats
from .compile_shape_modes import compile_shape_modes
from .extract_shape_modes import extract_shape_modes
from .fit_pca_model import fit_pca_model
from .get_shape_coefficients import get_shape_coefficients
from .make_voxels_array import make_voxels_array
from .merge_shape_modes import merge_shape_modes

module_name = module_file.replace(".py", "")
TASK_MODULES = [
calculate_shape_stats,
calculate_size_stats,
compile_shape_modes,
extract_shape_modes,
fit_pca_model,
get_shape_coefficients,
make_voxels_array,
merge_shape_modes,
]

module = importlib.import_module(f".{module_name}", package=__name__)
setattr(sys.modules[__name__], module_name, task(getattr(module, module_name)))
for task_module in TASK_MODULES:
MODULE_NAME = task_module.__name__
module = importlib.import_module(f".{MODULE_NAME}", package=__name__)
setattr(sys.modules[__name__], MODULE_NAME, task(getattr(module, MODULE_NAME)))

0 comments on commit b25cf78

Please sign in to comment.