Skip to content

Commit

Permalink
Fix Docker build script (#640)
Browse files Browse the repository at this point in the history
* Pass build arguments to Docker

* Fix Codacy downloader to work with latest releases

* Add automatic Docker push for release

* Update changelog

* Print pytype version in CI

* Fix type error

* Fix other type false positive
  • Loading branch information
AdamGleave authored and araffin committed Jan 2, 2020
1 parent 6bdb7ce commit b06ab28
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: "Type Checking"
script:
- 'docker run --rm --mount src=$(pwd),target=/root/code/stable-baselines,type=bind ${DOCKER_IMAGE} bash -c "cd /root/code/stable-baselines/ && pytype"'
- 'docker run --rm --mount src=$(pwd),target=/root/code/stable-baselines,type=bind ${DOCKER_IMAGE} bash -c "cd /root/code/stable-baselines/ && pytype --version && pytype"'

- stage: Codacy Trigger
if: type != pull_request
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN \
. $VENV/bin/activate && \
cd $CODE_DIR && \
pip install --upgrade pip && \
if [[ $USE_GPU == "True" ]]; then \
if [ "$USE_GPU" = "True" ]; then \
TENSORFLOW_PACKAGE="tensorflow-gpu==1.8.0"; \
else \
TENSORFLOW_PACKAGE="tensorflow==1.8.0"; \
Expand All @@ -47,6 +47,6 @@ ENV PATH=$VENV/bin:$PATH

# Codacy code coverage report: used for partial code coverage reporting
RUN cd $CODE_DIR && \
curl -Ls -o codacy-coverage-reporter.jar "$(curl -Ls https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({name, browser_download_url} | select(.name | (contains("codacy-coverage-reporter") and endswith("assembly.jar")))) | .[0].browser_download_url')"
curl -Ls -o codacy-coverage-reporter.jar "$(curl -Ls https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({name, browser_download_url} | select(.name | (startswith("codacy-coverage-reporter") and contains("assembly") and endswith(".jar")))) | .[0].browser_download_url')"

CMD /bin/bash
4 changes: 4 additions & 0 deletions docs/misc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ Breaking Changes:
New Features:
^^^^^^^^^^^^^

- Docker build script, `scripts/build_docker.sh`, can push images automatically.

Bug Fixes:
^^^^^^^^^^

- Fixed Docker build script, `scripts/build_docker.sh`, to pass `USE_GPU` build argument.

Deprecations:
^^^^^^^^^^^^^

Expand Down
7 changes: 6 additions & 1 deletion scripts/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ else
TAG="${TAG}-cpu"
fi

docker build --build-arg PARENT_IMAGE=${PARENT} -t ${TAG}:${VERSION} .
docker build --build-arg PARENT_IMAGE=${PARENT} --build-arg USE_GPU=${USE_GPU} -t ${TAG}:${VERSION} .
docker tag ${TAG}:${VERSION} ${TAG}:latest

if [[ ${RELEASE} == "True" ]]; then
docker push ${TAG}:${VERSION}
docker push ${TAG}:latest
fi
2 changes: 1 addition & 1 deletion stable_baselines/common/vec_env/subproc_vec_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self, env_fns, start_method=None):
for work_remote, remote, env_fn in zip(self.work_remotes, self.remotes, env_fns):
args = (work_remote, remote, CloudpickleWrapper(env_fn))
# daemon=True: if the main process crashes, we should not cause things to hang
process = ctx.Process(target=_worker, args=args, daemon=True)
process = ctx.Process(target=_worker, args=args, daemon=True) # pytype:disable=attribute-error
process.start()
self.processes.append(process)
work_remote.close()
Expand Down
2 changes: 2 additions & 0 deletions stable_baselines/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def writekvs(self, kvs):
summary = tf.Summary(value=[summary_val(k, v) for k, v in kvs.items() if valid_float_value(v)])
event = event_pb2.Event(wall_time=time.time(), summary=summary)
event.step = self.step # is there any reason why you'd want to specify the step?
if self.writer is None:
raise ValueError("Attempt to write after close().")
self.writer.WriteEvent(event)
self.writer.Flush()
self.step += 1
Expand Down

0 comments on commit b06ab28

Please sign in to comment.