Skip to content

Commit 068c829

Browse files
committed
Add the devamp dataset to test data.
This adds a target //programl/test/data:devmap_dataset which is a tarball of the full devmap dataset. github.com//issues/119
1 parent 27d73c3 commit 068c829

File tree

6 files changed

+97
-1
lines changed

6 files changed

+97
-1
lines changed

programl/task/devmap/dataset/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
py_binary(
1818
name = "create",
1919
srcs = ["create.py"],
20+
visibility = ["//visibility:public"],
2021
deps = [
2122
"//programl/ir/llvm/py:llvm",
2223
"//programl/proto:features_py",

programl/task/devmap/dataset/create.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
"""Prepare the CPU/GPU OpenCL device-mapping dataset."""
16+
"""Prepare the CPU/GPU OpenCL device-mapping dataset.
17+
18+
This script downloads the necessary datasets and produces the devmap downstream task dataset.
19+
20+
Usage:
21+
22+
$ bazel run //programl/task/devmap/dataset:create -- --path=/path/to/devmap
23+
"""
1724
import io
1825
import os
1926
import shutil

programl/test/data/BUILD

+12
Original file line numberDiff line numberDiff line change
@@ -3116,6 +3116,18 @@ py_binary(
31163116
],
31173117
)
31183118

3119+
genrule(
3120+
name = "devmap_dataset",
3121+
testonly = 1,
3122+
outs = ["devmap_dataset.tar.bz2"],
3123+
cmd = (
3124+
"$(location //programl/task/devmap/dataset:create) --path=$(@D)/dtmp && " +
3125+
"tar cjf $(@D)/devmap_dataset.tar.bz2 -C $(@D)/dtmp . && " +
3126+
"rm -rf $(@D)/dtmp"
3127+
),
3128+
tools = ["//programl/task/devmap/dataset:create"],
3129+
)
3130+
31193131
genrule(
31203132
name = "reachability_dataflow_dataset",
31213133
testonly = 1,

programl/test/py/plugins/BUILD

+19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@ py_test(
3737
],
3838
)
3939

40+
py_library(
41+
name = "devmap_dataset",
42+
testonly = 1,
43+
srcs = ["devmap_dataset.py"],
44+
data = ["//programl/test/data:devmap_dataset"],
45+
deps = [
46+
"//third_party/py/labm8",
47+
],
48+
)
49+
50+
py_test(
51+
name = "devmap_dataset_test",
52+
srcs = ["devmap_dataset.py"],
53+
deps = [
54+
":devmap_dataset",
55+
"//third_party/py/labm8",
56+
],
57+
)
58+
4059
py_library(
4160
name = "llvm_ir",
4261
testonly = 1,
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2019-2020 the ProGraML authors.
2+
#
3+
# Contact Chris Cummins <[email protected]>.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
from pathlib import Path
17+
18+
from labm8.py import bazelutil
19+
20+
DEVMAP_DATASET = bazelutil.DataArchive("programl/test/data/devmap_dataset.tar.bz2")
21+
22+
23+
@test.Fixture(scope="function")
24+
def devmap_dataset() -> Path:
25+
"""A test fixture which yields the root of the devmap dataset."""
26+
with DEVMAP_DATASET as d:
27+
yield d
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2019-2020 the ProGraML authors.
2+
#
3+
# Contact Chris Cummins <[email protected]>.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
"""Unit tests for //programl/test/py/plugins:devmap_dataset."""
17+
from pathlib import Path
18+
19+
from labm8.py import test
20+
21+
pytest_plugins = ["programl.test.py.plugins.devmap_dataset"]
22+
23+
24+
def test_devmap_dataset(devmap_dataset: Path):
25+
assert (devmap_dataset / "ir").is_dir()
26+
assert (devmap_dataset / "graphs").is_dir()
27+
28+
29+
if __name__ == "__main__":
30+
test.Main()

0 commit comments

Comments
 (0)