Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bo Zhang
csst
Commits
b959fa81
Commit
b959fa81
authored
Mar 31, 2022
by
BO ZHANG
🏀
Browse files
updated processor module
parent
7e6af829
Changes
1
Show whitespace changes
Inline
Side-by-side
csst/core/processor.py
View file @
b959fa81
from
abc
import
ABCMeta
,
abstractmethod
from
abc
import
ABC
,
ABCMeta
,
abstractmethod
from
enum
import
Enum
...
...
@@ -8,26 +8,52 @@ class CsstProcStatus(Enum):
ioerror
=
1
runtimeerror
=
2
# self['empty'].info = 'Not run yet.'
# self['normal'].info = 'This is a normal run.'
# self['ioerror'].info = 'This run is exceptionally stopped due to IO error.'
# self['runtimeerror'].info = 'This run is exceptionally stopped due to runtime error.'
class
CsstProcessor
(
metaclass
=
ABCMeta
):
class
CsstProcessor
(
ABC
):
def
__init__
(
self
,
**
kwargs
):
self
.
_status
=
CsstProcStatus
()
# self._status = CsstProcStatus()
pass
@
abstractmethod
def
prepare
(
self
,
**
kwargs
):
pass
# do your preparation here
raise
NotImplementedError
@
abstractmethod
def
run
(
self
,
kwargs
):
""" """
r
eturn
self
.
_status
def
run
(
self
,
**
kwargs
):
# run your pipeline
r
aise
NotImplementedError
@
abstractmethod
def
cleanup
(
self
):
pass
# clean up environment
raise
NotImplementedError
class
CsstDemoProcessor
(
CsstProcessor
):
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
()
def
some_function
(
self
,
**
kwargs
):
print
(
"some function"
)
def
prepare
(
self
):
print
(
"prepare"
)
def
run
(
self
):
print
(
"run"
)
def
cleanup
(
self
):
print
(
"clear up"
)
if
__name__
==
"__main__"
:
cp
=
CsstDemoProcessor
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment