Skip to content

Commit 9945992

Browse files
fixes CI finally (#80)
* fixes CI finally * fix lint * fix tqdm
1 parent 1779d0c commit 9945992

7 files changed

Lines changed: 130 additions & 41 deletions

File tree

.github/workflows/predicators.yml

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
cache-dependency-path: '**/setup.py'
1919
- run: |
2020
pip install -e .
21-
pip install pytest-cov
21+
pip install pytest-cov==2.12.1
2222
- name: Pytest
2323
run: |
2424
pytest -s tests/ --cov-config=.coveragerc --cov=predicators/ --cov=tests/ --cov-fail-under=100 --cov-report=term-missing:skip-covered
@@ -61,13 +61,13 @@ jobs:
6161
- name: Install dependencies
6262
run: |
6363
pip install -e .
64-
pip install pytest-pylint
64+
pip install pytest-pylint==0.18.0
6565
- name: Pylint
6666
run: |
6767
pytest . --pylint -m pylint --pylint-rcfile=.predicators_pylintrc
6868
env:
6969
PYTHONHASHSEED: 0
70-
autoformat:
70+
yapf:
7171
runs-on: ubuntu-latest
7272
strategy:
7373
matrix:
@@ -80,9 +80,56 @@ jobs:
8080
python-version: ${{ matrix.python-version }}
8181
cache: 'pip'
8282
cache-dependency-path: '**/setup.py'
83-
- name: Run YAPF to test if python code is correctly formatted
84-
uses: AlexanderMelde/yapf-action@master
83+
- name: Install dependencies
84+
run: |
85+
pip install yapf==0.32.0
86+
- name: Run yapf to detect any autoformatting changes
87+
run: |
88+
yapf --diff -r --style .style.yapf --exclude '**/third_party' predicators
89+
yapf --diff -r --style .style.yapf scripts
90+
yapf --diff -r --style .style.yapf tests
91+
yapf --diff -r --style .style.yapf setup.py
92+
env:
93+
PYTHONHASHSEED: 0
94+
isort:
95+
runs-on: ubuntu-latest
96+
strategy:
97+
matrix:
98+
python-version: [3.8]
99+
steps:
100+
- uses: actions/checkout@v2
101+
- name: Set up Python ${{ matrix.python-version }}
102+
uses: actions/setup-python@v2
103+
with:
104+
python-version: ${{ matrix.python-version }}
105+
cache: 'pip'
106+
cache-dependency-path: '**/setup.py'
107+
- name: Install dependencies
108+
run: |
109+
pip install isort==5.10.1
110+
- name: Run isort to detect any changes
111+
run: |
112+
isort --check-only .
113+
env:
114+
PYTHONHASHSEED: 0
115+
docformatter:
116+
runs-on: ubuntu-latest
117+
strategy:
118+
matrix:
119+
python-version: [3.8]
120+
steps:
121+
- uses: actions/checkout@v2
122+
- name: Set up Python ${{ matrix.python-version }}
123+
uses: actions/setup-python@v2
85124
with:
86-
args: --verbose --style .style.yapf --exclude '**/third_party'
87-
- name: Run isort to organize imports
88-
uses: isort/isort-action@master
125+
python-version: ${{ matrix.python-version }}
126+
cache: 'pip'
127+
cache-dependency-path: '**/setup.py'
128+
- name: Install dependencies
129+
run: |
130+
pip install docformatter==1.4
131+
- name: Run docformatter to detect any autoformatting changes
132+
run: |
133+
docformatter --check -r . --exclude venv predicators/third_party
134+
env:
135+
PYTHONHASHSEED: 0

mypy.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,11 @@ ignore_missing_imports = True
8383
[mypy-panda_robot_client.*]
8484
ignore_missing_imports = True
8585

86+
[mypy-gym.*]
87+
ignore_missing_imports = True
88+
89+
[mypy-gym_sokoban.*]
90+
ignore_missing_imports = True
91+
8692
[mypy-tqdm.*]
8793
ignore_missing_imports = True

predicators/pybullet_helpers/motion_planning.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,32 @@
1313

1414

1515
def run_motion_planning(
16-
robot: SingleArmPyBulletRobot, initial_positions: JointPositions,
17-
target_positions: JointPositions, collision_bodies: Collection[int],
18-
seed: int,
19-
physics_client_id: int) -> Optional[Sequence[JointPositions]]:
16+
robot: SingleArmPyBulletRobot,
17+
initial_positions: JointPositions,
18+
target_positions: JointPositions,
19+
collision_bodies: Collection[int],
20+
seed: int,
21+
physics_client_id: int,
22+
) -> Optional[Sequence[JointPositions]]:
2023
"""Run BiRRT to find a collision-free sequence of joint positions.
2124
2225
Note that this function changes the state of the robot.
2326
"""
2427
rng = np.random.default_rng(seed)
2528
joint_space = robot.action_space
2629
joint_space.seed(seed)
27-
_sample_fn = lambda _: joint_space.sample()
2830
num_interp = CFG.pybullet_birrt_extend_num_interp
2931

