Skip to content

Commit

Permalink
🔧 fix to use latest versioon result if multiple apps (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanesarango authored Jun 12, 2023
1 parent d1f4305 commit 78c6c44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion isabl_cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ def _get_dependencies_results(self, targets, references):
# Match app by name, and optionally by version
if dependency.get("app_name"):
result_args["application_name"] = dependency.get("app_name")
if "version" in dependency:
if "app_version" in dependency:
result_args["application_version"] = dependency.get("app_version")
else:
# Match app by primary key
Expand Down
12 changes: 8 additions & 4 deletions isabl_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def get_results(
if i.application.pk == application_key:
experiment_results.append(i)
elif application_name:
if application_version:
if (
application_version
and application_version != "latest"
):
if (
i.application.name == application_name
and i.application.version == application_version
Expand Down Expand Up @@ -113,8 +116,8 @@ def get_results(
f"{i.pk}({i.application.name} {i.application.version}) is {i.status}"
)

# If more than 1 result and version is `any`, use latest.
if len(results) > 2 and application_version == "any":
# Return latest if more than 1 result and version is `latest`.
if len(results) > 2 and application_version == "latest":
results = sorted(results, key=lambda x: x[1], reverse=True)[:1]

return results
Expand All @@ -135,7 +138,8 @@ def get_result(*args, **kwargs):
app_name = kwargs.get("application_name") or kwargs.get("application_key")
results = get_results(*args, **kwargs)
assert results, f"No results found for application: {app_name}"
assert len(results) == 1, f"Multiple results returned {results}"
if kwargs.get("application_version") != "latest":
assert len(results) == 1, f"Multiple results returned {results}"
result, key = results[0]
return result, key

Expand Down

0 comments on commit 78c6c44

Please sign in to comment.