Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: backport CLI fixes to Python 3.6 #192

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
96f23e8
tests: fix missing setuptools dependency
alvarolopez Jun 11, 2024
9a9602e
feat: add -dev suffix to the version when installed as dev
alvarolopez Jun 10, 2024
097cc83
feat!: remove deprecated deepaas-predict
alvarolopez Jun 7, 2024
7b5896d
fix: remove deprecated cli option
alvarolopez Jun 7, 2024
010df7b
test: fix async tests
alvarolopez Jun 10, 2024
4c5a6fa
test: fix async call
alvarolopez Jun 10, 2024
b2cdd4b
tests: update tox.ini
alvarolopez Jun 10, 2024
242e02e
fix: allow users to setup base_path for serving under a different prefix
alvarolopez Jun 11, 2024
376b0f9
feat!: remove automatic loading of deprecated deepaas-test model
alvarolopez Jun 10, 2024
b45ebf9
tests: add asyncio testing with pytest
alvarolopez Jun 10, 2024
586fcb4
tests: include poetry plugin explicitly
alvarolopez Jun 11, 2024
25a0cab
tests: migrate cmd tests to pytest
alvarolopez Jun 10, 2024
6162ecd
tests: migrate models and wrapper test to pytest
alvarolopez Jun 10, 2024
eb75c7b
tests: migrate API versions tests to pytest
alvarolopez Jun 10, 2024
0728807
tests: migrate API and API V2 tests to pytest
alvarolopez Jun 11, 2024
8c54128
tests: remove base tests, as not used anymore
alvarolopez Jun 11, 2024
903e6ec
docs: fix doc build
alvarolopez Jun 11, 2024
80003c3
feat!: remove loading of various modules
alvarolopez Jun 10, 2024
033a085
feat!: remove oslo.log and use standard python logging
alvarolopez Jun 10, 2024
f4e9ec4
fix: make description optional
IgnacioHeredia Apr 26, 2024
ecff7f6
feat: allow multiple input files
IgnacioHeredia May 6, 2024
31d950c
refactor: remove unneeded check
IgnacioHeredia May 14, 2024
3fd3b55
feat: allow linebreaks in help messages
IgnacioHeredia May 14, 2024
77d40b4
feat: add required info to help message
IgnacioHeredia May 14, 2024
0749057
feat: add types to help message
IgnacioHeredia May 14, 2024
ad1ffd7
feat: properly support lists and dicts in argparse
IgnacioHeredia May 16, 2024
43c4a6f
style: organize `_fields_to_dict` code
IgnacioHeredia May 16, 2024
b4f7fd3
feat: support bools
IgnacioHeredia May 17, 2024
111eb76
style: fix flake8
IgnacioHeredia May 17, 2024
47d357f
style: fix black
IgnacioHeredia May 17, 2024
66906f5
ci: watch also 2.x branch for releases
alvarolopez Aug 6, 2024
97c8703
fix: change target branch on release-please action
alvarolopez Aug 6, 2024
86886a1
fix: change deprecated GH action
alvarolopez Aug 6, 2024
4bdc67e
ci: fix glob pattern
alvarolopez Aug 8, 2024
f619ebd
ci: fix package build, using trusted publisher
alvarolopez Aug 8, 2024
4364a52
Revert "ci: fix package build, using trusted publisher"
alvarolopez Aug 8, 2024
260ee7e
ci: fix CI build and publish
alvarolopez Aug 8, 2024
82a18f2
fix: do not pass basePath to aiohttp_apispec
alvarolopez Aug 9, 2024
c30db00
fix: also serve static_path from base_path
alvarolopez Aug 9, 2024
01a25db
docs: update badges
alvarolopez Aug 22, 2024
175368a
tests: move to Python 3.12
alvarolopez Aug 27, 2024
dfcfede
tests: move to AI4OS Hub CI Images
alvarolopez Aug 27, 2024
0a40d2f
chore: configure release-please as python
alvarolopez Sep 26, 2024
b6c97cc
chore: bump GH actions versions
alvarolopez Sep 26, 2024
835a4b8
feat: restore compatibility with Python 3.6
IgnacioHeredia Oct 17, 2024
1be3c1c
feat: adapt CLI to 3.6
IgnacioHeredia Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Python package
name: CI tests via tox

on:
push:
branches:
- "*"
- '**'

pull_request:
branches:
- "*"
- '**'

jobs:
build:
Expand All @@ -17,9 +17,9 @@ jobs:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -35,10 +35,10 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand All @@ -49,8 +49,7 @@ jobs:

- name: Build and publish
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: |
poetry build
poetry publish
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches:
- master
- 'releases/**'

permissions:
contents: write
Expand All @@ -13,22 +14,25 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
- uses: googleapis/release-please-action@v4
id: release
with:
# this assumes that you have created a personal access token
# (PAT) and configured it as a GitHub action secret named
# `MY_RELEASE_PLEASE_TOKEN` (this secret name is not important).
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
release-type: python
# The short ref name of the branch or tag that triggered
# the workflow run. For example, `main` or `1.x`
target-branch: ${{ github.ref_name }}

- uses: actions/checkout@v4
- name: tag major and minor versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/googleapis/release-please-action.git"
git tag -d v${{ steps.release.outputs.major }} || true
git tag -d v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }} || true
git push origin :v${{ steps.release.outputs.major }} || true
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.4.0"
".": "2.5.2"
}
2 changes: 1 addition & 1 deletion .sqa/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.6"

