Skip to content

Commit b1a5d76

Browse files
committed
Merge branch 'master' into benchmarking-docs
2 parents 4c4445c + ebdb42b commit b1a5d76

File tree

7 files changed

+28
-7
lines changed

7 files changed

+28
-7
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ commands:
138138
# Download and cache dependencies
139139
- restore_cache:
140140
keys:
141-
- v9win-dependencies-{{ checksum "setup.py" }}-{{ checksum "ci/build_and_activate_venv.ps1" }}
141+
- v10win-dependencies-{{ checksum "setup.py" }}-{{ checksum "ci/build_and_activate_venv.ps1" }}
142142

143143
- run:
144144
name: install python and binary dependencies
@@ -168,7 +168,7 @@ commands:
168168
- save_cache:
169169
paths:
170170
- .\venv
171-
key: v9win-dependencies-{{ checksum "setup.py" }}-{{ checksum "ci/build_and_activate_venv.ps1" }}
171+
key: v10win-dependencies-{{ checksum "setup.py" }}-{{ checksum "ci/build_and_activate_venv.ps1" }}
172172

173173
- run:
174174
name: install imitation

ci/build_and_activate_venv.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ If ($venv -eq $null) {
99

1010
virtualenv -p python3.8 $venv
1111
& $venv\Scripts\activate
12-
# Note: We need to install setuptools==66.1.1 to allow installing gym==0.21.0.
13-
python -m pip install --upgrade pip setuptools==66.1.1
12+
# Note: We need to install these versions of setuptools and wheel to allow installing gym==0.21.0 on Windows.
13+
# See https://github.com/freqtrade/freqtrade/issues/8376
14+
# TODO(GH#707): remove pin once upgraded Gym
15+
python -m pip install --upgrade pip wheel==0.38.4 setuptools==65.5.1
1416
pip install ".[docs,parallel,test]"

ci/build_and_activate_venv.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,12 @@ virtualenv -p ${python_version} ${venv}
2222
source ${venv}/bin/activate
2323
# Note: We need to install setuptools==66.1.1 to allow installing gym==0.21.0.
2424
python -m pip install --upgrade pip setuptools==66.1.1
25+
26+
# If platform is linux, install pytorch CPU version.
27+
# This will prevent installing the CUDA version in the pip install ".[docs,parallel,test]" command.
28+
# The CUDA version is a couple of gigabytes larger than the CPU version.
29+
# Since we don't need the CUDA version for testing, we can save some time by not installing it.
30+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
31+
pip install torch --index-url https://download.pytorch.org/whl/cpu
32+
fi
2533
pip install ".[docs,parallel,test]"

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# specific version needed for gym==0.21.0
2+
setuptools==65.5.0

readthedocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ build:
1212

1313
python:
1414
install:
15+
# TODO(GH#707): remove docs/requirements.txt once Gym upgraded
16+
- requirements: docs/requirements.txt
1517
- method: pip
1618
path: .
1719
extra_requirements:

src/imitation/testing/expert_trajectories.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import math
33
import pathlib
44
import pickle
5+
import shutil
56
import warnings
67
from os import PathLike
78
from pathlib import Path
@@ -73,10 +74,10 @@ def lazy_generate_expert_trajectories(
7374
environment_cache_path = pathlib.Path(cache_path) / hfsb3.EnvironmentName(env_id)
7475
environment_cache_path.mkdir(parents=True, exist_ok=True)
7576

76-
trajectories_path = environment_cache_path / "rollout.npz"
77+
trajectories_path = environment_cache_path / "rollout"
7778

7879
# Note: we cast to str here because FileLock doesn't support pathlib.Path.
79-
with FileLock(str(environment_cache_path / "rollout.npz.lock")):
80+
with FileLock(str(environment_cache_path / "rollout.lock")):
8081
try:
8182
trajectories = data_serialize.load_with_rewards(trajectories_path)
8283
except (FileNotFoundError, pickle.PickleError) as e: # pragma: no cover
@@ -96,7 +97,13 @@ def lazy_generate_expert_trajectories(
9697
return trajectories[:num_trajectories]
9798
else: # pragma: no cover
9899
# If it is not enough, just throw away the cache and generate more.
99-
trajectories_path.unlink()
100+
if trajectories_path.is_dir():
101+
# rmtree won't remove directory on Windows
102+
# until the last handle to the directory is closed
103+
del trajectories
104+
shutil.rmtree(trajectories_path)
105+
else:
106+
trajectories_path.unlink()
100107
return lazy_generate_expert_trajectories(
101108
cache_path,
102109
env_id,
Binary file not shown.

0 commit comments

Comments
 (0)