Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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 JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
dd685d83
Commit
dd685d83
authored
11 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
use session aggregation for experiment timestamps
parent
289e2f55
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
experiments.py
+12
-1
12 additions, 1 deletion
experiments.py
with
12 additions
and
1 deletion
experiments.py
+
12
−
1
View file @
dd685d83
...
...
@@ -20,8 +20,15 @@ class Experiments(nimsapiutil.NIMSRequestHandler):
def
get
(
self
):
"""
Return the list of Experiments.
"""
query
=
{
'
permissions.
'
+
self
.
userid
:
{
'
$exists
'
:
'
true
'
}}
if
not
self
.
user_is_superuser
else
None
projection
=
[
'
timestamp
'
,
'
group
'
,
'
name
'
,
'
permissions.
'
+
self
.
userid
]
projection
=
[
'
group
'
,
'
name
'
,
'
permissions.
'
+
self
.
userid
]
experiments
=
list
(
self
.
app
.
db
.
experiments
.
find
(
query
,
projection
))
session_aggregates
=
self
.
app
.
db
.
sessions
.
aggregate
([
{
'
$match
'
:
{
'
experiment
'
:
{
'
$in
'
:
[
exp
[
'
_id
'
]
for
exp
in
experiments
]}}},
{
'
$group
'
:
{
'
_id
'
:
'
$experiment
'
,
'
timestamp
'
:
{
'
$max
'
:
'
$timestamp
'
}}},
])[
'
result
'
]
timestamps
=
{
sa
[
'
_id
'
]:
sa
[
'
timestamp
'
]
for
sa
in
session_aggregates
}
for
exp
in
experiments
:
exp
[
'
timestamp
'
]
=
timestamps
[
exp
[
'
_id
'
]]
self
.
response
.
write
(
json
.
dumps
(
experiments
,
default
=
bson
.
json_util
.
default
))
def
put
(
self
):
...
...
@@ -36,6 +43,10 @@ class Experiment(nimsapiutil.NIMSRequestHandler):
experiment
=
self
.
app
.
db
.
experiments
.
find_one
({
'
_id
'
:
bson
.
objectid
.
ObjectId
(
exp_id
)})
if
not
experiment
:
self
.
abort
(
404
)
experiment
[
'
timestamp
'
]
=
self
.
app
.
db
.
sessions
.
aggregate
([
{
'
$match
'
:
{
'
experiment
'
:
bson
.
objectid
.
ObjectId
(
exp_id
)}},
{
'
$group
'
:
{
'
_id
'
:
'
$experiment
'
,
'
timestamp
'
:
{
'
$max
'
:
'
$timestamp
'
}}},
])[
'
result
'
][
0
][
'
timestamp
'
]
if
not
self
.
user_is_superuser
:
if
self
.
userid
not
in
experiment
[
'
permissions
'
]:
self
.
abort
(
403
)
...
...
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