Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam
Manage
Activity
Members
Labels
Plan
Issues
31
Issue boards
Milestones
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FINAM
finam
Commits
d4b109ce
Commit
d4b109ce
authored
2 years ago
by
Sebastian Müller
🐈
Browse files
Options
Downloads
Patches
Plain Diff
Component: don't require to overwrite _validate or _finalize
parent
8db78a62
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!156
Component: don't require to overwrite _validate or _finalize
Pipeline
#126286
passed with stages
Stage: test
Stage: build
in 2 minutes and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/finam/sdk/component.py
+4
-8
4 additions, 8 deletions
src/finam/sdk/component.py
tests/core/test_sdk.py
+17
-4
17 additions, 4 deletions
tests/core/test_sdk.py
with
21 additions
and
12 deletions
src/finam/sdk/component.py
+
4
−
8
View file @
d4b109ce
...
...
@@ -116,11 +116,9 @@ class Component(IComponent, Loggable, ABC):
def
_validate
(
self
):
"""
Validate the correctness of the component
'
s settings and coupling.
Components
must
overwrite this method.
Components
should
overwrite this method.
"""
raise
NotImplementedError
(
f
"
Method `_validate` must be implemented by all components, but implementation is missing in
{
self
.
name
}
.
"
)
self
.
logger
.
debug
(
"
Method `_validate` not implemented by user.
"
)
@final
def
update
(
self
):
...
...
@@ -163,11 +161,9 @@ class Component(IComponent, Loggable, ABC):
def
_finalize
(
self
):
"""
Finalize and clean up the component.
Components
must
overwrite this method.
Components
should
overwrite this method.
"""
raise
NotImplementedError
(
f
"
Method `_finalize` must be implemented by all components, but implementation is missing in
{
self
.
name
}
.
"
)
self
.
logger
.
debug
(
"
Method `_finalize` not implemented by user.
"
)
@property
def
inputs
(
self
):
...
...
This diff is collapsed.
Click to expand it.
tests/core/test_sdk.py
+
17
−
4
View file @
d4b109ce
"""
Unit tests for the sdk implementations.
"""
import
logging
import
unittest
from
datetime
import
datetime
...
...
@@ -466,20 +467,32 @@ class TestNotImplemented(unittest.TestCase):
with
self
.
assertRaises
(
NotImplementedError
):
comp
.
_connect
()
with
self
.
assertRaises
(
NotImplementedError
):
# check that the debug log for not implementing _validate is there
with
self
.
assertLogs
(
level
=
logging
.
DEBUG
)
as
captured
:
comp
.
validate
()
with
self
.
assertRaises
(
NotImplementedError
):
self
.
assertEqual
(
len
(
captured
.
records
),
2
)
self
.
assertEqual
(
captured
.
records
[
0
].
levelno
,
logging
.
DEBUG
)
self
.
assertEqual
(
captured
.
records
[
1
].
levelno
,
logging
.
DEBUG
)
with
self
.
assertLogs
(
level
=
logging
.
DEBUG
)
as
captured
:
comp
.
_validate
()
self
.
assertEqual
(
len
(
captured
.
records
),
1
)
self
.
assertEqual
(
captured
.
records
[
0
].
levelno
,
logging
.
DEBUG
)
with
self
.
assertRaises
(
NotImplementedError
):
comp
.
update
()
with
self
.
assertRaises
(
NotImplementedError
):
comp
.
_update
()
with
self
.
assertRaises
(
NotImplementedError
):
# check that the debug log for not implementing _finalize is there
with
self
.
assertLogs
(
level
=
logging
.
DEBUG
)
as
captured
:
comp
.
finalize
()
with
self
.
assertRaises
(
NotImplementedError
):
self
.
assertEqual
(
len
(
captured
.
records
),
2
)
self
.
assertEqual
(
captured
.
records
[
0
].
levelno
,
logging
.
DEBUG
)
self
.
assertEqual
(
captured
.
records
[
1
].
levelno
,
logging
.
DEBUG
)
with
self
.
assertLogs
(
level
=
logging
.
DEBUG
)
as
captured
:
comp
.
_finalize
()
self
.
assertEqual
(
len
(
captured
.
records
),
1
)
self
.
assertEqual
(
captured
.
records
[
0
].
levelno
,
logging
.
DEBUG
)
def
test_adapter_not_implemented
(
self
):
adapter
=
NotImplAdapter
()
...
...
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