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
a4194c49
Commit
a4194c49
authored
11 months ago
by
Timothe Jost
Browse files
Options
Downloads
Patches
Plain Diff
run callback got improved : ability to be dispatched or not
parent
466aa690
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#131867
passed
11 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pypelines/__init__.py
+1
-1
1 addition, 1 deletion
src/pypelines/__init__.py
src/pypelines/steps.py
+31
-26
31 additions, 26 deletions
src/pypelines/steps.py
with
32 additions
and
27 deletions
src/pypelines/__init__.py
+
1
−
1
View file @
a4194c49
__version__
=
"
0.0.6
2
"
__version__
=
"
0.0.6
3
"
from
.
import
loggs
from
.
import
loggs
from
.pipes
import
*
from
.pipes
import
*
...
...
This diff is collapsed.
Click to expand it.
src/pypelines/steps.py
+
31
−
26
View file @
a4194c49
...
@@ -188,10 +188,9 @@ class BaseStep:
...
@@ -188,10 +188,9 @@ class BaseStep:
"""
Return the result of calling the get_generate_wrapped method.
"""
"""
Return the result of calling the get_generate_wrapped method.
"""
return
self
.
get_generate_wrapped
()
return
self
.
get_generate_wrapped
()
# def make_wrapped_functions(self):
@property
# self.save = self.make_wrapped_save()
def
run_callbacks
(
self
):
# self.load = self.make_wrapped_load()
return
self
.
get_run_callbacks
()
# self.generate = self.make_wrapped_generate()
def
get_save_wrapped
(
self
):
def
get_save_wrapped
(
self
):
"""
Returns a wrapped function that saves data using the disk class.
"""
Returns a wrapped function that saves data using the disk class.
...
@@ -288,6 +287,33 @@ class BaseStep:
...
@@ -288,6 +287,33 @@ class BaseStep:
)
)
return
autoload_arguments
(
loggedmethod
(
self
.
generation_mechanism
),
self
)
return
autoload_arguments
(
loggedmethod
(
self
.
generation_mechanism
),
self
)
def
get_run_callbacks
(
self
):
def
wrapper
(
session
,
extra
=
""
,
show_plots
=
True
):
logger
=
logging
.
getLogger
(
"
callback_runner
"
)
for
callback_data
in
self
.
callbacks
:
arguments
=
{
"
session
"
:
session
,
"
extra
"
:
extra
,
"
pipeline
"
:
self
.
pipeline
}
if
isinstance
(
callback_data
,
tuple
):
callback
=
callback_data
[
0
]
overriding_arguments
=
callback_data
[
1
]
else
:
callback
=
callback_data
overriding_arguments
=
{}
arguments
.
update
(
overriding_arguments
)
on_what
=
f
"
{
session
.
alias
}
.
{
extra
}
"
if
extra
else
session
.
alias
try
:
logger
.
info
(
f
"
Running the callback
{
callback
.
__name__
}
on
{
on_what
}
"
)
callback
(
**
arguments
)
except
Exception
as
e
:
import
traceback
traceback_msg
=
traceback
.
format_exc
()
logger
.
error
(
f
"
The callback
{
callback
}
failed with error :
{
e
}
"
)
logger
.
error
(
f
"
Full traceback below :
\n
{
traceback_msg
}
"
)
if
self
.
do_dispatch
:
return
self
.
pipe
.
dispatcher
(
wrapper
,
"
callbacks
"
)
return
wrapper
def
get_level
(
self
,
selfish
=
False
)
->
int
:
def
get_level
(
self
,
selfish
=
False
)
->
int
:
"""
Get the level of the step.
"""
Get the level of the step.
...
@@ -521,7 +547,7 @@ class BaseStep:
...
@@ -521,7 +547,7 @@ class BaseStep:
if
save_output
:
if
save_output
:
logger
.
save
(
f
"
Saving the generated
{
self
.
relative_name
}{
'
.
'
+
extra
if
extra
else
''
}
output.
"
)
logger
.
save
(
f
"
Saving the generated
{
self
.
relative_name
}{
'
.
'
+
extra
if
extra
else
''
}
output.
"
)
disk_object
.
save
(
result
)
disk_object
.
save
(
result
)
self
.
run_callbacks
(
session
,
extra
,
show_plots
=
False
)
self
.
run_callbacks
(
session
,
extra
=
extra
,
show_plots
=
False
)
return
result
return
result
...
@@ -555,27 +581,6 @@ class BaseStep:
...
@@ -555,27 +581,6 @@ class BaseStep:
return
wrapper
return
wrapper
def
run_callbacks
(
self
,
session
,
extra
=
""
,
show_plots
=
True
)
->
None
:
logger
=
logging
.
getLogger
(
"
callback_runner
"
)
for
callback_data
in
self
.
callbacks
:
arguments
=
{
"
session
"
:
session
,
"
extra
"
:
extra
,
"
pipeline
"
:
self
.
pipeline
}
if
isinstance
(
callback_data
,
tuple
):
callback
=
callback_data
[
0
]
overriding_arguments
=
callback_data
[
1
]
else
:
callback
=
callback_data
overriding_arguments
=
{}
arguments
.
update
(
overriding_arguments
)
try
:
logger
.
info
(
f
"
Running the callback
{
callback
.
__name__
}
"
)
callback
(
**
arguments
)
except
Exception
as
e
:
import
traceback
traceback_msg
=
traceback
.
format_exc
()
logger
.
error
(
f
"
The callback
{
callback
}
failed with error :
{
e
}
"
)
logger
.
error
(
"
Full traceback below :
\n
"
+
traceback_msg
)
def
generate_doc
(
self
)
->
str
:
def
generate_doc
(
self
)
->
str
:
"""
Generate a new docstring by inserting a chapter about Pipeline Args before the existing
"""
Generate a new docstring by inserting a chapter about Pipeline Args before the existing
docstring of the function.
docstring of the function.
...
...
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