Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alibylite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Swain Lab
aliby
alibylite
Commits
0a888621
Commit
0a888621
authored
3 years ago
by
Alán Muñoz
Browse files
Options
Downloads
Patches
Plain Diff
add abc file
parent
050ba03a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/abc.py
+41
-0
41 additions, 0 deletions
core/abc.py
with
41 additions
and
0 deletions
core/abc.py
0 → 100644
+
41
−
0
View file @
0a888621
#!/usr/bin/env python3
from
pydoc
import
locate
from
agora.abc
import
ProcessABC
class
PostProcessABC
(
ProcessABC
):
"""
Extend ProcessABC to add as_function, allowing for all PostProcesses to be called as functions
almost directly.
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
()
@classmethod
def
as_function
(
cls
,
data
,
*
args
,
**
kwargs
):
# Find the parameter's default
parameters
=
get_parameters
(
cls
.
__name__
).
default
(
*
args
,
**
kwargs
)
return
cls
(
parameters
=
parameters
).
run
(
data
)
def
get_process
(
process
,
suffix
=
""
):
"""
Dynamically import a process class from the
'
processes
'
folder.
Assumes process filename and class name are the same
"""
location
=
f
"
postprocessor.core.processes.
{
process
}
.
{
process
}{
suffix
}
"
found
=
locate
(
location
)
if
found
==
None
:
raise
Exception
(
f
"
{
location
}
not found
"
)
return
found
def
get_parameters
(
self
,
process
):
"""
Dynamically import parameters from the
'
processes
'
folder.
Assumes parameter is the same name as the file with
'
Parameters
'
added at the end.
"""
return
get_process
(
process
,
suffix
=
"
Parameters
"
)
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