Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to PDM #49

Merged
merged 11 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .buildkite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.2.0b1 \
POETRY_HOME="/tmp/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1
PIP_DEFAULT_TIMEOUT=100

RUN apt-get -y update && \
apt-get -y install curl build-essential gcc git && \
apt-get -y clean

RUN pip install \
--no-cache-dir \
poetry==1.2.2
pdm==2.1.5

ENTRYPOINT bash
3 changes: 1 addition & 2 deletions .buildkite/install-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ set -eo pipefail

echo --- Installing dependencies

poetry install --without gpu
pip install -r .buildkite/requirements.txt
pdm install -d -G ci
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ common: &common
plugins:
- EmbarkStudios/k8s#1.2.10:
service-account-name: monorepo-ci
image: gcr.io/embark-shared/ml/ci-runner@sha256:dc0c033b862fa2ff9ac328ca2aa9b89d4bad248188d79d55ccaa12659766e809
image: gcr.io/embark-shared/ml/ci-runner@sha256:c10bd72949eca593c5b533cc62f41e6c0dc8e147accc094f9abc66840f6d0ef6
default-secret-name: buildkite-k8s-plugin
always-pull: false
<< : *small
Expand Down
3 changes: 1 addition & 2 deletions .buildkite/publish-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ gcloud config set account monorepo-ci@embark-builds.iam.gserviceaccount.com

echo --- Building docs
pushd docs
poetry env info --path
EXIT_CODE=0
make deploy || EXIT_CODE=$?

Expand All @@ -24,7 +23,7 @@ if [ $EXIT_CODE -ne 0 ]; then
EOF
else
if [[ "$BUILDKITE_BRANCH" = "main" ]]; then
gsutil rsync -r ./_build/dirhtml gs://embark-static/emote-docs
pdm run gsutil rsync -r ./_build/dirhtml gs://embark-static/emote-docs
buildkite-agent annotate "✅ New documentation deployed at https://static.embark.net/emote-docs/" --style "success" --context "sphinx"
else
buildkite-agent annotate "✅ Documentation built succesfully" --style "success" --context "sphinx"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/run-bandit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source .buildkite/install-repo.sh
echo --- Running bandit

EXIT_CODE=0
poetry run bandit --r emote experiments tests -ll > diff.txt || EXIT_CODE=$?
pdm run bandit --r emote experiments tests -ll > diff.txt || EXIT_CODE=$?

if [ $EXIT_CODE -ne 0 ]; then
cat << EOF | buildkite-agent annotate --style "error" --context "bandit"
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/run-black.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ source .buildkite/install-repo.sh
echo --- Running black

EXIT_CODE=0
poetry run black --check --diff emote > diff.txt || EXIT_CODE=$?
pdm run black --check --diff emote > diff.txt || EXIT_CODE=$?

if [ $EXIT_CODE -ne 0 ]; then
cat << EOF | buildkite-agent annotate --style "error" --context "eslint"
:warning: Your code isn't formatted by \`black\`. Please fix the below diffs, or run \`poetry run black emote\` to automatically format it.
:warning: Your code isn't formatted by \`black\`. Please fix the below diffs, or run \`pdm run black emote\` to automatically format it.

