Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
Jupyter Docker Stacks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Jupyter Docker Stacks
Commits
083e2bbe
Commit
083e2bbe
authored
Feb 27, 2020
by
romainx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter dependencies from outdated packages
parent
f6dd044f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
12 deletions
+40
-12
test/test_outdated.py
test/test_outdated.py
+40
-12
No files found.
test/test_outdated.py
View file @
083e2bbe
...
...
@@ -26,6 +26,7 @@ import subprocess
from
collections
import
defaultdict
from
itertools
import
chain
import
logging
import
ast
import
pytest
...
...
@@ -67,9 +68,12 @@ def semantic_cmp(version_string):
return
tuple
(
map
(
try_int
,
mss
))
def
print_result
(
installed
,
result
):
def
print_result
(
installed
,
specs
,
result
):
"""Print the result of the outdated check"""
if
specs
is
None
:
nb_packages
=
len
(
installed
)
else
:
nb_packages
=
len
(
specs
)
nb_updatable
=
len
(
result
)
updatable_ratio
=
nb_updatable
/
nb_packages
LOGGER
.
info
(
...
...
@@ -79,16 +83,24 @@ def print_result(installed, result):
@
pytest
.
mark
.
info
def
test_outdated_packages
(
container
):
def
test_outdated_packages
(
container
,
remove_dependencies
=
True
):
"""Getting the list of outdated packages"""
LOGGER
.
info
(
f
"Checking outdated packages in {container.image_name} ..."
)
c
=
container
.
run
(
tty
=
True
,
command
=
[
"start.sh"
,
"bash"
,
"-c"
,
"sleep infinity"
])
sp_i
=
c
.
exec_run
([
"conda"
,
"list"
])
sp_v
=
c
.
exec_run
([
"conda"
,
"search"
,
"--outdated"
])
specs
=
None
if
remove_dependencies
:
raw_specs
=
c
.
exec_run
(
[
"grep"
,
"^# update specs:"
,
"/opt/conda/conda-meta/history"
]
)
specs
=
parse_specs
(
raw_specs
.
output
.
decode
(
"utf-8"
))
installed
=
get_versions
(
sp_i
.
output
.
decode
(
"utf-8"
))
available
=
get_versions
(
sp_v
.
output
.
decode
(
"utf-8"
))
result
=
list
()
for
pkg
,
inst_vs
in
installed
.
items
():
if
not
remove_dependencies
or
pkg
in
specs
:
avail_vs
=
sorted
(
list
(
available
[
pkg
]),
key
=
semantic_cmp
)
if
not
avail_vs
:
continue
...
...
@@ -96,5 +108,21 @@ def test_outdated_packages(container):
newest
=
avail_vs
[
-
1
]
if
avail_vs
and
current
!=
newest
:
if
semantic_cmp
(
current
)
<
semantic_cmp
(
newest
):
result
.
append
({
"Package"
:
pkg
,
"Current"
:
current
,
"Newest"
:
newest
})
print_result
(
installed
,
result
)
result
.
append
(
{
"Package"
:
pkg
,
"Current"
:
current
,
"Newest"
:
newest
}
)
print_result
(
installed
,
specs
,
result
)
def
parse_specs
(
raw_specs
):
"""Return the list of requested packages (specs)
Versions are removed from packages.
"""
packages
=
list
()
for
spec
in
(
spec
for
spec
in
raw_specs
.
split
(
"
\n
"
)
if
spec
.
strip
()
!=
""
):
packages
+=
map
(
lambda
x
:
x
.
split
(
"="
,
1
)[
0
],
ast
.
literal_eval
(
spec
.
split
(
": "
)[
1
])
)
LOGGER
.
debug
(
f
"List of specs from conda env: {packages}"
)
return
packages
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment