-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update adding task decorator to init imports (#18)
- Loading branch information
1 parent
36517de
commit b25cf78
Showing
1 changed file
with
22 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) |