Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BluePyMM
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BlueBrain
BluePyMM
Commits
602a3f57
Unverified
Commit
602a3f57
authored
Jun 23, 2020
by
Werner Alfons Hilda Van Geit
Committed by
GitHub
Jun 23, 2020
Browse files
Options
Downloads
Plain Diff
Merge pull request #198 from arnaudon/recipe_yaml
Yaml loader for recipes
parents
8756ab0e
ce307a02
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bluepymm/prepare_combos/parse_files.py
+47
-0
47 additions, 0 deletions
bluepymm/prepare_combos/parse_files.py
with
47 additions
and
0 deletions
bluepymm/prepare_combos/parse_files.py
+
47
−
0
View file @
602a3f57
...
...
@@ -27,6 +27,7 @@ Copyright (c) 2018, EPFL/Blue Brain Project
import
pandas
import
re
import
os
import
lxml
import
lxml.etree
...
...
@@ -92,6 +93,52 @@ def read_mm_recipe(recipe_filename):
"""
Read a BBP builder recipe and return a pandas.DataFrame with all
possible (layer, m-type, e-type)-combinations.
Args:
recipe_filename(str): filename of recipe (XML/YAML)
Returns:
A pandas.DataFrame with fields
"
layer
"
,
"
fullmtype
"
, and
"
etype
"
.
"""
if
os
.
path
.
splitext
(
recipe_filename
)[
1
]
==
'
.xml
'
:
return
read_mm_recipe_xml
(
recipe_filename
)
elif
os
.
path
.
splitext
(
recipe_filename
)[
1
]
==
'
.yaml
'
:
return
read_mm_recipe_yaml
(
recipe_filename
)
else
:
raise
Exception
(
'
Please provide an .xml or .yaml as recipe file
'
)
def
read_mm_recipe_yaml
(
recipe_filename
):
"""
Read a BBP builder recipe and return a pandas.DataFrame with all
possible (layer, m-type, e-type)-combinations.
Args:
recipe_filename(str): filename of recipe (YAML)
Returns:
A pandas.DataFrame with fields
"
layer
"
,
"
fullmtype
"
, and
"
etype
"
.
"""
import
yaml
with
open
(
recipe_filename
,
'
r
'
)
as
f
:
recipe
=
yaml
.
safe_load
(
f
)
if
recipe
[
'
version
'
]
not
in
(
'
v2.0
'
,):
raise
Exception
(
'
Only v2.0 of recipe yaml files are supported
'
)
mecombos
=
pandas
.
DataFrame
(
columns
=
[
"
layer
"
,
"
fullmtype
"
,
"
etype
"
])
for
region
in
recipe
[
'
neurons
'
]:
for
etype
in
region
[
'
traits
'
][
'
etype
'
].
keys
():
n_combos
=
len
(
mecombos
)
mecombos
.
loc
[
n_combos
,
'
layer
'
]
=
region
[
'
traits
'
][
'
layer
'
]
mecombos
.
loc
[
n_combos
,
'
fullmtype
'
]
=
region
[
'
traits
'
][
'
mtype
'
]
mecombos
.
loc
[
n_combos
,
'
etype
'
]
=
etype
return
mecombos
def
read_mm_recipe_xml
(
recipe_filename
):
"""
Read a BBP builder recipe and return a pandas.DataFrame with all
possible (layer, m-type, e-type)-combinations.
Args:
recipe_filename(str): filename of recipe (XML)
...
...
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
sign in
to comment