services:
DEEPaaS-testing:
image: "indigodatacloud/ci-images:python3.11"
image: "ai4oshub/ci-images:python3.12"
hostname: "deepaas-testing"
volumes:
- type: bind
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![fair-software.eu](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F-green)](https://fair-software.eu)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9063/badge)](https://www.bestpractices.dev/projects/9063)
[![GitHub license](https://img.shields.io/github/license/indigo-dc/DEEPaaS.svg)](https://github.com/indigo-dc/DEEPaaS/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/indigo-dc/DEEPaaS.svg)](https://github.com/indigo-dc/DEEPaaS/releases)
[![GitHub license](https://img.shields.io/github/license/ai4os/DEEPaaS.svg)](https://github.com/ai4os/DEEPaaS/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/ai4os/DEEPaaS.svg)](https://github.com/ai4os/DEEPaaS/releases)
[![PyPI](https://img.shields.io/pypi/v/deepaas.svg)](https://pypi.python.org/pypi/deepaas)
[![Python versions](https://img.shields.io/pypi/pyversions/deepaas.svg)](https://pypi.python.org/pypi/deepaas)
[![Build Status](https://jenkins.services.ai4os.eu/job/AI4OS/job/DEEPaaS/job/master/badge/icon)](https://jenkins.services.ai4os.eu/job/AI4OS/job/DEEPaaS/job/master/)
Expand Down
21 changes: 20 additions & 1 deletion deepaas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,23 @@
# License for the specific language governing permissions and limitations
# under the License.

__version__ = "2.4.0"
from contextlib import suppress
# import importlib.metadata # does not work with 3.6
from pathlib import Path

__version__ = "2.5.2"


def extract_version() -> str:
"""Returns either the version of the package installed."""
with suppress(FileNotFoundError, StopIteration):
root_dir = Path(__file__).parent.parent
with open(root_dir / "pyproject.toml", encoding="utf-8") as pyproject_toml:
version = (
next(line for line in pyproject_toml if line.startswith("version"))
.split("=")[1]
.strip("'\"\n ")
)
return f"{version}-dev (at {root_dir})"
# return importlib.metadata.version(__package__ or __name__.split(".", maxsplit=1)[0])
return __version__
30 changes: 23 additions & 7 deletions deepaas/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
# License for the specific language governing permissions and limitations
# under the License.

import pathlib

from aiohttp import web
import aiohttp_apispec
from oslo_config import cfg
from oslo_log import log as logging

import deepaas
from deepaas.api import v2
from deepaas.api import versions
from deepaas import log
from deepaas import model

LOG = logging.getLogger(__name__)
LOG = log.getLogger(__name__)

APP = None

Expand Down Expand Up @@ -75,10 +76,22 @@ async def get_app(
model.register_v2_models(APP)

v2app = v2.get_app(enable_train=enable_train, enable_predict=enable_predict)
APP.add_subapp("/v2", v2app)
if base_path:
path = str(pathlib.Path(base_path) / "v2")
else:
path = "/v2"
APP.add_subapp(path, v2app)
versions.register_version("stable", v2.get_version)

APP.add_routes(versions.routes)
if base_path:
# Get versions.routes, and transform them to have the base_path, as we cannot
# directly modify the routes already created and stored in the RouteTableDef
for route in versions.routes:
APP.router.add_route(
route.method, str(pathlib.Path(base_path + route.path)), route.handler
)
else:
APP.add_routes(versions.routes)

LOG.info("Serving loaded V2 models: %s", list(model.V2_MODELS.keys()))

Expand All @@ -88,6 +101,10 @@ async def get_app(
await m.warm()

if swagger:
doc = str(pathlib.Path(base_path + doc))
swagger = str(pathlib.Path(base_path + "/swagger.json"))
static_path = str(pathlib.Path(base_path + static_path))

# init docs with all parameters, usual for ApiSpec
aiohttp_apispec.setup_aiohttp_apispec(
app=APP,
Expand All @@ -99,9 +116,8 @@ async def get_app(
"description": "API documentation",
"url": "https://deepaas.readthedocs.org/",
},
basePath=base_path,
version=deepaas.__version__,
url="/swagger.json",
version=deepaas.extract_version(),
url=swagger,
swagger_path=doc if enable_doc else None,
prefix=prefix,
static_path=static_path,
Expand Down
2 changes: 1 addition & 1 deletion deepaas/api/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
from aiohttp import web
import aiohttp_apispec
from oslo_config import cfg
from oslo_log import log

from deepaas.api.v2 import debug as v2_debug
from deepaas.api.v2 import models as v2_model
from deepaas.api.v2 import predict as v2_predict
from deepaas.api.v2 import responses
from deepaas.api.v2 import train as v2_train
from deepaas import log

CONF = cfg.CONF
LOG = log.getLogger("deepaas.api.v2")
Expand Down
3 changes: 2 additions & 1 deletion deepaas/api/v2/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from aiohttp import web
import aiohttp_apispec
from oslo_config import cfg
from oslo_log import log

from deepaas import log

CONF = cfg.CONF

Expand Down
2 changes: 1 addition & 1 deletion deepaas/api/v2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

from aiohttp import web
import aiohttp_apispec
from oslo_log import log
from webargs import aiohttpparser
import webargs.core

from deepaas.api.v2 import responses
from deepaas.api.v2 import utils
from deepaas import log
from deepaas import model

LOG = log.getLogger("deepaas.api.v2.train")
Expand Down
2 changes: 1 addition & 1 deletion deepaas/api/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
routes = web.RouteTableDef()


@routes.view("/")
@routes.view("/", name="versions")
class Versions(web.View):
versions = {}

Expand Down
Loading
Loading