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

Add task decorator to init imports #19

Merged
merged 1 commit into from
Mar 30, 2023
Merged
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
26 changes: 8 additions & 18 deletions src/abm_shape_collection/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import importlib
import sys

from prefect import task

from .calculate_shape_stats import calculate_shape_stats
Expand All @@ -12,18 +9,11 @@
from .make_voxels_array import make_voxels_array
from .merge_shape_modes import merge_shape_modes

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,
]

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)))
calculate_shape_stats = task(calculate_shape_stats)
calculate_size_stats = task(calculate_size_stats)
compile_shape_modes = task(compile_shape_modes)
extract_shape_modes = task(extract_shape_modes)
fit_pca_model = task(fit_pca_model)
get_shape_coefficients = task(get_shape_coefficients)
make_voxels_array = task(make_voxels_array)
merge_shape_modes = task(merge_shape_modes)