studio: handle revision errors when posting

This commit is contained in:
dberenbaum
2023-03-08 22:19:32 +01:00
committed by David de la Iglesia Castro
parent 0bd34c8977
commit fe7db32311
2 changed files with 19 additions and 2 deletions
+1 -1
View File
@@ -337,7 +337,7 @@ def to_studio_params(dvc_params):
if not dvc_params:
return result
for rev_data in dvc_params.values():
for file_name, file_data in rev_data["data"].items():
for file_name, file_data in rev_data.get("data", {}).items():
result[file_name] = file_data["data"]
return result
+18 -1
View File
@@ -2,7 +2,7 @@ import pytest
from dvc.exceptions import InvalidArgumentError
from dvc.repo.experiments.refs import EXPS_NAMESPACE, ExpRefInfo
from dvc.repo.experiments.utils import check_ref_format, resolve_name
from dvc.repo.experiments.utils import check_ref_format, resolve_name, to_studio_params
def commit_exp_ref(tmp_dir, scm, file="foo", contents="foo", name="foo"):
@@ -53,3 +53,20 @@ def test_run_check_ref_format(scm, name, result):
else:
with pytest.raises(InvalidArgumentError):
check_ref_format(scm, ref)
@pytest.mark.parametrize(
"params,expected",
[
(
{"workspace": {"data": {"params.yaml": {"data": {"foo": 1}}}}},
{"params.yaml": {"foo": 1}},
),
(
{"workspace": {"error": "something went wrong"}},
{},
),
],
)
def test_to_studio_params(params, expected):
assert to_studio_params(params) == expected