Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dayabay-model
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
dayabay-data-preservation
dayabay-model
Commits
f563d32b
Commit
f563d32b
authored
1 year ago
by
Maxim Gonchar
Browse files
Options
Downloads
Plain Diff
Merge commit '
5180dd6f
'
parents
08aeef8b
5180dd6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
subtrees/dagflow/dagflow/bundles/load_parameters.py
+13
-13
13 additions, 13 deletions
subtrees/dagflow/dagflow/bundles/load_parameters.py
subtrees/dagflow/test/variables/test_load_variables.py
+12
-12
12 additions, 12 deletions
subtrees/dagflow/test/variables/test_load_variables.py
with
25 additions
and
25 deletions
subtrees/dagflow/dagflow/bundles/load_
v
ar
iable
s.py
→
subtrees/dagflow/dagflow/bundles/load_
p
ar
ameter
s.py
+
13
−
13
View file @
f563d32b
...
...
@@ -15,7 +15,7 @@ class ParsCfgHasProperFormat(object):
nelements
=
len
(
format
)
dtin
=
DictWrapper
(
data
)
for
key
,
subdata
in
dtin
[
'
v
ar
iable
s
'
].
walkitems
():
for
key
,
subdata
in
dtin
[
'
p
ar
ameter
s
'
].
walkitems
():
if
isinstance
(
subdata
,
tuple
):
if
len
(
subdata
)
==
nelements
:
continue
else
:
...
...
@@ -27,7 +27,7 @@ class ParsCfgHasProperFormat(object):
return
data
IsNumber
=
Or
(
float
,
int
,
error
=
'
Invalid number
"
{}
"
, expect int of float
'
)
IsNumberOrTuple
=
Or
(
IsNumber
,
(
IsNumber
,),
error
=
'
Invalid number/tuple {}
'
)
IsNumberOrTuple
=
Or
(
IsNumber
,
(
IsNumber
,),
And
([
IsNumber
],
Use
(
tuple
)),
error
=
'
Invalid number/tuple {}
'
)
IsLabel
=
Or
({
'
text
'
:
str
,
Optional
(
'
latex
'
):
str
,
...
...
@@ -40,7 +40,7 @@ IsLabel = Or({
IsValuesDict
=
NestedSchema
(
IsNumberOrTuple
)
IsLabelsDict
=
NestedSchema
(
IsLabel
,
processdicts
=
True
)
def
IsFormatOk
(
format
):
if
not
isinstance
(
format
,
tuple
):
if
not
isinstance
(
format
,
(
tuple
,
list
)
):
return
format
==
'
value
'
if
len
(
format
)
==
1
:
...
...
@@ -62,9 +62,9 @@ def IsFormatOk(format):
return
f1
in
(
'
value
'
,
'
central
'
)
IsFormat
=
Schema
(
IsFormatOk
,
error
=
'
Invalid
v
ar
iable
format
"
{}
"
.
'
)
Is
V
arsCfgDict
=
Schema
({
'
v
ar
iable
s
'
:
IsValuesDict
,
IsFormat
=
Schema
(
IsFormatOk
,
error
=
'
Invalid
p
ar
ameter
format
"
{}
"
.
'
)
Is
P
arsCfgDict
=
Schema
({
'
p
ar
ameter
s
'
:
IsValuesDict
,
'
labels
'
:
IsLabelsDict
,
'
format
'
:
IsFormat
,
'
state
'
:
Or
(
'
fixed
'
,
'
variable
'
,
error
=
'
Invalid parameters state: {}
'
),
...
...
@@ -72,16 +72,16 @@ IsVarsCfgDict = Schema({
},
# error = 'Invalid parameters configuration: {}'
)
IsProper
V
arsCfgDict
=
And
(
Is
V
arsCfgDict
,
ParsCfgHasProperFormat
())
IsProper
P
arsCfgDict
=
And
(
Is
P
arsCfgDict
,
ParsCfgHasProperFormat
())
IsLoadableDict
=
And
(
{
'
load
'
:
Or
(
str
,
And
(
Path
,
Use
(
str
))),
Optional
(
str
):
object
},
Use
(
LoadFileWithExt
(
yaml
=
LoadYaml
,
key
=
'
load
'
,
update
=
True
),
error
=
'
Failed to load {}
'
),
IsProper
V
arsCfgDict
IsProper
P
arsCfgDict
)
IsProper
V
arsCfg
=
Or
(
IsProper
V
arsCfgDict
,
IsLoadableDict
)
IsProper
P
arsCfg
=
Or
(
IsProper
P
arsCfgDict
,
IsLoadableDict
)
def
process_var_fixed1
(
vcfg
,
_
,
__
):
return
{
'
central
'
:
vcfg
,
'
value
'
:
vcfg
,
'
sigma
'
:
None
}
...
...
@@ -126,14 +126,14 @@ def get_format_processor(format):
return
process_var_percent
def
iterate_varcfgs
(
cfg
:
DictWrapper
):
v
ar
iable
scfg
=
cfg
[
'
v
ar
iable
s
'
]
p
ar
ameter
scfg
=
cfg
[
'
p
ar
ameter
s
'
]
labelscfg
=
cfg
[
'
labels
'
]
format
=
cfg
[
'
format
'
]
hascentral
=
'
central
'
in
format
process
=
get_format_processor
(
format
)
for
key
,
varcfg
in
v
ar
iable
scfg
.
walkitems
():
for
key
,
varcfg
in
p
ar
ameter
scfg
.
walkitems
():
varcfg
=
process
(
varcfg
,
format
,
hascentral
)
try
:
varcfg
[
'
label
'
]
=
labelscfg
[
key
]
...
...
@@ -143,8 +143,8 @@ def iterate_varcfgs(cfg: DictWrapper):
from
dagflow.variable
import
Parameters
def
load_
v
ar
iable
s
(
acfg
):
cfg
=
IsProper
V
arsCfg
.
validate
(
acfg
)
def
load_
p
ar
ameter
s
(
acfg
):
cfg
=
IsProper
P
arsCfg
.
validate
(
acfg
)
cfg
=
DictWrapper
(
cfg
)
path
=
cfg
[
'
path
'
]
...
...
This diff is collapsed.
Click to expand it.
subtrees/dagflow/test/variables/test_load_variables.py
+
12
−
12
View file @
f563d32b
from
dagflow.graphviz
import
savegraph
from
dagflow.graph
import
Graph
from
dagflow.bundles.load_
v
ar
iable
s
import
load_
v
ar
iable
s
from
dagflow.bundles.load_
p
ar
ameter
s
import
load_
p
ar
ameter
s
cfg1
=
{
'
v
ar
iable
s
'
:
{
'
p
ar
ameter
s
'
:
{
'
var1
'
:
1.0
,
'
var2
'
:
1.0
,
'
sub1
'
:
{
...
...
@@ -22,7 +22,7 @@ cfg1 = {
},
}
cfg1a
=
{
'
v
ar
iable
s
'
:
{
'
p
ar
ameter
s
'
:
{
'
var1
'
:
1.0
,
'
var2
'
:
1.0
,
'
sub1
'
:
{
...
...
@@ -42,7 +42,7 @@ cfg1a = {
}
cfg2
=
{
'
v
ar
iable
s
'
:
{
'
p
ar
ameter
s
'
:
{
'
var1
'
:
(
1.0
,
1.0
,
0.1
),
'
var2
'
:
(
1.0
,
2.0
,
0.1
),
'
sub1
'
:
{
...
...
@@ -63,8 +63,8 @@ cfg2 = {
}
cfg3
=
{
'
v
ar
iable
s
'
:
{
'
var1
'
:
(
1.0
,
1.0
,
0.1
)
,
'
p
ar
ameter
s
'
:
{
'
var1
'
:
[
1.0
,
1.0
,
0.1
]
,
'
var2
'
:
(
1.0
,
2.0
,
0.1
),
'
sub1
'
:
{
'
var3
'
:
(
2.0
,
3.0
,
0.1
)
...
...
@@ -78,12 +78,12 @@ cfg3 = {
},
'
var2
'
:
'
simple label 2
'
},
'
format
'
:
(
'
value
'
,
'
central
'
,
'
sigma_relative
'
)
,
'
format
'
:
[
'
value
'
,
'
central
'
,
'
sigma_relative
'
]
,
'
state
'
:
'
fixed
'
,
}
cfg4
=
{
'
v
ar
iable
s
'
:
{
'
p
ar
ameter
s
'
:
{
'
var1
'
:
(
1.0
,
1.0
,
10
),
'
var2
'
:
(
1.0
,
2.0
,
10
),
'
sub1
'
:
{
...
...
@@ -102,7 +102,7 @@ cfg4 = {
}
cfg5
=
{
'
v
ar
iable
s
'
:
{
'
p
ar
ameter
s
'
:
{
'
var1
'
:
(
1.0
,
10
),
'
var2
'
:
(
2.0
,
10
),
'
sub1
'
:
{
...
...
@@ -121,13 +121,13 @@ cfg5 = {
}
from
pprint
import
pprint
def
test_load_
v
ar
iable
s_v01
():
def
test_load_
p
ar
ameter
s_v01
():
cfgs
=
(
cfg1
,
cfg1a
,
cfg2
,
cfg3
,
cfg4
,
cfg5
)
with
Graph
(
close
=
True
)
as
g
:
for
i
,
cfg
in
enumerate
(
cfgs
):
vars
=
load_
v
ar
iable
s
(
cfg
)
vars
=
load_
p
ar
ameter
s
(
cfg
)
print
(
cfg
[
'
state
'
])
print
(
i
,
end
=
'
'
)
pprint
(
vars
.
object
)
savegraph
(
g
,
'
output/test_load_
v
ar
iable
s.pdf
'
,
show
=
'
all
'
)
savegraph
(
g
,
'
output/test_load_
p
ar
ameter
s.pdf
'
,
show
=
'
all
'
)
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