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
31c3079f
Commit
31c3079f
authored
2 years ago
by
Martin Lange
Browse files
Options
Downloads
Patches
Plain Diff
create infotransfer rule classes, add to connect helper, check them
parent
9908d612
No related branches found
No related tags found
1 merge request
!154
Auto-transfer infos
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/finam/tools/connect_helper.py
+60
-0
60 additions, 0 deletions
src/finam/tools/connect_helper.py
with
60 additions
and
0 deletions
src/finam/tools/connect_helper.py
+
60
−
0
View file @
31c3079f
...
@@ -7,6 +7,28 @@ from ..errors import FinamNoDataError
...
@@ -7,6 +7,28 @@ from ..errors import FinamNoDataError
from
..tools.log_helper
import
ErrorLogger
from
..tools.log_helper
import
ErrorLogger
class
InfoSource
:
def
__init__
(
self
,
name
,
*
fields
):
self
.
name
=
name
self
.
fields
=
fields
class
FromInput
(
InfoSource
):
def
__init__
(
self
,
name
,
*
fields
):
super
().
__init__
(
name
,
fields
)
class
FromOutput
(
InfoSource
):
def
__init__
(
self
,
name
,
*
fields
):
super
().
__init__
(
name
,
fields
)
class
FromValue
:
def
__init__
(
self
,
field
,
value
):
self
.
field
=
field
self
.
value
=
value
class
ConnectHelper
(
Loggable
):
class
ConnectHelper
(
Loggable
):
"""
Helper for iterative connect.
"""
Helper for iterative connect.
...
@@ -22,6 +44,10 @@ class ConnectHelper(Loggable):
...
@@ -22,6 +44,10 @@ class ConnectHelper(Loggable):
All inputs of the component.
All inputs of the component.
outputs : dict
outputs : dict
All outputs of the component.
All outputs of the component.
in_info_rules : dict
Info transfer rules for inputs.
out_info_rules : dict
Info transfer rules for outputs.
pull_data : arraylike
pull_data : arraylike
Names of the inputs that are to be pulled.
Names of the inputs that are to be pulled.
cache : bool
cache : bool
...
@@ -35,6 +61,8 @@ class ConnectHelper(Loggable):
...
@@ -35,6 +61,8 @@ class ConnectHelper(Loggable):
inputs
,
inputs
,
outputs
,
outputs
,
pull_data
=
None
,
pull_data
=
None
,
in_info_rules
=
None
,
out_info_rules
=
None
,
cache
=
True
,
cache
=
True
,
):
):
...
@@ -43,6 +71,9 @@ class ConnectHelper(Loggable):
...
@@ -43,6 +71,9 @@ class ConnectHelper(Loggable):
self
.
_outputs
=
outputs
self
.
_outputs
=
outputs
self
.
_cache
=
cache
self
.
_cache
=
cache
self
.
_in_info_rules
=
in_info_rules
or
{}
self
.
_out_info_rules
=
in_info_rules
or
{}
with
ErrorLogger
(
self
.
logger
):
with
ErrorLogger
(
self
.
logger
):
for
name
in
pull_data
or
[]:
for
name
in
pull_data
or
[]:
if
name
not
in
self
.
_inputs
:
if
name
not
in
self
.
_inputs
:
...
@@ -62,10 +93,39 @@ class ConnectHelper(Loggable):
...
@@ -62,10 +93,39 @@ class ConnectHelper(Loggable):
name
:
False
for
name
,
out
in
self
.
outputs
.
items
()
if
out
.
needs_push
name
:
False
for
name
,
out
in
self
.
outputs
.
items
()
if
out
.
needs_push
}
}
self
.
_check_info_rules
()
self
.
_in_info_cache
=
{}
self
.
_in_info_cache
=
{}
self
.
_out_info_cache
=
{}
self
.
_out_info_cache
=
{}
self
.
_out_data_cache
=
{}
self
.
_out_data_cache
=
{}
def
_check_info_rules
(
self
):
for
name
,
rules
in
self
.
_in_info_rules
.
items
():
if
name
not
in
self
.
_inputs
:
raise
ValueError
(
f
"
No input named
'
{
name
}
'
to apply info transfer rule.
"
)
for
rule
in
rules
:
self
.
_check_rule
(
rule
)
for
name
,
rules
in
self
.
_out_info_rules
.
items
():
if
name
not
in
self
.
_outputs
:
raise
ValueError
(
f
"
No output named
'
{
name
}
'
to apply info transfer rule.
"
)
for
rule
in
rules
:
self
.
_check_rule
(
rule
)
def
_check_rule
(
self
,
rule
):
if
isinstance
(
rule
,
FromInput
)
and
rule
.
name
not
in
self
.
_inputs
:
raise
ValueError
(
f
"
No input named
'
{
rule
.
name
}
'
to use in info transfer rule.
"
)
if
isinstance
(
rule
,
FromOutput
)
and
rule
.
name
not
in
self
.
_inputs
:
raise
ValueError
(
f
"
No output named
'
{
rule
.
name
}
'
to use in info transfer rule.
"
)
@property
@property
def
logger
(
self
):
def
logger
(
self
):
"""
Logger for this component.
"""
"""
Logger for this component.
"""
...
...
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