Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pypelines
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HaissLab
Data Management
Pypelines
Commits
15c67a0c
Commit
15c67a0c
authored
8 months ago
by
Timothe Jost
Browse files
Options
Downloads
Patches
Plain Diff
ongoing developpement of improved typing support via other means of creation than decorators
parent
073aa3ac
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/pypelines/__init__.py
+1
-1
1 addition, 1 deletion
src/pypelines/__init__.py
src/pypelines/pipes.py
+3
-3
3 additions, 3 deletions
src/pypelines/pipes.py
src/pypelines/steps.py
+32
-11
32 additions, 11 deletions
src/pypelines/steps.py
with
36 additions
and
15 deletions
src/pypelines/__init__.py
+
1
−
1
View file @
15c67a0c
__version__
=
"
0.0.7
1
"
__version__
=
"
0.0.7
2
"
from
.
import
loggs
from
.
import
loggs
from
.pipes
import
*
from
.pipes
import
*
...
...
This diff is collapsed.
Click to expand it.
src/pypelines/pipes.py
+
3
−
3
View file @
15c67a0c
...
@@ -75,20 +75,20 @@ class BasePipe(BasePipeType, metaclass=ABCMeta):
...
@@ -75,20 +75,20 @@ class BasePipe(BasePipeType, metaclass=ABCMeta):
requires_is_step_attr
=
True
requires_is_step_attr
=
True
for
class_name
,
class_object
in
inspect
.
getmembers
(
self
,
predicate
=
inspect
.
isclass
):
for
class_name
,
class_object
in
inspect
.
getmembers
(
self
,
predicate
=
inspect
.
isclass
):
print
(
class_name
,
class_object
)
if
class_name
==
"
Steps
"
:
if
class_name
==
"
Steps
"
:
print
(
"
FOUND
"
)
steps_members_scanner
=
inspect
.
getmembers
(
class_object
(),
predicate
=
inspect
.
ismethod
)
steps_members_scanner
=
inspect
.
getmembers
(
class_object
(),
predicate
=
inspect
.
ismethod
)
requires_is_step_attr
=
False
requires_is_step_attr
=
False
break
break
# this loop populates self.steps dictionnary from the instanciated (bound) step methods.
# this loop populates self.steps dictionnary from the instanciated (bound) step methods.
for
step_name
,
step
in
steps_members_scanner
:
for
step_name
,
step
in
steps_members_scanner
:
print
(
"
step:
"
,
step_name
)
if
not
requires_is_step_attr
or
getattr
(
step
,
"
is_step
"
,
False
):
if
not
requires_is_step_attr
or
getattr
(
step
,
"
is_step
"
,
False
):
step_name
=
to_snake_case
(
step_name
)
step_name
=
to_snake_case
(
step_name
)
_steps
[
step_name
]
=
step
_steps
[
step_name
]
=
step
for
step_name
,
step
in
inspect
.
getmembers
(
self
,
predicate
=
inspect
.
isclass
):
if
if
len
(
_steps
)
<
1
:
if
len
(
_steps
)
<
1
:
raise
ValueError
(
raise
ValueError
(
f
"
You should register at least one step class with @stepmethod in
{
self
.
pipe_name
}
class.
{
_steps
=
}
"
f
"
You should register at least one step class with @stepmethod in
{
self
.
pipe_name
}
class.
{
_steps
=
}
"
...
...
This diff is collapsed.
Click to expand it.
src/pypelines/steps.py
+
32
−
11
View file @
15c67a0c
...
@@ -8,7 +8,7 @@ from pandas import DataFrame
...
@@ -8,7 +8,7 @@ from pandas import DataFrame
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
types
import
MethodType
from
types
import
MethodType
from
typing
import
Callable
,
Type
,
Iterable
,
Protocol
,
List
,
TYPE_CHECKING
,
Any
from
typing
import
Callable
,
Type
,
Iterable
,
Protocol
,
List
,
TYPE_CHECKING
,
Any
,
Optional
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
.pipelines
import
Pipeline
from
.pipelines
import
Pipeline
...
@@ -78,7 +78,9 @@ class BaseStep:
...
@@ -78,7 +78,9 @@ class BaseStep:
pipe
:
"
BasePipe
"
pipe
:
"
BasePipe
"
pipeline
:
"
Pipeline
"
pipeline
:
"
Pipeline
"
def
__init__
(
self
,
pipeline
:
"
Pipeline
"
,
pipe
:
"
BasePipe
"
,
worker
:
MethodType
,
step_name
:
str
=
""
):
def
__init__
(
self
,
pipeline
:
"
Pipeline
"
,
pipe
:
"
BasePipe
"
,
worker
:
Optional
[
MethodType
]
=
None
,
step_name
:
str
=
""
):
"""
Initialize a BaseStep object.
"""
Initialize a BaseStep object.
Args:
Args:
...
@@ -102,22 +104,37 @@ class BaseStep:
...
@@ -102,22 +104,37 @@ class BaseStep:
self
.
pipeline
=
pipeline
self
.
pipeline
=
pipeline
# save an instanciated access to the pipe parent
# save an instanciated access to the pipe parent
self
.
pipe
=
pipe
self
.
pipe
=
pipe
self
.
step_name
=
to_snake_case
(
self
.
get_attribute_or_default
(
"
step_name
"
,
step_name
))
if
not
self
.
step_name
:
raise
ValueError
(
f
"
Step name in
{
self
.
pipe
.
pipe_name
}
cannot be blank nor None
"
)
# save an instanciated access to the step function (undecorated)
# save an instanciated access to the step function (undecorated)
self
.
worker
=
worker
if
not
hasattr
(
self
,
"
worker
"
):
if
worker
is
None
:
raise
AttributeError
(
f
"
For the step :
{
self
.
pipe
.
pipe_name
}
.
{
self
.
step_name
}
, a worker method must
"
"
be defined if created from a class
"
)
needs_attachment
=
True
self
.
worker
=
worker
else
:
needs_attachment
=
False
# we attach the values of the worker elements to BaseStep
# we attach the values of the worker elements to BaseStep
# as they are get only (no setter) on worker (bound method)
# as they are get only (no setter) on worker (bound method)
self
.
do_dispatch
=
getattr
(
self
.
worker
,
"
do_dispatch
"
,
False
)
self
.
version
=
getattr
(
self
.
worker
,
"
version
"
,
0
)
self
.
requires
=
getattr
(
self
.
worker
,
"
requires
"
,
[])
self
.
step_name
=
to_snake_case
(
getattr
(
self
.
worker
,
"
step_name
"
,
step_name
))
if
not
self
.
step_name
:
getattr
(
self
,
"
do_dispatch
"
,
getattr
(
self
.
worker
,
"
do_dispatch
"
,
False
))
raise
ValueError
(
"
Step name cannot be blank nor None
"
)
self
.
callbacks
=
getattr
(
self
.
worker
,
"
callbacks
"
,
[])
self
.
do_dispatch
=
self
.
get_attribute_or_default
(
"
do_dispatch
"
,
False
)
self
.
version
=
self
.
get_attribute_or_default
(
"
version
"
,
0
)
self
.
requires
=
self
.
get_attribute_or_default
(
"
requires
"
,
[])
self
.
worker
=
MethodType
(
worker
.
__func__
,
self
)
self
.
callbacks
=
self
.
get_attribute_or_default
(
"
callbacks
"
,
[])
if
needs_attachment
:
self
.
worker
=
MethodType
(
worker
.
__func__
,
self
)
# self.make_wrapped_functions()
# self.make_wrapped_functions()
...
@@ -128,6 +145,10 @@ class BaseStep:
...
@@ -128,6 +145,10 @@ class BaseStep:
self
.
task
=
self
.
pipeline
.
runner_backend
.
create_task_manager
(
self
)
self
.
task
=
self
.
pipeline
.
runner_backend
.
create_task_manager
(
self
)
def
get_attribute_or_default
(
self
,
attribute_name
:
str
,
default
:
Any
)
->
Any
:
# TODO : fix here , when calling get_attribute_or_default before worker s set, cannot work
return
getattr
(
self
,
attribute_name
,
getattr
(
self
.
worker
,
attribute_name
,
default
))
@property
@property
def
requirement_stack
(
self
)
->
Callable
:
def
requirement_stack
(
self
)
->
Callable
:
"""
Return a partial function that calls the get_requirement_stack method of the pipeline
"""
Return a partial function that calls the get_requirement_stack method of the pipeline
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment