-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconfig.yml
More file actions
158 lines (138 loc) · 4.81 KB
/
config.yml
File metadata and controls
158 lines (138 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# Copyright 2020 Adam Gleave
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
version: 2.1
orbs:
codecov: codecov/codecov@1.1.0
defaults: &defaults
docker:
- image: humancompatibleai/evaluating_rewards:base
auth:
username: $DOCKERHUB_USERNAME
password: $DOCKERHUB_PASSWORD
working_directory: /evaluating-rewards
environment_defaults: &environment_defaults
# If you change these, also change scripts/code_checks.sh
SRC_FILES: src/ tests/ setup.py
TYPECHECK_FILES: src/ # tests often do weird things with types, exclude
# Don't use auto-detect since it sees all CPUs available, but container is throttled.
executors:
unit-test:
<<: *defaults
resource_class: xlarge
environment:
<<: *environment_defaults
# Don't use auto-detect since it sees all CPUs available, but container is throttled.
NUM_CPUS: 8
lintandtype:
<<: *defaults
resource_class: medium
environment:
<<: *environment_defaults
# Don't use auto-detect since it sees all CPUs available, but container is throttled.
NUM_CPUS: 2
commands:
dependencies:
# You must still manually update the Docker image if any
# binary (non-Python) dependencies change.
description: "Check out and update Python dependencies."
steps:
- checkout
# Download and cache dependencies
# Note you will still need to manually update the Docker image if any
# binary (non-Python) dependencies change.
- restore_cache:
keys:
- v2-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
- run:
name: install dependencies
# MUJOCO_KEY is defined in a CircleCI context
# Do some sanity checks to make sure key works
command: "[[ -d /venv ]] || /evaluating-rewards/scripts/build_venv.sh /venv"
- save_cache:
paths:
- /venv
key: v2-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
- run:
name: install evaluating_rewards
# Build a wheel then install to avoid copying whole directory (pip issue #2195)
command: |
python setup.py sdist bdist_wheel
pip install --upgrade --force-reinstall --no-deps dist/evaluating_rewards-*.whl
jobs:
lintandtype:
executor: lintandtype
steps:
- dependencies
- run:
name: flake8
command: flake8 ${SRC_FILES}
- run:
name: black
command: black --check ${SRC_FILES}
- run:
name: codespell
command: codespell -I .codespell.skip --skip='*.pyc,*.pdf,*.png.*.pkl,*.json' ${SRC_FILES}
- run:
name: pylint
command: pylint --extension-pkg-whitelist=numpy -j ${NUM_CPUS} ${SRC_FILES}
- run:
name: pytype
command: pytype -j ${NUM_CPUS} ${TYPECHECK_FILES}
unit-test:
executor: unit-test
parallelism: 2
steps:
- dependencies
- run:
name: Memory Monitor
command: |
mkdir /tmp/resource-usage
export FILE=/tmp/resource-usage/memory.txt
while true; do
ps -u root eo pid,%cpu,%mem,args,uname --sort=-%mem >> $FILE
echo "----------" >> $FILE
sleep 1
done
background: true
- run:
name: run tests
command: |
pytest --cov=/venv/lib/python3.7/site-packages/evaluating_rewards --cov=tests \
--junitxml=/tmp/test-reports/junit.xml --no-success-flaky-report \
--shard-id=${CIRCLE_NODE_INDEX} --num-shards=${CIRCLE_NODE_TOTAL} \
--nb-test-files -n ${NUM_CPUS} -vv tests/ examples/
mv .coverage .coverage.eval
coverage combine # rewrite paths from virtualenv to src/
- codecov/upload
- store_artifacts:
path: /tmp/test-reports
destination: test-reports
- store_artifacts:
path: /tmp/resource-usage
destination: resource-usage
- store_test_results:
path: /tmp/test-reports
unit-test:
workflows:
version: 2
test:
jobs:
- lintandtype:
context:
- MuJoCo
- docker-hub-creds
- unit-test:
context:
- MuJoCo
- docker-hub-creds