Skip to content

Commit 783a3c3

Browse files
authored
Merge pull request #55 from APLA-Toolbox/package-pypi
Packaging Pypi
2 parents 35b1d3b + b515901 commit 783a3c3

14 files changed

+74
-33
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ on: [push]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest, macos-latest]
11+
python-version: [3.6, 3.7, 3.8]
12+
exclude:
13+
- os: macos-latest
14+
python-version: 3.8
815

916
steps:
1017
- uses: actions/checkout@v2

.github/workflows/tests.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ on: [push]
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest, macos-latest]
11+
python-version: [3.6, 3.7, 3.8]
12+
exclude:
13+
- os: macos-latest
14+
python-version: 3.8
815

916
steps:
1017
- uses: actions/checkout@v2
@@ -34,7 +41,16 @@ jobs:
3441
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3542
3643
test:
37-
runs-on: ubuntu-latest
44+
runs-on: ${{ matrix.os }}
45+
strategy:
46+
matrix:
47+
os: [ubuntu-latest, macos-latest, windows-latest]
48+
python-version: [3.6, 3.7, 3.8, pypy-3.6]
49+
exclude:
50+
- os: macos-latest
51+
python-version: 3.8
52+
- os: windows-latest
53+
python-version: 3.6
3854
steps:
3955
- uses: actions/checkout@v2
4056
- name: Set up Python 3.7

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,15 @@ $ julia --color=yes -e 'using Pkg; Pkg.add(Pkg.PackageSpec(path="https://github.
4545

4646
```bash
4747
$ python3 -m pip install --upgrade pip
48-
$ git clone https://github.com/APLA-Toolbox/PythonPDDL
49-
$ cd PythonPDDL
50-
$ python3 -m pip install -r requirements.txt
48+
$ python3 -m pip install jupyddl
5149
```
5250

53-
# Usage
54-
55-
Navigate to the root directory and you can run the tool by using : `python3 main.py "data/domain.pddl" "data/problem.pddl"`
56-
5751
# REFL Mode
5852

59-
- Clone the repository: `git clone https://github.com/APLA-Toolbox/PythonPDDL`
60-
- Move to the repository folder: `cd PythonPDDL`
6153
- Run `python3` in the terminal.
6254
- Use the AutomatedPlanner class to do what you want:
6355
```python
64-
from src.automated_planner import AutomatedPlanner # takes some time because it has to instantiate the Julia interface
56+
from jupyddl import AutomatedPlanner # takes some time because it has to instantiate the Julia interface
6557
apl = AutomatedPlanner("data/domain.pddl", "data/problem.pddl)
6658

6759
apl.initial_state
@@ -85,15 +77,11 @@ print(apl.get_actions_from_path(path))
8577
[<PyCall.jlwrap flip_row(r1)>, <PyCall.jlwrap flip_row(r3)>, <PyCall.jlwrap flip_column(c2)>]
8678
```
8779

88-
# Script mode
89-
90-
UC
91-
9280
# Contribute
9381

9482
Open an issue to state clearly the contribution you want to make. Upon aproval send in a PR with the Issue referenced. (Implement Issue #No / Fix Issue #No).
9583

96-
# Contributors
84+
# Maintainers
9785

9886
- Erwin Lejeune
9987
- Sampreet Sarkar

jupyddl/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .automated_planner import AutomatedPlanner
2+
3+
if __name__ == "__main__":
4+
_ = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
File renamed without changes.

src/automated_planner.py renamed to jupyddl/automated_planner.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def satisfies(self, asserted_state, state):
4747
def state_has_term(self, state, term):
4848
if self.pddl.has_term_in_state(self.domain, state, term):
4949
return True
50-
else:
51-
return False
50+
return False
5251

5352
def __flatten_goal(self):
5453
return self.pddl.flatten_goal(self.problem)
@@ -74,8 +73,7 @@ def get_actions_from_path(self, path):
7473
cost = self.pddl.get_value(path[-1].state, "total-cost")
7574
if not cost:
7675
return actions
77-
else:
78-
return (actions, cost)
76+
return (actions, cost)
7977

8078
def get_state_def_from_path(self, path):
8179
if not path:
@@ -92,32 +90,28 @@ def breadth_first_search(self, time_it=False):
9290
path = self.__retrace_path(last_node)
9391
if time_it:
9492
return path, total_time
95-
else:
96-
return path, None
93+
return path, None
9794

9895
def depth_first_search(self, time_it=False):
9996
dfs = DepthFirstSearch(self)
10097
last_node, total_time = dfs.search()
10198
path = self.__retrace_path(last_node)
10299
if time_it:
103100
return path, total_time
104-
else:
105-
return path, None
101+
return path, None
106102

107103
def dijktra_best_first_search(self, time_it=False):
108104
dijkstra = DijkstraBestFirstSearch(self)
109105
last_node, total_time = dijkstra.search()
110106
path = self.__retrace_path(last_node)
111107
if time_it:
112108
return path, total_time
113-
else:
114-
return path, None
109+
return path, None
115110

116111
def astar_best_first_search(self, time_it=False, heuristic=goal_count_heuristic):
117112
astar = AStarBestFirstSearch(self, heuristic)
118113
last_node, total_time = astar.search()
119114
path = self.__retrace_path(last_node)
120115
if time_it:
121116
return path, total_time
122-
else:
123-
return path, None
117+
return path, None
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

setup.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import setuptools
2+
3+
with open("requirements.txt") as f:
4+
required = f.read().splitlines()
5+
6+
with open("README.md", "r", encoding="utf-8") as fh:
7+
long_description = fh.read()
8+
9+
10+
setuptools.setup(
11+
name="jupyddl", # Replace with your own username
12+
version="0.2.4",
13+
author="Erwin Lejeune",
14+
author_email="erwinlejeune.pro@gmail.com",
15+
description="Jupyddl is a PDDL planner built on top of a Julia parser",
16+
long_description=long_description,
17+
long_description_content_type="text/markdown",
18+
url="https://github.com/apla-toolbox/pythonpddl",
19+
packages=setuptools.find_packages(),
20+
install_requires=required,
21+
classifiers=[
22+
"Programming Language :: Python :: 3 :: Only",
23+
"Programming Language :: Python :: 3.6",
24+
"Programming Language :: Python :: 3.7",
25+
"Programming Language :: Python :: 3.8",
26+
"Programming Language :: Python :: 3",
27+
"License :: OSI Approved :: Apache Software License",
28+
"Operating System :: Unix",
29+
"Operating System :: MacOS",
30+
"Framework :: Pytest",
31+
],
32+
python_requires=">=3.6",
33+
)

src/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test_automated_planner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def test_execute_action():
2828
def test_state_has_term():
2929
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
3030
is_goal = apla.state_has_term(apla.initial_state, apla.goals[0])
31-
assert is_goal == False
31+
assert not is_goal
3232

3333

3434
def test_state_assertion():
3535
apla = AutomatedPlanner("data/domain.pddl", "data/problem.pddl")
36-
assert apla.satisfies(apla.problem.goal, apla.initial_state) == False
36+
assert not apla.satisfies(apla.problem.goal, apla.initial_state)

0 commit comments

Comments
 (0)