Skip to content

Commit

Permalink
feat: use sensible name when generating old schema records
Browse files Browse the repository at this point in the history
  • Loading branch information
wd15 committed Mar 17, 2024
1 parent 8ff605a commit c73604d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pfhub/new_to_old.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,31 @@ def subs(data_all, lines_and_contours):
"memory_usage": data_all.results.memory_in_kb,
"lines": lines_and_contours["lines"],
"contours": lines_and_contours.get("contours", []),
"name": data_all.id,
"name": make_name(data_all),
"repo_version": "aaaaa",
}


def make_name(data_all):
"""Generate a name from a new schema record
Args:
data_all: new schema dictionary
Returns:
a sensibel name string
"""
return (
data_all.framework[0].name
+ "-"
+ data_all.benchmark_problem
+ "-"
+ data_all.contributors[0].id.split(":")[1]
+ "-"
+ data_all.date_created
)


def render_meta(data_all):
"""Render the meta file"""
return render(
Expand Down
13 changes: 13 additions & 0 deletions pfhub/scripts/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,16 @@ def test_adding_new_result(tmpdir):
outpath2 = os.path.join(tmpdir, "result_list_1a.1.yaml")
assert result.exit_code == 0
assert result.output.splitlines()[-1] == f"Writing: {outpath1}, {outpath2}"


def test_name_generation(tmpdir):
"""Test name generation when converting from new to old"""
runner = CliRunner()
base = os.path.split(__file__)[0]
yaml_path = os.path.join(base, "..", "test_data", "meumapps", "pfhub.yaml")
result = runner.invoke(convert_to_old, [yaml_path, "--dest", tmpdir])
outpath = os.path.join(tmpdir, "meta.yaml")
assert result.exit_code == 0
assert result.output.splitlines()[-1] == f"Writing: {outpath}"
data = read_yaml(outpath)
assert data["name"] == "meumapps-1a.1-stvdwtt-2021-04-01"

0 comments on commit c73604d

Please sign in to comment.