Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aidge_core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Houssem ROUIS
aidge_core
Commits
0214c5bb
Commit
0214c5bb
authored
3 months ago
by
Maxence Naud
Committed by
Maxence Naud
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: release with python3.8
parent
35e890ba
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
aidge_core/show_graphview.py
+9
-8
9 additions, 8 deletions
aidge_core/show_graphview.py
aidge_core/testing/utils/tree_cache.py
+22
-6
22 additions, 6 deletions
aidge_core/testing/utils/tree_cache.py
aidge_core/testing/utils/tree_utils.py
+23
-6
23 additions, 6 deletions
aidge_core/testing/utils/tree_utils.py
with
54 additions
and
20 deletions
aidge_core/show_graphview.py
+
9
−
8
View file @
0214c5bb
...
...
@@ -4,8 +4,9 @@ import builtins
import
aidge_core
import
numpy
as
np
from
pathlib
import
Path
from
typing
import
Any
,
Dict
,
List
,
Optional
def
_retrieve_operator_attrs
(
node
:
aidge_core
.
Node
)
->
d
ict
[
str
,
int
,
float
,
bool
,
None
]:
def
_retrieve_operator_attrs
(
node
:
aidge_core
.
Node
)
->
D
ict
[
str
,
Optional
[
Any
]
]:
"""
Returns the dictionary containing the attributes of a given Node.
...
...
@@ -13,7 +14,7 @@ def _retrieve_operator_attrs(node : aidge_core.Node) -> dict[str, int, float, bo
:type graph: aidge_core.Node
:return: A dictionary with the Node
'
s attributes.
:rtype:
d
ict[str,
int, float, bool, None
]
:rtype:
D
ict[str,
Optional[Any]
]
"""
if
node
.
get_operator
().
attr
is
not
None
:
...
...
@@ -27,7 +28,7 @@ def _retrieve_operator_attrs(node : aidge_core.Node) -> dict[str, int, float, bo
return
node_attr_dict
def
_create_dict
(
ordered_nodes
:
l
ist
[
aidge_core
.
Node
],
write_trainable_params_embed
:
bool
,
write_trainable_params_ext
:
bool
,
path_trainable_params
:
Path
,
params_file_format
:
str
)
->
d
ict
[
str
,
int
,
float
,
bool
,
None
]:
def
_create_dict
(
ordered_nodes
:
L
ist
[
aidge_core
.
Node
],
write_trainable_params_embed
:
bool
,
write_trainable_params_ext
:
bool
,
path_trainable_params
:
Path
,
params_file_format
:
str
)
->
D
ict
[
str
,
Optional
[
Any
]
]:
"""
Creates a dictionary to store the information of a given ordered GraphView.
...
...
@@ -43,7 +44,7 @@ def _create_dict(ordered_nodes : list[aidge_core.Node], write_trainable_params_e
:type params_file_format: str
:return: A dictionary with the GraphView description.
:rtype:
d
ict[str,
int, float, bool, None
]
:rtype:
D
ict[str,
Optional[Any]
]
"""
graphview_dict
=
{
'
graph
'
:
[]}
...
...
@@ -79,7 +80,7 @@ def _create_dict(ordered_nodes : list[aidge_core.Node], write_trainable_params_e
if
parents
[
0
]
is
None
:
parents
.
append
(
parents
.
pop
(
0
))
else
:
pass
parents_inputs
=
[]
input_idx
=
0
for
parent
in
node
.
get_parents
():
...
...
@@ -88,11 +89,11 @@ def _create_dict(ordered_nodes : list[aidge_core.Node], write_trainable_params_e
for
child
in
children
:
if
child
[
0
]
==
node
and
child
[
1
]
==
input_idx
:
parents_inputs
.
append
((
parent
.
name
(),
input_idx
))
elif
parent
is
None
:
if
input_idx
not
in
[
item
[
1
]
for
item
in
parents_inputs
]:
parents_inputs
.
append
((
None
,
input_idx
))
input_idx
+=
1
node_dict
[
'
parents
'
]
=
parents_inputs
...
...
@@ -167,7 +168,7 @@ def _create_dict(ordered_nodes : list[aidge_core.Node], write_trainable_params_e
return
graphview_dict
def
_write_dict_json
(
graphview_dict
:
d
ict
[
str
,
int
,
float
,
bool
,
None
],
json_path
:
str
)
->
None
:
def
_write_dict_json
(
graphview_dict
:
D
ict
[
str
,
Optional
[
Any
]
],
json_path
:
str
)
->
None
:
"""
Writes dictionary containing GraphView description to a JSON file.
...
...
This diff is collapsed.
Click to expand it.
aidge_core/testing/utils/tree_cache.py
+
22
−
6
View file @
0214c5bb
...
...
@@ -43,6 +43,7 @@ For more evolved scenarii, specialize the provided FileTreeCache class.
from
pathlib
import
Path
import
shutil
import
sys
import
filecmp
from
typing
import
Optional
,
Union
,
List
...
...
@@ -54,6 +55,21 @@ __all__ = [
"
tree_update_from_cache
"
,
]
def
is_relative_to
(
path
:
Path
,
other
:
Path
)
->
bool
:
"""
Dynamically choose implementation based on Python version
"""
# Python 3.9+
if
sys
.
version_info
>=
(
3
,
9
):
return
path
.
is_relative_to
(
other
)
# Python 3.8 and earlier
try
:
path
.
relative_to
(
other
)
return
True
except
ValueError
:
return
False
class
FileTreeCache
():
"""
...
...
@@ -66,8 +82,8 @@ class FileTreeCache():
default_tmp_prefix
=
"
__tmp_
"
def
__init__
(
self
,
src_path
:
Union
[
str
|
Path
],
cache_path
:
Optional
[
Union
[
str
|
Path
]]
=
None
src_path
:
Union
[
str
,
Path
],
cache_path
:
Optional
[
Union
[
str
,
Path
]]
=
None
)
->
None
:
self
.
src_path
=
Path
(
src_path
).
absolute
()
self
.
cache_path
=
(
...
...
@@ -78,7 +94,7 @@ class FileTreeCache():
)
ctx_msg
=
f
"
tree_cache:
{
src_path
=
}
,
{
cache_path
=
}
"
assert
self
.
src_path
!=
self
.
cache_path
,
f
"
src_path and cache_path must differ on
{
ctx_msg
}
"
assert
not
self
.
src_path
.
is_relative_to
(
self
.
cache_path
),
f
"
src_path must not be relative to cache_path on
{
ctx_msg
}
"
assert
not
is_relative_to
(
self
.
src_path
,
self
.
cache_path
),
f
"
src_path must not be relative to cache_path on
{
ctx_msg
}
"
self
.
_tmp_path
=
(
self
.
src_path
.
parent
/
f
"
{
self
.
default_tmp_prefix
}{
self
.
src_path
.
name
}
"
)
...
...
@@ -92,7 +108,7 @@ class FileTreeCache():
assert
not
dst_cache_dir
.
exists
()
assert
src_dir
.
is_dir
()
assert
not
cache_dir
.
exists
()
or
cache_dir
.
is_dir
()
assert
not
cache_dir
.
is_relative_to
(
src_dir
)
assert
not
is_relative_to
(
cache_dir
,
src_dir
)
def
copy_or_cache
(
src
,
dst
):
base_src
=
Path
(
src
).
relative_to
(
src_dir
)
...
...
@@ -132,8 +148,8 @@ class FileTreeCache():
def
tree_update_from_cache
(
src_path
:
Union
[
str
|
Path
],
cache_path
:
Optional
[
Union
[
str
|
Path
]]
=
None
)
->
None
:
src_path
:
Union
[
str
,
Path
],
cache_path
:
Optional
[
Union
[
str
,
Path
]]
=
None
)
->
None
:
"""
Update from cache the current generation of a tree from the
older generations, preserving file stamps when files contents are identical.
...
...
This diff is collapsed.
Click to expand it.
aidge_core/testing/utils/tree_utils.py
+
23
−
6
View file @
0214c5bb
...
...
@@ -5,8 +5,9 @@ Provide utility function for file trees manipulations.
"""
import
shutil
import
sys
from
pathlib
import
Path
from
typing
import
Union
,
Optional
from
typing
import
Union
__all__
=
[
...
...
@@ -15,8 +16,24 @@ __all__ = [
]
def
is_relative_to
(
path
:
Path
,
other
:
Path
)
->
bool
:
"""
Dynamically choose implementation based on Python version
"""
# Python 3.9+
if
sys
.
version_info
>=
(
3
,
9
):
return
path
.
is_relative_to
(
other
)
# Python 3.8 and earlier
try
:
path
.
relative_to
(
other
)
return
True
except
ValueError
:
return
False
def
tree_remove
(
path
:
Union
[
str
|
Path
],
path
:
Union
[
str
,
Path
],
ignore_missing
:
bool
=
False
,
)
->
None
:
"""
...
...
@@ -35,8 +52,8 @@ def tree_remove(
def
tree_move
(
src_path
:
Union
[
str
|
Path
],
dst_path
:
Union
[
str
|
Path
],
src_path
:
Union
[
str
,
Path
],
dst_path
:
Union
[
str
,
Path
],
ignore_missing
:
bool
=
False
,
exist_ok
:
bool
=
False
,
)
->
None
:
...
...
@@ -56,8 +73,8 @@ def tree_move(
assert
ignore_missing
or
src_path
.
exists
(),
f
"
src_path must exists when ignore_missing is False on
{
ctx_msg
}
"
assert
exist_ok
or
not
dst_path
.
exists
(),
f
"
dst_path must not exists when exist_ok is False on
{
ctx_msg
}
"
assert
src_path
!=
dst_path
,
f
"
paths must not be identical on
{
ctx_msg
}
"
assert
not
dst_path
.
is_relative_to
(
src_path
),
f
"
dst_path must not be relative to src_path on
{
ctx_msg
}
"
assert
not
src_path
.
is_relative_to
(
dst_path
),
f
"
src_path must not be relative to dst_path on
{
ctx_msg
}
"
assert
not
is_relative_to
(
dst_path
,
src_path
),
f
"
dst_path must not be relative to src_path on
{
ctx_msg
}
"
assert
not
is_relative_to
(
src_path
,
dst_path
),
f
"
src_path must not be relative to dst_path on
{
ctx_msg
}
"
if
ignore_missing
and
not
src_path
.
exists
():
return
if
exist_ok
and
dst_path
.
exists
():
...
...
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