Skip to content

Commit a36c0b7

Browse files
authored
MacOs versioning and release bugfix (#247)
1 parent ad92dd7 commit a36c0b7

File tree

12 files changed

+183
-178
lines changed

12 files changed

+183
-178
lines changed

.circleci/unittest/linux/scripts/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- pytest
1818
- pytest-cov
1919
- pytest-mock
20+
- pytest-instafail
2021
- expecttest
2122
- pyyaml
2223
- scipy

.circleci/unittest/linux/scripts/run_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ lib_dir="${env_dir}/lib"
1616

1717
# solves ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found
1818
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$lib_dir
19+
export MKL_THREADING_LAYER=GNU
1920

2021
pytest test/smoke_test.py -v --durations 20
2122
pytest test/smoke_test_deps.py -v --durations 20
22-
pytest -v --durations 20
23+
pytest --instafail -v --durations 20

.circleci/unittest/linux_optdeps/scripts/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
- pytest
1111
- pytest-cov
1212
- pytest-mock
13+
- pytest-instafail
1314
- expecttest
1415
- pyyaml
1516
- scipy

.circleci/unittest/linux_optdeps/scripts/run_test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ export MJLIB_PATH=$root_dir/.mujoco/mujoco-2.1.1/lib/libmujoco.so.2.1.1
1414
export MUJOCO_PY_MUJOCO_PATH=$root_dir/.mujoco/mujoco210
1515
export DISPLAY=unix:0.0
1616
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/project/.mujoco/mujoco210/bin
17+
export MKL_THREADING_LAYER=GNU
18+
1719
#MUJOCO_GL=glfw pytest --cov=torchrl --junitxml=test-results/junit.xml -v --durations 20
18-
MUJOCO_GL=egl pytest -v --durations 20
20+
MUJOCO_GL=egl pytest --instafail -v --durations 20

.circleci/unittest/linux_stable/scripts/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies:
1818
- pytest
1919
- pytest-cov
2020
- pytest-mock
21+
- pytest-instafail
2122
- expecttest
2223
- pyyaml
2324
- scipy

.circleci/unittest/linux_stable/scripts/run_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ lib_dir="${env_dir}/lib"
1616

1717
# solves ImportError: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found
1818
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$lib_dir
19+
export MKL_THREADING_LAYER=GNU
1920

2021
pytest test/smoke_test.py -v --durations 20
2122
pytest test/smoke_test_deps.py -v --durations 20
22-
pytest -v --durations 20
23+
pytest --instafail -v --durations 20

.github/workflows/wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
run: |
2828
export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH"
2929
python3 -mpip install wheel
30-
VERSION_TAG=${{ matrix.cuda_support[0] }} PYTORCH_CUDA_RESTRICTIONS=${{ matrix.cuda_support[2] }} python3 setup.py bdist_wheel
30+
BUILD_VERSION=0.0.1 python3 setup.py bdist_wheel
3131
# NB: wheels have the linux_x86_64 tag so we rename to manylinux1
3232
# find . -name 'dist/*whl' -exec bash -c ' mv $0 ${0/linux/manylinux1}' {} \;
3333
# pytorch/pytorch binaries are also manylinux_2_17 compliant but they
@@ -68,7 +68,7 @@ jobs:
6868
run: |
6969
export CC=clang CXX=clang++
7070
python3 -mpip install wheel
71-
python3 setup.py bdist_wheel
71+
BUILD_VERSION=0.0.1 python3 setup.py bdist_wheel
7272
- name: Upload wheel for the test-wheel job
7373
uses: actions/upload-artifact@v2
7474
with:

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _main():
165165
"dm_control": ["dm_control"],
166166
"gym_continuous": ["mujoco-py", "mujoco"],
167167
"rendering": ["moviepy"],
168-
"tests": ["pytest", "pyyaml"],
168+
"tests": ["pytest", "pyyaml", "pytest-instafail"],
169169
"utils": [
170170
"tensorboard",
171171
"tqdm",
@@ -186,4 +186,5 @@ def _main():
186186

187187
write_version_file()
188188
print("Building wheel {}-{}".format(package_name, version))
189+
print(f"BUILD_VERSION is {os.getenv('BUILD_VERSION')}")
189190
_main()

test/test_shared.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ def remote_process(command_pipe_child, command_pipe_parent, tensordict):
2222
tensordict.zero_()
2323
print(f"zeroing time: {time.time() - t0}")
2424
command_pipe_child.send("done")
25+
command_pipe_child.close()
26+
del command_pipe_child, command_pipe_parent, tensordict
2527

2628
@staticmethod
2729
def driver_func(subtd, td):
@@ -39,10 +41,12 @@ def driver_func(subtd, td):
3941

4042
for key, item in td[0].items():
4143
assert (item == 0).all()
42-
proc.join()
4344
command_pipe_parent.close()
45+
proc.join()
46+
del command_pipe_child, command_pipe_parent, proc
4447

45-
def test_shared(self):
48+
@pytest.mark.parametrize("indexing_method", range(3))
49+
def test_shared(self, indexing_method):
4650
torch.manual_seed(0)
4751
tensordict = TensorDict(
4852
source={
@@ -53,31 +57,21 @@ def test_shared(self):
5357
batch_size=[1000],
5458
)
5559

56-
td1 = tensordict.clone().share_memory_()
57-
td2 = tensordict.clone().share_memory_()
58-
td3 = tensordict.clone().share_memory_()
59-
subtd2 = TensorDict(
60-
source={key: item[0] for key, item in td2.items()}, batch_size=[]
61-
)
62-
assert subtd2.is_shared()
63-
print("sub td2 is shared: ", subtd2.is_shared())
64-
65-
subtd1 = td1.get_sub_tensordict(0)
66-
t0 = time.time()
67-
self.driver_func(subtd1, td1)
68-
t_elapsed = time.time() - t0
69-
print(f"execution on subtd: {t_elapsed}")
60+
td = tensordict.clone().share_memory_()
61+
if indexing_method == 0:
62+
subtd = TensorDict(
63+
source={key: item[0] for key, item in td.items()}, batch_size=[]
64+
)
65+
elif indexing_method == 1:
66+
subtd = td.get_sub_tensordict(0)
67+
elif indexing_method == 2:
68+
subtd = td[0]
69+
else:
70+
raise NotImplementedError
7071

71-
t0 = time.time()
72-
self.driver_func(subtd2, td2)
73-
t_elapsed = time.time() - t0
74-
print(f"execution on plain td: {t_elapsed}")
72+
assert subtd.is_shared()
7573

76-
subtd3 = td3[0]
77-
t0 = time.time()
78-
self.driver_func(subtd3, td3)
79-
t_elapsed = time.time() - t0
80-
print(f"execution on regular indexed td: {t_elapsed}")
74+
self.driver_func(subtd, td)
8175

8276

8377
class TestStack:
@@ -102,6 +96,8 @@ def remote_process(command_pipe_child, command_pipe_parent, tensordict):
10296
tensordict.update_at_(td, i)
10397
time_spent = time.time() - t0
10498
command_pipe_child.send(time_spent)
99+
command_pipe_child.close()
100+
del command_pipe_child, command_pipe_parent
105101

106102
@staticmethod
107103
def driver_func(td, stack):

0 commit comments

Comments
 (0)