Skip to content

Commit

Permalink
Merge branch 'devel' into hackathon
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-nikiforov-umn committed May 7, 2024
2 parents 72a4a8a + cc574d5 commit 90f608d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions docker/config/excerpts/query_local/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ def item_is_latest(kimcode):
version than the one given.
"""
# Discard human-readable prefix, if any
name, leader, num, ver = parse_kim_code(kimcode)
short_id = ("_").join((leader, num, ver))
_, leader, num, ver = parse_kim_code(kimcode)
shortcode = ("_").join((leader, num))
leader = leader.lower()

if leader in ["te", "vc"]:
Expand All @@ -558,9 +558,9 @@ def item_is_latest(kimcode):
# Don't need to turn on 'history' since we're interested in the latest
query = {
"database": "data",
"query": {"meta." + item_type + ".short-id": short_id},
"project": ["meta." + item_type + ".version"],
"sort": [["meta." + item_type + ".version", -1]],
"query": {"meta." + item_type + ".shortcode": shortcode},
"project": ["meta." + item_type + ".kimid-version"],
"sort": [["meta." + item_type + ".kimid-version", -1]],
"limit": 1,
}

Expand Down
3 changes: 3 additions & 0 deletions docker/config/excerpts/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def intercept_query(query, subject_name, local, infofile):

# If we're querying from pipeline.stdin.tpl for a stale Model, add history and sort accordingly
if add_history:
print ("WARNING: Querying for stale models will currently return ALL results for that model.\n"
"If your pipeline.stdin.tpl query does not include a 'limit':1 option,\n"
"you may get duplicate and/or 'double stale' (stale model and stale test) results.\n")
query["history"] = True
orig_sort = query.get("sort", None)
if orig_sort:
Expand Down
7 changes: 2 additions & 5 deletions docker/config/excerpts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def item_is_latest(kimcode):
# Discard human-readable prefix, if any
_, leader, num, ver = kimcodes.parse_kim_code(kimcode)
short_id = ("_").join((leader, num, ver))
leader = leader.lower()

# Query remote database
query = {
Expand All @@ -200,12 +199,10 @@ def item_is_latest(kimcode):
# onto a single key, a scalar is returned)
if isinstance(query_result, list):
if query_result:
latest_ver = query_result[0]
return query_result[0]
else:
# Couldn't find any results, so we must have the latest version of the item
# as far as the local database is concerned
return True
else:
latest_ver = query_result

return ver == latest_ver
return query_result

0 comments on commit 90f608d

Please sign in to comment.