\`\`\`diff
$(cat diff.txt)
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/run-isort.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ source .buildkite/install-repo.sh
echo --- Running isort

EXIT_CODE=0
poetry run isort --check --diff emote > diff.txt || EXIT_CODE=$?
pdm run isort --check --diff emote > diff.txt || EXIT_CODE=$?
cat diff.txt

if [ $EXIT_CODE -ne 0 ]; then
cat << EOF | buildkite-agent annotate --style "error" --context "isort"
:warning: Your imports aren't sorted by \`isort\`. Please fix the below diffs, or run \`poetry run isort emote\` to automatically format it.
:warning: Your imports aren't sorted by \`isort\`. Please fix the below diffs, or run \`pdm run isort emote\` to automatically format it.

\`\`\`diff
$(cat diff.txt)
Expand Down
22 changes: 18 additions & 4 deletions .buildkite/validate-lockfile.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
set -eo pipefail

EXIT_CODE=0
poetry lock --check || EXIT_CODE=$?

pdm lock --refresh || EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
buildkite-agent annotate --style "error" --context "lockfile" ":lock: Lockfile is outdated. Please run \`poetry lock --no-update\` and commit the result."
exit 1
buildkite-agent annotate --style "error" --context "lockfile" ":lock: Failed validating lockfile. See logs for more info."
exit 1
fi

GIT_STATUS=$(git status --porcelain --untracked-files=no -- pdm.lock)
if [ -n "$GIT_STATUS" ]; then
lock_diff=$(git diff pdm.lock)
cat << EOF | buildkite-agent annotate --style "error" --context "lockfile"
:lock: Lockfile is outdated. Please run \`pdm lock --no-update\` and commit the result.

\`\`\`diff
$lock_diff
\`\`\`
EOF
exit 1
else
buildkite-agent annotate --style "success" --context "lockfile" ":lock: Lockfile is up to date."
fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ docs/coverage.rst
# Outputs from Emote and tests
*.onnx
runs/**
/.pdm.toml
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ reinforcement learning

[![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev)
[![Embark](https://img.shields.io/badge/discord-ark-%237289da.svg?logo=discord)](https://discord.gg/dAuKfZS)
[![Build status](https://badge.buildkite.com/968ac3c0bb075fb878f9f973ed91406c8b257b0f050c197542.svg?theme=github&branch=ts/docs-poetry)](https://buildkite.com/embark-studios/emote)
[![Build status](https://badge.buildkite.com/968ac3c0bb075fb878f9f973ed91406c8b257b0f050c197542.svg?theme=github&branch=main)](https://buildkite.com/embark-studios/emote)
[![Docs status](https://img.shields.io/badge/Docs-latest-brightgreen)](https://static.embark.net/emote-docs/)

🚧 This project is very much **work in progress and not yet ready for production use.** 🚧
Expand Down Expand Up @@ -109,19 +109,13 @@ class PolicyLoss(LossCallback):

## Installation

:warning: You currently **need** to use a pre-release version of the Poetry 1.2 series. :warning:

For installation and environment handling we use `poetry`. Install it from [here](https://python-poetry.org/). After `poetry` is set up, set up and activate the emote environment by running


For installation and environment handling we use `pdm`. Install it from [pdm](https://pdm.fming.dev/latest/#installation). After `pdm` is set up, set up and activate the emote environment by running

```bash
poetry install
pdm install
```




## Contribution

[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4-ff69b4.svg)](../main/CODE_OF_CONDUCT.md)
Expand Down
8 changes: 4 additions & 4 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= poetry run sphinx-build
SPHINXOPTS ?=
SPHINXBUILD ?= pdm run sphinx-build
SOURCEDIR = .
BUILDDIR = _build

Expand All @@ -20,6 +20,6 @@ help:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

deploy:
@$(SPHINXBUILD) -M coverage "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M coverage "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
cp "$(BUILDDIR)/coverage/python.txt" "$(SOURCEDIR)/coverage.rst"
@$(SPHINXBUILD) -M dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
8 changes: 4 additions & 4 deletions docs/coding-standard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allow disabling of formatting anywhere.

To run black manually, you can use the command: ::

poetry run black emote/
pdm run black emote/ tests/

Which will format all code in emote.

Expand All @@ -40,11 +40,11 @@ isort

`isort <https://github.com/PyCQA/isort>`_ is another formatting tool,
but deals only with sorting imports. Isort is configured to be
consistent with Black from within `pyproject.toml`.
consistent with Black from within `pyproject.toml`.

To run isort manually, you can use the command: ::

poetry run isort emote/
pdm run isort emote/ tests/


Example configurations
Expand All @@ -59,7 +59,7 @@ emacs
:demand t
:after python
:hook (python-mode . python-black-on-save-mode-enable-dwim))

(use-package python-isort
:demand t
:after python
Expand Down
8 changes: 3 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ for reinforcement learning written at Embark.
Installation
============

.. warning:: You'll need to use a pre-release Poetry 1.2 version, e.g. 1.2.0a1 or later. Older versions will crash while installing our dependencies.
Install `PDM <https://pdm.fming.dev/latest/#installation>`_ following the instructions on the
PDM site. Then install the package using ::

Install `Poetry <https://python-poetry.org/>`_ following the instructions on the
Poetry site. Then install the package using ::

poetry install
pdm install


Ideas and Philosophy
Expand Down
Loading