Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
force-bdss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adham Hashibon
force-bdss
Commits
c8118126
Commit
c8118126
authored
7 years ago
by
Stefano Borini
Browse files
Options
Downloads
Patches
Plain Diff
Introduced data matching
parent
4a5104a7
No related branches found
No related tags found
1 merge request
!69
Introduce slots and resolution of named variables
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
force_bdss/core_evaluation_driver.py
+83
-2
83 additions, 2 deletions
force_bdss/core_evaluation_driver.py
with
83 additions
and
2 deletions
force_bdss/core_evaluation_driver.py
+
83
−
2
View file @
c8118126
...
@@ -31,18 +31,99 @@ class CoreEvaluationDriver(BaseCoreDriver):
...
@@ -31,18 +31,99 @@ class CoreEvaluationDriver(BaseCoreDriver):
mco_bundle
=
mco_model
.
bundle
mco_bundle
=
mco_model
.
bundle
mco_communicator
=
mco_bundle
.
create_communicator
()
mco_communicator
=
mco_bundle
.
create_communicator
()
# Receives the data from the MCO. These are technically unnamed.
# The names are then assigned. Order is important
mco_data_values
=
mco_communicator
.
receive_from_mco
(
mco_model
)
mco_data_values
=
mco_communicator
.
receive_from_mco
(
mco_model
)
if
len
(
mco_data_values
)
!=
len
(
mco_model
.
parameters
):
raise
RuntimeError
(
"
The number of data values returned by
"
"
the MCO does not match the number of
"
"
parameters specified. This is likely a
"
"
MCO plugin error.
"
)
# Assign the name to the data value that was emitted.
for
dv
,
param
in
zip
(
mco_data_values
,
mco_model
.
parameters
):
dv
.
name
=
param
.
name
ds_results
=
[]
ds_results
=
[]
for
ds_model
in
workflow
.
data_sources
:
for
ds_model
in
workflow
.
data_sources
:
ds_bundle
=
ds_model
.
bundle
ds_bundle
=
ds_model
.
bundle
data_source
=
ds_bundle
.
create_data_source
()
data_source
=
ds_bundle
.
create_data_source
()
ds_results
.
extend
(
data_source
.
run
(
ds_model
,
mco_data_values
))
in_slots
,
out_slots
=
data_source
.
slots
(
ds_model
)
passed_data_values
=
self
.
_bind_data_values
(
mco_data_values
,
ds_model
.
input_slot_maps
,
in_slots
)
res
=
data_source
.
run
(
ds_model
,
passed_data_values
)
if
len
(
res
)
!=
len
(
out_slots
):
raise
RuntimeError
(
"
The number of data values returned by
"
"
the DataSource does not match the number
"
"
of parameters specified. This is likely a
"
"
DataSource plugin error.
"
)
if
len
(
res
)
!=
len
(
ds_model
.
output_slot_names
):
raise
RuntimeError
(
"
The number of data values returned by
"
"
the DataSource does not match the number
"
"
of names specified. This is either an
"
"
input file error or a plugin error.
"
)
for
dv
,
output_slot_name
in
zip
(
res
,
ds_model
.
output_slot_names
):
dv
.
name
=
output_slot_name
ds_results
.
extend
(
res
)
kpi_results
=
[]
kpi_results
=
[]
for
kpic_model
in
workflow
.
kpi_calculators
:
for
kpic_model
in
workflow
.
kpi_calculators
:
kpic_bundle
=
kpic_model
.
bundle
kpic_bundle
=
kpic_model
.
bundle
kpi_calculator
=
kpic_bundle
.
create_kpi_calculator
()
kpi_calculator
=
kpic_bundle
.
create_kpi_calculator
()
kpi_results
.
extend
(
kpi_calculator
.
run
(
kpic_model
,
ds_results
))
in_slots
,
out_slots
=
kpi_calculator
.
slots
(
kpic_model
)
passed_data_values
=
self
.
_bind_data_values
(
mco_data_values
+
ds_results
,
kpic_model
.
input_slot_maps
,
in_slots
)
res
=
kpi_calculator
.
run
(
kpic_model
,
passed_data_values
)
if
len
(
res
)
!=
len
(
out_slots
):
raise
RuntimeError
(
"
The number of data values returned by
"
"
the KPICalculator does not match the
"
"
number of parameters specified. This is
"
"
likely a KPICalculator plugin error.
"
)
if
len
(
res
)
!=
len
(
kpic_model
.
output_slot_names
):
raise
RuntimeError
(
"
The number of data values returned by
"
"
the KPICalculator does not match the
"
"
number of names specified. This is
"
"
either an input file error or a plugin
"
"
error.
"
)
for
kpi
,
output_slot_name
in
zip
(
res
,
kpic_model
.
output_slot_names
):
kpi
.
name
=
output_slot_name
kpi_results
.
extend
(
res
)
mco_communicator
.
send_to_mco
(
mco_model
,
kpi_results
)
mco_communicator
.
send_to_mco
(
mco_model
,
kpi_results
)
def
_bind_data_values
(
self
,
available_data_values
,
model_slot_map
,
slots
):
passed_data_values
=
[]
lookup_map
=
{
dv
.
name
:
dv
for
dv
in
available_data_values
}
if
len
(
slots
)
>
len
(
model_slot_map
):
raise
RuntimeError
(
"
The length of the slots is greater than
"
"
the length of the slot map. This may
"
"
indicate a file error
"
)
for
slot
,
slot_map
in
zip
(
slots
,
model_slot_map
):
passed_data_values
.
append
(
lookup_map
[
slot_map
.
name
])
return
passed_data_values
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