32+
def _sample_fn(pt: JointPositions) -> JointPositions:
33+
new_pt: JointPositions = list(joint_space.sample())
34+
# Don't change the fingers.
35+
new_pt[robot.left_finger_joint_idx] = pt[robot.left_finger_joint_idx]
36+
new_pt[robot.right_finger_joint_idx] = pt[robot.right_finger_joint_idx]
37+
return new_pt
38+
39+
def _set_state(pt: JointPositions) -> None:
40+
robot.set_joints(pt)
41+
3042
def _extend_fn(pt1: JointPositions,
3143
pt2: JointPositions) -> Iterator[JointPositions]:
3244
pt1_arr = np.array(pt1)
@@ -38,7 +50,7 @@ def _extend_fn(pt1: JointPositions,
3850
yield list(pt1_arr * (1 - i / num) + pt2_arr * i / num)
3951

4052
def _collision_fn(pt: JointPositions) -> bool:
41-
robot.set_joints(pt)
53+
_set_state(pt)
4254
p.performCollisionDetection(physicsClientId=physics_client_id)
4355
for body in collision_bodies:
4456
if p.getContactPoints(robot.robot_id,
@@ -48,6 +60,8 @@ def _collision_fn(pt: JointPositions) -> bool:
4860
return False
4961

5062
def _distance_fn(from_pt: JointPositions, to_pt: JointPositions) -> float:
63+
# NOTE: only using positions to calculate distance. Should use
64+
# orientations as well in the near future.
5165
from_ee = robot.forward_kinematics(from_pt)
5266
to_ee = robot.forward_kinematics(to_pt)
5367
return sum(np.subtract(from_ee, to_ee)**2)

scripts/analyze_results_directory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
]
5050

5151

52-
def _compute_percentage_tasks_solved(d: pd.DataFrame) -> pd.DataFrame:
52+
def _compute_percentage_tasks_solved(d: Dict[str, float]) -> float:
5353
try:
5454
ret_df = (d["num_solved"] / d["num_test_tasks"]) * 100
5555
except ZeroDivisionError:

setup.py

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,48 @@
33

44
# NOTE: Windows users will have to install windows-curses
55
# (https://pypi.org/project/windows-curses/)
6-
setup(name="predicators",
7-
version="0.1.0",
8-
packages=find_packages(include=["predicators", "predicators.*"]),
9-
install_requires=[
10-
"numpy>=1.22.3", "pytest", "gym==0.21.0", "matplotlib", "imageio",
11-
"imageio-ffmpeg", "pandas", "torch", "scipy", "tabulate", "dill",
12-
"pyperplan", "pathos", "requests", "slack_bolt", "pybullet>=3.2.0",
13-
"scikit-learn", "graphlib-backport", "openai", "pyyaml",
14-
"pylint==2.14.5", "types-PyYAML", "lisdf", "seaborn",
15-
"smepy@git+https://github.com/sebdumancic/structure_mapping.git"
16-
],
17-
include_package_data=True,
18-
extras_require={
19-
"develop": [
20-
"pytest-cov>=2.12.1",
21-
"pytest-pylint>=0.18.0",
22-
"yapf==0.32.0",
23-
"docformatter",
24-
"isort",
25-
"mypy@git+https://github.com/python/mypy.git@9bd651758e8ea2494" +
26-
"837814092af70f8d9e6f7a1",
27-
]
28-
})
6+
setup(
7+
name="predicators",
8+
version="0.1.0",
9+
packages=find_packages(include=["predicators", "predicators.*"]),
10+
install_requires=[
11+
"numpy>=1.22.3",
12+
"pytest",
13+
"gym==0.26.2",
14+
"matplotlib",
15+
"imageio",
16+
"imageio-ffmpeg",
17+
"pandas",
18+
"torch",
19+
"scipy",
20+
"tabulate",
21+
"dill",
22+
"pyperplan",
23+
"pathos",
24+
"requests",
25+
"slack_bolt",
26+
"pybullet>=3.2.0",
27+
"scikit-learn",
28+
"graphlib-backport",
29+
"openai",
30+
"pyyaml",
31+
"pylint==2.14.5",
32+
"types-PyYAML",
33+
"lisdf",
34+
"seaborn",
35+
"smepy@git+https://github.com/sebdumancic/structure_mapping.git",
36+
"pg3@git+https://github.com/tomsilver/pg3.git",
37+
"gym_sokoban@git+https://github.com/Learning-and-Intelligent-Systems/gym-sokoban.git" # pylint: disable=line-too-long
38+
],
39+
include_package_data=True,
40+
extras_require={
41+
"develop": [
42+
"pytest-cov==2.12.1",
43+
"pytest-pylint==0.18.0",
44+
"yapf==0.32.0",
45+
"docformatter==1.4",
46+
"isort==5.10.1",
47+
"mypy@git+https://github.com/python/mypy.git@9bd651758e8ea2494" +
48+
"837814092af70f8d9e6f7a1",
49+
]
50+
})

tests/approaches/test_random_actions_approach.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ def test_random_actions_approach():
2525
actions.append(act)
2626
assert env.action_space.contains(act.arr)
2727
# Test reproducibility
28-
assert str(actions) == "[Action(_arr=array([0.70787615], dtype=float32)), Action(_arr=array([0.3698764], dtype=float32)), Action(_arr=array([0.29010695], dtype=float32)), Action(_arr=array([0.10647454], dtype=float32)), Action(_arr=array([0.9975787], dtype=float32)), Action(_arr=array([0.9942262], dtype=float32)), Action(_arr=array([0.98252517], dtype=float32)), Action(_arr=array([0.55868745], dtype=float32)), Action(_arr=array([0.68523175], dtype=float32)), Action(_arr=array([0.99104315], dtype=float32))]" # pylint: disable=line-too-long
28+
assert str(actions) == "[Action(_arr=array([0.6823519], dtype=float32)), Action(_arr=array([0.05382102], dtype=float32)), Action(_arr=array([0.22035988], dtype=float32)), Action(_arr=array([0.18437181], dtype=float32)), Action(_arr=array([0.1759059], dtype=float32)), Action(_arr=array([0.8120945], dtype=float32)), Action(_arr=array([0.92334497], dtype=float32)), Action(_arr=array([0.2765744], dtype=float32)), Action(_arr=array([0.81975454], dtype=float32)), Action(_arr=array([0.8898927], dtype=float32))]" # pylint: disable=line-too-long

tests/approaches/test_random_options_approach.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _solved_classifier(s, o):
4949
policy = approach.solve(task, 500)
5050
solved = False
5151
act_var = None
52-
for _ in range(10):
52+
for _ in range(25):
5353
act = policy(state)
5454
assert act.has_option()
5555
if act_var is None:
@@ -111,4 +111,4 @@ def _solved_classifier(s, o):
111111
act_var = act.arr.item()
112112
state = _simulator(state, act)
113113
# Test reproducibility
114-
assert str(actions) == "[Action(_arr=array([0.70787615], dtype=float32)), Action(_arr=array([0.3698764], dtype=float32)), Action(_arr=array([0.29010695], dtype=float32)), Action(_arr=array([0.9975787], dtype=float32)), Action(_arr=array([0.9942262], dtype=float32)), Action(_arr=array([0.98252517], dtype=float32)), Action(_arr=array([0.55868745], dtype=float32)), Action(_arr=array([0.68523175], dtype=float32)), Action(_arr=array([0.99104315], dtype=float32)), Action(_arr=array([0.8620031], dtype=float32))]" # pylint: disable=line-too-long
114+
assert str(actions) == "[Action(_arr=array([0.6823519], dtype=float32)), Action(_arr=array([0.8120945], dtype=float32)), Action(_arr=array([0.92334497], dtype=float32)), Action(_arr=array([0.2765744], dtype=float32)), Action(_arr=array([0.81975454], dtype=float32)), Action(_arr=array([0.8898927], dtype=float32)), Action(_arr=array([0.51297045], dtype=float32)), Action(_arr=array([0.8242416], dtype=float32)), Action(_arr=array([0.74146706], dtype=float32)), Action(_arr=array([0.6299402], dtype=float32))]" # pylint: disable=line-too-long

0 commit comments

Comments
 (0)