Skip to content

Commit

Permalink
Merge pull request #4 from nextmv-io/feature/eng-4277-create-workflow…
Browse files Browse the repository at this point in the history
…-for-publishingdistributing-the-package

ENG-4277 Modify workflow for PyPI and TestPYPI
  • Loading branch information
sebastian-quintero authored Dec 21, 2023
2 parents 8ffefb3 + 3d20720 commit 5bc56e8
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 41 deletions.
57 changes: 36 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
name: publish

on:
release:
types: [created]
release:
types: [created]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
publish:
runs-on: ubuntu-latest
steps:
- name: git clone
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: install dependencies
run: |
pip install --upgrade pip
pip install build twine
- name: build binary wheel and source tarball
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m build
- name: publish to TestPyPI
env:
TWINE_USERNAME: ${{ secrets.TESTPYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TESTPYPI_PASSWORD }}
run: twine upload --repository testpypi dist/*

- name: publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
2 changes: 1 addition & 1 deletion .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: git clone
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: git clone
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
72 changes: 70 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
# nextmv python package
# Nextmv Python SDK

This is a placeholder for Nextmv's Python package. Stay tuned for more information.
This is the Python SDK for the Nextmv Platform. Before starting:

1. [Sign up][signup] for a Nextmv account.
2. Get your API key. Go to [Team > API Key][api-key].

Visit the [docs][docs] for more information.

## Installation

Install using `pip`:

```bash
pip install nextmv
```

## Usage

Make sure that you have your API key set as an environment variable:

```bash
export NEXTMV_API_KEY=<your-API-key>
```

Additionally, you must have a valid app in the Nextmv Cloud.

- Make a run and get the results.

```python
import os

from nextmv.cloud import Application, Client

input = {
"defaults": {"vehicles": {"speed": 20}},
"stops": [
{
"id": "Nijō Castle",
"location": {"lon": 135.748134, "lat": 35.014239},
"quantity": -1,
},
{
"id": "Kyoto Imperial Palace",
"location": {"lon": 135.762057, "lat": 35.025431},
"quantity": -1,
},
],
"vehicles": [
{
"id": "v2",
"capacity": 2,
"start_location": {"lon": 135.728898, "lat": 35.039705},
},
],
}

client = Client(api_key=os.getenv("NEXTMV_API_KEY"))
app = Application(client=client, id="your-app-id")
result = app.new_run_with_result(
input=input,
instance_id="latest",
run_options={"solve.duration": "1s"},
)
print(result.to_dict())

```

[signup]: https://cloud.nextmv.io
[docs]: https://nextmv.io/docs
[api-key]: https://cloud.nextmv.io/team/api-keys
39 changes: 28 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
[build-system]
requires = ["hatchling >= 1.13.0"]
build-backend = "hatchling.build"
requires = ["hatchling >= 1.13.0"]

[project]
name = "nextmv"
description = "The Python SDK for Nextmv"
readme = "README.md"
requires-python = ">=3.10"
license = {file = "LICENSE"}
authors = [
{ name = "Nextmv", email = "[email protected]" }
{ email = "[email protected]", name = "Nextmv" }
]
keywords = ["nextmv", "optimization", "solver", "vehicle routing problem", "operations research", "decisions", "decision engineering"]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
]
version = "0.1.0"
dependencies = [
"pydantic>=2.5.2",
"requests>=2.31.0",
]
description = "The Python SDK for Nextmv"
keywords = [
"decision engineering",
"decision science",
"decisions",
"nextmv",
"optimization",
"operations research",
"shift scheduling",
"solver",
"vehicle routing problem",
]
license = { file = "LICENSE" }
maintainers = [
{ email = "[email protected]", name = "Nextmv" }
]
name = "nextmv"
readme = "README.md"
requires-python = ">=3.10"
version = "0.1.0.dev3"

[project.urls]
Homepage = "https://www.nextmv.io"
Documentation = "https://www.nextmv.io/docs"
Repository = "https://github.com/nextmv-io/sdk-python"
Repository = "https://github.com/nextmv-io/nextmv-py"

[tool.ruff]
target-version = "py312"
Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pydantic==2.5.2
requests==2.31.0
ruff==0.1.7
setuptools==69.0.2
wheel==0.42.0
build>=1.0.3
pydantic>=2.5.2
requests>=2.31.0
ruff>=0.1.7
twine>=4.0.2

0 comments on commit 5bc56e8

Please sign in to comment.