Skip to content

Commit 30f8a7c

Browse files
ENG-4277 Create workflow for PyPI and TestPYPI
1 parent fbafcda commit 30f8a7c

File tree

7 files changed

+132
-35
lines changed

7 files changed

+132
-35
lines changed

.github/workflows/publish.yml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
11
name: publish
22

33
on:
4-
release:
5-
types: [created]
4+
release:
5+
types: [created]
66

77
jobs:
8-
deploy:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v4
12-
- name: Set up Python
13-
uses: actions/setup-python@v4
14-
with:
15-
python-version: "3.x"
16-
- name: Install dependencies
17-
run: |
18-
python -m pip install --upgrade pip
19-
pip install setuptools wheel twine
20-
- name: Build and publish
21-
env:
22-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
23-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
24-
run: |
25-
python setup.py sdist bdist_wheel
26-
twine upload dist/*
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: git clone
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.12"
18+
19+
- name: install dependencies
20+
run: |
21+
pip install --upgrade pip
22+
pip install build twine
23+
24+
- name: build binary wheel and source tarball
25+
env:
26+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
27+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
28+
run: |
29+
python -m build
30+
31+
- name: publish to TestPyPI
32+
env:
33+
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
34+
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }}
35+
run: twine upload --repository testpypi dist/*
36+
37+
- name: publish to PyPI
38+
env:
39+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
40+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
41+
run: twine upload dist/*

.github/workflows/python-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
python-version: ["3.10", "3.11", "3.12"]
99
steps:
1010
- name: git clone
11-
uses: actions/checkout@v3
11+
uses: actions/checkout@v4
1212

1313
- name: set up Python ${{ matrix.python-version }}
1414
uses: actions/setup-python@v4

.github/workflows/python-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
python-version: ["3.10", "3.11", "3.12"]
99
steps:
1010
- name: git clone
11-
uses: actions/checkout@v3
11+
uses: actions/checkout@v4
1212

1313
- name: set up Python ${{ matrix.python-version }}
1414
uses: actions/setup-python@v4

README.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,71 @@
1-
# nextmv python package
1+
# Nextmv Python SDK
22

3-
This is a placeholder for Nextmv's Python package. Stay tuned for more information.
3+
This is the Python SDK for the Nextmv Platform. Before starting:
4+
5+
1. [Sign up][signup] for a Nextmv account.
6+
2. Get your API key. Go to [Team > API Key][api-key].
7+
8+
Visit the [docs][docs] for more information.
9+
10+
## Installation
11+
12+
Install using `pip`:
13+
14+
```bash
15+
pip install nextmv
16+
```
17+
18+
## Usage
19+
20+
Make sure that you have your API key set as an environment variable:
21+
22+
```bash
23+
export NEXTMV_API_KEY=<your-API-key>
24+
```
25+
26+
Additionally, you must have a valid app pushed to the Nextmv Cloud.
27+
28+
- Make a run and get the results.
29+
30+
```python
31+
import os
32+
33+
from nextmv.cloud import Application, Client
34+
35+
input = {
36+
"defaults": {"vehicles": {"speed": 20}},
37+
"stops": [
38+
{
39+
"id": "Nijō Castle",
40+
"location": {"lon": 135.748134, "lat": 35.014239},
41+
"quantity": -1,
42+
},
43+
{
44+
"id": "Kyoto Imperial Palace",
45+
"location": {"lon": 135.762057, "lat": 35.025431},
46+
"quantity": -1,
47+
},
48+
],
49+
"vehicles": [
50+
{
51+
"id": "v2",
52+
"capacity": 2,
53+
"start_location": {"lon": 135.728898, "lat": 35.039705},
54+
},
55+
],
56+
}
57+
58+
client = Client(api_key=os.getenv("NEXTMV_API_KEY"))
59+
app = Application(client=client, id="your-app-id")
60+
result = app.new_run_with_result(
61+
input=input,
62+
instance_id="latest",
63+
run_options={"solve.duration": "1s"},
64+
)
65+
print(result.to_dict())
66+
67+
```
68+
69+
[signup]: https://cloud.nextmv.io
70+
[docs]: https://nextmv.io/docs
71+
[api-key]: https://cloud.nextmv.io/team/api-keys

nextmv/cloud/application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ class Metadata(BaseModel):
5656
class PollingOptions(BaseModel):
5757
"""Options to use when polling for a run result."""
5858

59-
backoff: float = 1.5
59+
backoff: float = 1
6060
"""Backoff factor to use between polls."""
6161
delay: float = 1
6262
"""Delay to use between polls, in seconds."""
6363
initial_delay: float = 1
64-
"""Initial delay to use between polls, in seconds."""
64+
"""Initial delay to use before polling, in seconds."""
6565
max_duration: float = 60
6666
"""Maximum duration of the polling strategy, in seconds."""
6767
max_tries: int = 10

pyproject.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,32 @@ license = {file = "LICENSE"}
1111
authors = [
1212
{ name = "Nextmv", email = "tech@nextmv.io" }
1313
]
14-
keywords = ["nextmv", "optimization", "solver", "vehicle routing problem", "operations research", "decisions", "decision engineering"]
14+
keywords = [
15+
"nextmv",
16+
"optimization",
17+
"decision science",
18+
"operations research",
19+
"solver",
20+
"vehicle routing problem",
21+
"shift scheduling",
22+
"decisions",
23+
"decision engineering",
24+
]
1525
classifiers = [
1626
"Programming Language :: Python :: 3",
1727
"License :: OSI Approved :: Apache Software License",
1828
"Operating System :: OS Independent",
1929
]
20-
version = "0.1.0"
30+
version = "0.1.0-dev.0"
31+
dependencies = [
32+
"pydantic>=2.5.2,<3.0.0",
33+
"requests>=2.31.0,<3.0.0",
34+
]
2135

2236
[project.urls]
2337
Homepage = "https://www.nextmv.io"
2438
Documentation = "https://www.nextmv.io/docs"
25-
Repository = "https://github.com/nextmv-io/sdk-python"
39+
Repository = "https://github.com/nextmv-io/nextmv-py"
2640

2741
[tool.ruff]
2842
target-version = "py312"

requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pydantic==2.5.2
2-
requests==2.31.0
3-
ruff==0.1.7
4-
setuptools==69.0.2
5-
wheel==0.42.0
1+
build==1.0.3,<2.0.0
2+
pydantic>=2.5.2,<3.0.0
3+
requests==2.31.0,<3.0.0
4+
ruff==0.1.7,<0.2.0
5+
twine==4.0.2,<5.0.0

0 commit comments

Comments
 (0)