From e08bd69a191cc4238f7ab5cf66527e5c039c142e Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Mon, 16 Dec 2019 13:59:36 -0800 Subject: [PATCH] Run precommit in its own job, cache the data (#3094) --- .circleci/config.yml | 46 +++++++++++++++++++++++++++++----- .pre-commit-config.yaml | 5 ++-- config/offline_bc_config.yaml | 4 +-- config/sac_trainer_config.yaml | 2 -- test_requirements.txt | 1 - 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b1e7ba807b..04e8c36a77 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,12 +64,6 @@ jobs: pip freeze > test-reports/pip_versions.txt pytest --cov=ml-agents --cov=ml-agents-envs --cov=gym-unity --cov-report html --junitxml=test-reports/junit.xml -p no:warnings - - run: - name: Check Code Style using pre-commit - command: | - . venv/bin/activate - pre-commit run --show-diff-on-failure --all-files - - run: name: Verify there are no hidden/missing metafiles. # Renaming files or deleting files can leave metafiles behind that makes Unity very unhappy. @@ -88,6 +82,45 @@ jobs: path: htmlcov destination: htmlcov + pre-commit: + docker: + - image: circleci/python:3.7.3 + working_directory: ~/repo/ + + steps: + - checkout + - run: + name: Combine precommit config and python versions for caching + command: | + cat .pre-commit-config.yaml > pre-commit-deps.txt + python -VV >> pre-commit-deps.txt + + - restore_cache: + keys: + - v1-precommit-deps-{{ checksum "pre-commit-deps.txt" }} + + - run: + name: Install Dependencies + command: | + python3 -m venv venv + . venv/bin/activate + pip install --upgrade pip + pip install --upgrade setuptools + pip install pre-commit + # Install the hooks now so that they'll be cached + pre-commit install-hooks + + - save_cache: + paths: + - ~/.cache/pre-commit + - ./venv + key: v1-precommit-deps-{{ checksum "pre-commit-deps.txt" }} + + - run: + name: Check Code Style using pre-commit + command: | + . venv/bin/activate + pre-commit run --show-diff-on-failure --all-files markdown_link_check: parameters: @@ -241,6 +274,7 @@ workflows: pip_constraints: test_constraints_max_tf2_version.txt - markdown_link_check - protobuf_generation_check + - pre-commit - deploy: name: deploy ml-agents-envs directory: ml-agents-envs diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a6e56859a6..1920595894 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,14 +55,15 @@ repos: types: [markdown] - id: check-merge-conflict args: [--assume-in-merge] + - id: check-yaml + # Won't handle the templating in yamato + exclude: \.yamato/* - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.4.2 hooks: - id: python-check-mock-methods - - - repo: https://github.com/pre-commit/mirrors-pylint rev: v2.4.4 hooks: diff --git a/config/offline_bc_config.yaml b/config/offline_bc_config.yaml index 7d071505c5..7f2143c56d 100644 --- a/config/offline_bc_config.yaml +++ b/config/offline_bc_config.yaml @@ -10,7 +10,8 @@ default: num_layers: 2 sequence_length: 32 memory_size: 256 - demo_path: ./UnitySDK/Assets/Demonstrations/.demo + # Change the path here to point to your demo files + demo_path: ./UnitySDK/Assets/Demonstrations/Your_Demo_File.demo FoodCollector: trainer: offline_bc @@ -34,7 +35,6 @@ Hallway: batches_per_epoch: 5 num_layers: 2 hidden_units: 128 - sequence_length: 16 use_recurrent: true memory_size: 256 sequence_length: 32 diff --git a/config/sac_trainer_config.yaml b/config/sac_trainer_config.yaml index 809827854c..612b7f5675 100644 --- a/config/sac_trainer_config.yaml +++ b/config/sac_trainer_config.yaml @@ -206,7 +206,6 @@ Reacher: summary_freq: 3000 Hallway: - use_recurrent: true sequence_length: 32 num_layers: 2 hidden_units: 128 @@ -218,7 +217,6 @@ Hallway: use_recurrent: true VisualHallway: - use_recurrent: true sequence_length: 32 num_layers: 1 hidden_units: 128 diff --git a/test_requirements.txt b/test_requirements.txt index 58a3fe39c3..33b0fbb76b 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,4 +1,3 @@ # Test-only dependencies should go here, not in setup.py pytest>=3.2.2,<4.0.0 -pre-commit pytest-cov==2.6.1