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
7385b4e9
Commit
7385b4e9
authored
2 years ago
by
Martin Lange
Browse files
Options
Downloads
Patches
Plain Diff
implement the info transfer
parent
31c3079f
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
+43
-3
43 additions, 3 deletions
src/finam/tools/connect_helper.py
with
43 additions
and
3 deletions
src/finam/tools/connect_helper.py
+
43
−
3
View file @
7385b4e9
...
@@ -3,10 +3,15 @@ import logging
...
@@ -3,10 +3,15 @@ import logging
from
finam.interfaces
import
ComponentStatus
,
Loggable
from
finam.interfaces
import
ComponentStatus
,
Loggable
from
..data.tools
import
Info
from
..errors
import
FinamNoDataError
from
..errors
import
FinamNoDataError
from
..tools.log_helper
import
ErrorLogger
from
..tools.log_helper
import
ErrorLogger
class
MissingInfoError
(
Exception
):
"""
Internal error type for handling missing infos for transfer rules
"""
class
InfoSource
:
class
InfoSource
:
def
__init__
(
self
,
name
,
*
fields
):
def
__init__
(
self
,
name
,
*
fields
):
self
.
name
=
name
self
.
name
=
name
...
@@ -71,9 +76,6 @@ class ConnectHelper(Loggable):
...
@@ -71,9 +76,6 @@ 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
:
...
@@ -93,12 +95,34 @@ class ConnectHelper(Loggable):
...
@@ -93,12 +95,34 @@ 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
.
_in_info_rules
=
in_info_rules
or
{}
self
.
_out_info_rules
=
out_info_rules
or
{}
self
.
_check_info_rules
()
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
_apply_rules
(
self
,
rules
):
info
=
Info
(
time
=
None
,
grid
=
None
)
for
rule
in
rules
:
if
isinstance
(
rule
,
FromInput
):
in_info
=
self
.
in_infos
[
rule
.
name
]
if
in_info
is
None
:
raise
MissingInfoError
()
for
field
in
rule
.
fields
:
info
.
__setattr__
(
field
,
in_info
.
__getattr__
(
field
))
elif
isinstance
(
rule
,
FromOutput
):
out_info
=
self
.
out_infos
[
rule
.
name
]
if
out_info
is
None
:
raise
MissingInfoError
()
for
field
in
rule
.
fields
:
info
.
__setattr__
(
field
,
out_info
.
__getattr__
(
field
))
elif
isinstance
(
rule
,
FromValue
):
info
.
__setattr__
(
field
,
rule
.
value
)
return
info
def
_check_info_rules
(
self
):
def
_check_info_rules
(
self
):
for
name
,
rules
in
self
.
_in_info_rules
.
items
():
for
name
,
rules
in
self
.
_in_info_rules
.
items
():
if
name
not
in
self
.
_inputs
:
if
name
not
in
self
.
_inputs
:
...
@@ -216,6 +240,22 @@ class ConnectHelper(Loggable):
...
@@ -216,6 +240,22 @@ class ConnectHelper(Loggable):
push_infos
=
{
k
:
v
for
k
,
v
in
push_infos
.
items
()
if
self
.
out_infos
[
k
]
is
None
}
push_infos
=
{
k
:
v
for
k
,
v
in
push_infos
.
items
()
if
self
.
out_infos
[
k
]
is
None
}
push_data
=
{
k
:
v
for
k
,
v
in
push_data
.
items
()
if
not
self
.
data_pushed
[
k
]}
push_data
=
{
k
:
v
for
k
,
v
in
push_data
.
items
()
if
not
self
.
data_pushed
[
k
]}
for
name
,
rules
in
self
.
_in_info_rules
.
items
():
if
self
.
in_infos
[
name
]
is
None
and
name
not
in
self
.
_in_info_cache
:
try
:
info
=
self
.
_apply_rules
(
rules
)
exchange_infos
[
name
]
=
info
except
MissingInfoError
:
pass
for
name
,
rules
in
self
.
_out_info_rules
.
items
():
if
self
.
out_infos
[
name
]
is
None
and
name
not
in
self
.
_out_info_cache
:
try
:
info
=
self
.
_apply_rules
(
rules
)
push_infos
[
name
]
=
info
except
MissingInfoError
:
pass
if
self
.
_cache
:
if
self
.
_cache
:
self
.
_in_info_cache
.
update
(
exchange_infos
)
self
.
_in_info_cache
.
update
(
exchange_infos
)
self
.
_out_info_cache
.
update
(
push_infos
)
self
.
_out_info_cache
.
update
(
push_infos
)
...
...
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