Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.admin
Commits
49dec037
Commit
49dec037
authored
7 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Simplify this script according to discussion in #60
parent
fc2535a7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
conda/clean-betas.py
+13
-70
13 additions, 70 deletions
conda/clean-betas.py
with
13 additions
and
70 deletions
conda/clean-betas.py
+
13
−
70
View file @
49dec037
...
@@ -3,65 +3,10 @@
...
@@ -3,65 +3,10 @@
# Cleans-up old beta-conda-packages to avoid storing unused packages
# Cleans-up old beta-conda-packages to avoid storing unused packages
import
os
import
os
import
re
import
sys
import
sys
from
distutils.version
import
StrictVersion
from
distutils.version
import
StrictVersion
package_regex
=
re
.
compile
(
r
'
^(?P<name>\S+)-(?P<version>\d+\.\d+\.\d+[abc]\d+)-(?P<python>(py\d\d))?(?P<hash>h[0-9a-f]{7})_(?P<build>\d+)(?P<extension>\.tar\.bz2)$
'
)
def
check_regex
():
"""
Tests for the above regex
"""
def
_check
(
s
,
name
,
version
,
py
,
_hash
,
build
,
ext
):
m
=
package_regex
.
match
(
s
)
assert
m
is
not
None
,
'
expected match for %s
'
%
s
assert
m
.
group
(
'
name
'
)
==
name
,
'
%r != %r
'
%
(
m
.
group
(
'
name
'
),
name
)
assert
m
.
group
(
'
version
'
)
==
version
,
'
%r != %r
'
%
(
m
.
group
(
'
version
'
),
version
)
assert
m
.
group
(
'
python
'
)
==
py
,
'
%r != %r
'
%
(
m
.
group
(
'
python
'
),
py
)
assert
m
.
group
(
'
hash
'
)
==
_hash
,
'
%r != %r
'
%
(
m
.
group
(
'
hash
'
),
_hash
)
assert
m
.
group
(
'
build
'
)
==
build
,
'
%r != %r
'
%
(
m
.
group
(
'
build
'
),
build
)
assert
m
.
group
(
'
extension
'
)
==
ext
,
'
%r != %r
'
%
(
m
.
group
(
'
extension
'
),
ext
)
# This regexp must match the following examples:
_check
(
'
docs-2018.02.21b0-h7a51f39_0.tar.bz2
'
,
'
docs
'
,
'
2018.02.21b0
'
,
None
,
'
h7a51f39
'
,
'
0
'
,
'
.tar.bz2
'
)
_check
(
'
docs-with-dashes-2018.02.21b0-h7a51f39_0.tar.bz2
'
,
'
docs-with-dashes
'
,
'
2018.02.21b0
'
,
None
,
'
h7a51f39
'
,
'
0
'
,
'
.tar.bz2
'
)
_check
(
'
bob.sp-2.0.11b0-py27h21b2d43_7.tar.bz2
'
,
'
bob.sp
'
,
'
2.0.11b0
'
,
'
py27
'
,
'
h21b2d43
'
,
'
7
'
,
'
.tar.bz2
'
)
_check
(
'
gridtk-1.5.1b0-py36h361992c_4.tar.bz2
'
,
'
gridtk
'
,
'
1.5.1b0
'
,
'
py36
'
,
'
h361992c
'
,
'
4
'
,
'
.tar.bz2
'
)
_check
(
'
bob.measure-2.5.0b0-py36h81a6768_11.tar.bz2
'
,
'
bob.measure
'
,
'
2.5.0b0
'
,
'
py36
'
,
'
h81a6768
'
,
'
11
'
,
'
.tar.bz2
'
)
_check
(
'
bob.ip.caffe_extractor-1.1.2b0-py27hc65a447_0.tar.bz2
'
,
'
bob.ip.caffe_extractor
'
,
'
1.1.2b0
'
,
'
py27
'
,
'
hc65a447
'
,
'
0
'
,
'
.tar.bz2
'
)
_check
(
'
bob.db.msu_mfsd_mod-2.2.4b0-py27h2410e3f_2.tar.bz2
'
,
'
bob.db.msu_mfsd_mod
'
,
'
2.2.4b0
'
,
'
py27
'
,
'
h2410e3f
'
,
'
2
'
,
'
.tar.bz2
'
)
_check
(
'
bob-3.0.1b0-py27h2dcd9c5_5.tar.bz2
'
,
'
bob
'
,
'
3.0.1b0
'
,
'
py27
'
,
'
h2dcd9c5
'
,
'
5
'
,
'
.tar.bz2
'
)
# This regexp must **not** match the following examples
assert
package_regex
.
match
(
'
zc.buildout-2.10.0-py27_0.tar.bz2
'
)
is
None
assert
package_regex
.
match
(
'
speexdsp-1.2rc3-h5bbff6d_0.tar.bz2
'
)
is
None
assert
package_regex
.
match
(
'
pkgtools-0.7.3-py27_0.tar.bz2
'
)
is
None
assert
package_regex
.
match
(
'
opencv-3.1.0-np111py27_4.tar.bz2
'
)
is
None
assert
package_regex
.
match
(
'
keras-gpu-2.0.8-py27_0.tar.bz2
'
)
is
None
assert
package_regex
.
match
(
'
bob-3.0.0-np113py36_0.tar.bz2
'
)
is
None
assert
package_regex
.
match
(
'
bob.xyz.bla-2.0.12-np113py27_0.tar.bz2
'
)
is
None
def
main
(
scandir
,
dry_run
):
def
main
(
scandir
,
dry_run
):
betas
=
dict
()
betas
=
dict
()
...
@@ -70,20 +15,15 @@ def main(scandir, dry_run):
...
@@ -70,20 +15,15 @@ def main(scandir, dry_run):
for
f
in
filenames
:
for
f
in
filenames
:
if
f
.
startswith
(
'
.
'
):
continue
if
f
.
startswith
(
'
.
'
):
continue
if
f
.
startswith
(
'
repodata.json
'
):
continue
if
not
f
.
endswith
(
'
.tar.bz2
'
):
continue
m
=
package_regex
.
match
(
f
)
name
,
version
,
build_string
=
filename
[:
-
8
].
rsplit
(
'
-
'
,
2
)
if
m
is
None
:
build
=
build_string
.
rsplit
(
'
_
'
)[
-
1
]
print
(
'
ignoring `%s
\'
(does not match)
'
%
os
.
path
.
join
(
path
,
f
))
continue
# got a beta package since it matches our regex, insert it into our
name
=
os
.
path
.
basename
(
path
)
+
'
/
'
+
name
# list of packages to evaluate
name
=
os
.
path
.
basename
(
path
)
+
'
/
'
+
m
.
group
(
'
name
'
)
target
=
os
.
path
.
join
(
path
,
f
)
target
=
os
.
path
.
join
(
path
,
f
)
if
m
.
group
(
'
python
'
)
is
not
None
:
name
+=
'
@
'
+
m
.
group
(
'
python
'
)
betas
.
setdefault
(
name
,
[]).
append
((
betas
.
setdefault
(
name
,
[]).
append
((
StrictVersion
(
m
.
group
(
'
version
'
)),
#
version
StrictVersion
(
version
),
int
(
m
.
group
(
'
build
'
)
),
#build number
int
(
build
),
#build number
os
.
path
.
getmtime
(
target
),
#cross-platform last modification time
os
.
path
.
getmtime
(
target
),
#cross-platform last modification time
target
,
target
,
))
))
...
@@ -96,10 +36,13 @@ def main(scandir, dry_run):
...
@@ -96,10 +36,13 @@ def main(scandir, dry_run):
for
name
in
sorted
(
betas
.
keys
()):
for
name
in
sorted
(
betas
.
keys
()):
print
(
'
\n
==== packages for %s (%d) ====
'
%
(
name
,
len
(
betas
[
name
])))
print
(
'
\n
==== packages for %s (%d) ====
'
%
(
name
,
len
(
betas
[
name
])))
sorted_packages
=
sorted
(
betas
[
name
])
sorted_packages
=
sorted
(
betas
[
name
])
for
version
,
build
,
mtime
,
path
in
sorted_packages
[:
-
1
]:
keep_version
,
keep_build
,
_
=
sorted_packages
[
-
1
]
print
(
'
remove %s (%u)
'
%
(
path
,
mtime
))
for
version
,
build
,
mtime
,
path
in
sorted_packages
:
if
not
dry_run
:
os
.
unlink
(
path
)
if
version
==
keep_version
and
build
==
keep_build
:
print
(
'
[keep] %s (%u)
'
%
(
sorted_packages
[
-
1
][
3
],
sorted_packages
[
-
1
][
2
]))
print
(
'
[keep] %s (%u)
'
%
(
path
,
mtime
))
else
:
print
(
'
remove %s (%u)
'
%
(
path
,
mtime
))
if
not
dry_run
:
os
.
unlink
(
path
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
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