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
653dc393
Commit
653dc393
authored
6 years ago
by
James Johnson
Browse files
Options
Downloads
Patches
Plain Diff
updated key-value pairs, added tests which call traits_to_dict
parent
7f4ba93b
No related branches found
No related tags found
1 merge request
!152
Removed __traits_version__ from json files
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
force_bdss/io/tests/test_workflow_writer.py
+13
-1
13 additions, 1 deletion
force_bdss/io/tests/test_workflow_writer.py
force_bdss/io/workflow_writer.py
+5
-5
5 additions, 5 deletions
force_bdss/io/workflow_writer.py
with
18 additions
and
6 deletions
force_bdss/io/tests/test_workflow_writer.py
+
13
−
1
View file @
653dc393
...
...
@@ -16,6 +16,7 @@ from force_bdss.tests.dummy_classes.factory_registry_plugin import \
from
force_bdss.io.workflow_writer
import
WorkflowWriter
,
traits_to_dict
,
\
pop_recursive
from
force_bdss.core.workflow
import
Workflow
from
force_bdss.core.input_slot_info
import
InputSlotInfo
class
TestWorkflowWriter
(
unittest
.
TestCase
):
...
...
@@ -89,7 +90,18 @@ class TestWorkflowWriter(unittest.TestCase):
self
.
assertEqual
(
traits_to_dict
(
mock_traits
),
{
"
foo
"
:
"
bar
"
})
def
test_pop_recursive
(
self
):
def
test_traits_to_dict
(
self
):
wfwriter
=
WorkflowWriter
()
wf
=
self
.
_create_workflow
()
exec_layer
=
wf
.
execution_layers
[
0
]
exec_layer
.
data_sources
[
0
].
input_slot_info
=
[
InputSlotInfo
()]
slotdata
=
exec_layer
.
data_sources
[
0
].
input_slot_info
[
0
].
__getstate__
()
self
.
assertTrue
(
"
__traits_version__
"
in
slotdata
)
# Calls traits_to_dict for each data source
datastore_list
=
wfwriter
.
_execution_layer_data
(
exec_layer
)
new_slotdata
=
datastore_list
[
0
][
'
model_data
'
][
'
input_slot_info
'
]
self
.
assertTrue
(
"
__traits_version__
"
not
in
new_slotdata
)
test_dictionary
=
{
'
K1
'
:
{
'
K1
'
:
'
V1
'
,
'
K2
'
:
'
V2
'
,
'
K3
'
:
'
V3
'
},
'
K2
'
:
[
'
V1
'
,
'
V2
'
,
{
'
K1
'
:
'
V1
'
,
'
K2
'
:
'
V2
'
,
...
...
This diff is collapsed.
Click to expand it.
force_bdss/io/workflow_writer.py
+
5
−
5
View file @
653dc393
...
...
@@ -108,14 +108,14 @@ def pop_recursive(dictionary, remove_key):
except
KeyError
:
pass
for
key
in
dictionary
:
for
key
,
value
in
dictionary
.
items
()
:
# If remove_key is in the dict, remove it
if
isinstance
(
dictionary
[
key
]
,
dict
):
pop_recursive
(
dictionary
[
key
]
,
remove_key
)
if
isinstance
(
value
,
dict
):
pop_recursive
(
value
,
remove_key
)
# If we have a non-dict iterable which contains a dict,
# call pop.(remove_key) from that as well
elif
isinstance
(
dictionary
[
key
],
Iterable
):
for
element
in
dictionary
[
key
]
:
elif
isinstance
(
value
,
(
tuple
,
list
)
):
for
element
in
value
:
if
isinstance
(
element
,
dict
):
pop_recursive
(
element
,
remove_key
)
...
...
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