Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Show more breadcrumbs
beat
beat.web
Commits
b26130a0
Commit
b26130a0
authored
5 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[algorithms][models] Use new Environment object use_count method
parent
3a21221e
No related branches found
No related tags found
1 merge request
!324
Return compatibility information for algorithms and libraries
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/libraries/models.py
+4
-23
4 additions, 23 deletions
beat/web/libraries/models.py
with
4 additions
and
23 deletions
beat/web/libraries/models.py
+
4
−
23
View file @
b26130a0
...
...
@@ -229,36 +229,17 @@ class Library(Code):
Returns:
list:
mapping
environment
to
usage counts, determining how many times
a given algorithm has been successfully used on that environment
list:
annotated
environment
with
usage counts, determining how many times
a given
library used in
algorithm
s
has been successfully used on that environment
"""
from
django.db.models
import
Count
,
Q
from
..experiments.models
import
Block
from
..experiments.models
import
Experiment
from
..backend.models
import
Environment
# Tries to figure through a maximum if using algorithms have been
# successfully used inside an environment.
# Case 1) The block is part of an experiment that was successful
# Case 2) The block is part of an experiment that is not successful
# (failed or other), but it is CACHED (if not cached, then we can't
# attest anything about the algorithm/environment relationship!)
envs
=
(
Environment
.
objects
.
filter
(
blocks__in
=
Block
.
objects
.
filter
(
algorithm__in
=
self
.
used_by_algorithms
.
all
()
).
filter
(
Q
(
experiment__status
=
Experiment
.
DONE
)
|
((
~
Q
(
experiment__status
=
Experiment
.
DONE
))
&
Q
(
status
=
Block
.
DONE
))
)
)
.
annotate
(
itemcount
=
Count
(
"
id
"
))
.
order_by
(
"
-creation_date
"
)
.
distinct
()
return
Environment
.
objects
.
use_count
(
Block
.
objects
.
filter
(
algorithm__in
=
self
.
used_by_algorithms
.
all
())
)
return
[(
k
,
k
.
itemcount
)
for
k
in
envs
]
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