Skip to content
Snippets Groups Projects
Commit 866dcf50 authored by JostTim's avatar JostTim
Browse files

updates

parent c77e1769
No related branches found
No related tags found
No related merge requests found
Showing
with 17 additions and 10 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -2,6 +2,7 @@ from . step import BaseStep ...@@ -2,6 +2,7 @@ from . step import BaseStep
from . multisession import BaseMultisessionAccessor from . multisession import BaseMultisessionAccessor
from functools import wraps from functools import wraps
import inspect
from typing import Callable, Type, Iterable, Protocol, TYPE_CHECKING from typing import Callable, Type, Iterable, Protocol, TYPE_CHECKING
...@@ -32,9 +33,16 @@ class PipeMetaclass(type): ...@@ -32,9 +33,16 @@ class PipeMetaclass(type):
return super().__new__(cls, pipe_name, bases, attributes) return super().__new__(cls, pipe_name, bases, attributes)
def __init__(cls : Type, pipe_name : str, bases : Iterable[Type], attributes : dict) -> None:
print(f"init of {pipe_name}")
print(cls.__dict__)
@staticmethod @staticmethod
def make_step_attributes(step : Callable, pipe_name : str, step_name : str) -> Callable: def make_step_attributes(step : Callable, pipe_name : str, step_name : str) -> Callable:
print(f"init of {pipe_name}")
setattr(step, "pipe_name", pipe_name) setattr(step, "pipe_name", pipe_name)
setattr(step, "step_name", step_name) setattr(step, "step_name", step_name)
...@@ -58,6 +66,10 @@ class BasePipe(metaclass = PipeMetaclass): ...@@ -58,6 +66,10 @@ class BasePipe(metaclass = PipeMetaclass):
# this loop allows to populate self.steps from the now instanciated version of the step method. # this loop allows to populate self.steps from the now instanciated version of the step method.
# Using only instanciated version is important to be able to use self into it later, # Using only instanciated version is important to be able to use self into it later,
# without confusing ourselved with uninstanciated versions in the steps dict # without confusing ourselved with uninstanciated versions in the steps dict
methods = inspect.getmembers(self, predicate= inspect.ismethod)
print(methods)
for step_name, _ in self.steps.items(): for step_name, _ in self.steps.items():
step = getattr(self , step_name) # get the instanciated step method from name. step = getattr(self , step_name) # get the instanciated step method from name.
step = self.step_class(self.pipeline, self, step, step_name) step = self.step_class(self.pipeline, self, step, step_name)
......
No preview for this file type
...@@ -4,10 +4,6 @@ import pypelines ...@@ -4,10 +4,6 @@ import pypelines
pipeline_test_instance = pypelines.BasePipeline() pipeline_test_instance = pypelines.BasePipeline()
@pipeline_test_instance.register_pipe @pipeline_test_instance.register_pipe
class TestPipe(pypelines.BasePipe): class TestPipe(pypelines.BasePipe):
\ No newline at end of file
...@@ -4,16 +4,15 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..') ...@@ -4,16 +4,15 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')
import pypelines import pypelines
from . instances import pipeline_test_instance from pypelines import examples
class TestVersions(unittest.TestCase): class TestVersions(unittest.TestCase):
def setUp(self): def setUp(self):
self.version_handler = pypelines.HashVersionHandler('version_example.py') self.pipeline = examples.example_pipeline
self.pipeline = pipeline_test_instance
def test_function_hash(self): def test_pipeline_generate(self):
self.assertEqual(self.version_handler.get_function_hash(), "ad2d1f4") self.assertEqual(self.pipeline.ExamplePipe.example_step1.generate("bonjour"), {"argument1" : "bonjour", "optionnal_argument2" : 23})
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment