Skip to content

Commit

Permalink
Merge 'Prep release v0.24.0'
Browse files Browse the repository at this point in the history
See merge request askanna/askanna-cli!296
  • Loading branch information
robbertbos committed Feb 21, 2024
2 parents 73498c9 + 27b2422 commit 0063f22
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 76 deletions.
46 changes: 20 additions & 26 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ stages:
- release
- publish

include:
- template: Code-Quality.gitlab-ci.yml

.test_template: &test_template
.test_template:
stage: test
image: python:3-slim
before_script:
- apt-get update && apt-get install -y git
- apt-get update && apt-get install --no-install-recommends --assume-yes git
- pip install hatch
tags:
- kubernetes

.twine_template: &twine_template
.twine_template:
stage: publish
image: python:3-slim
tags:
Expand All @@ -26,7 +23,7 @@ include:
- pip install build twine
- python -m build

.publish_to_git_template: &publish_to_git_template
.publish_to_git_template:
stage: publish
needs:
- job: twine check
Expand Down Expand Up @@ -55,24 +52,21 @@ include:
- git remote add public $GIT_REPO
- git push public $TARGET

code_quality:
rules:
- if: $CODE_QUALITY_DISABLED
when: never
- if: ($CI_COMMIT_BRANCH == "main" || $CI_COMMIT_TAG)
when: never
- if: $CI_COMMIT_BRANCH
before_script:
- echo -e "[pycodestyle]\nmax-line-length = 119" > setup.cfg
- echo -e "rule 'MD013', :line_length = 119" > .mdlrc

lint:
<<: *test_template
extends: .test_template
script:
- hatch run +py=3 test:lint

pre-commit:
extends: .test_template
before_script:
- apt-get update && apt-get install --no-install-recommends --assume-yes git
- pip install pre-commit
script:
- pre-commit run --all-files

coverage:
<<: *test_template
extends: .test_template
script:
- hatch run +py=3 test:cov
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
Expand All @@ -88,7 +82,7 @@ coverage:
junit: junit.xml

pytest:
<<: *test_template
extends: .test_template
parallel:
matrix:
- PY_VERSION: ["3", "3.8", "3.9", "3.10", "3.11", "3.12"]
Expand All @@ -97,7 +91,7 @@ pytest:
- hatch run +py=$PY_VERSION test:pytest

twine check:
<<: *twine_template
extends: .twine_template
stage: test
script:
- twine check dist/*
Expand Down Expand Up @@ -169,7 +163,7 @@ release:
description: $CI_COMMIT_TAG_MESSAGE

publish to pypi:
<<: *twine_template
extends: .twine_template
needs:
- job: twine check
- job: pytest
Expand All @@ -180,7 +174,7 @@ publish to pypi:
- python -m twine upload --verbose --non-interactive --config-file ~/.pypirc -r pypi dist/*

publish to testpypi:
<<: *twine_template
extends: .twine_template
needs:
- job: twine check
rules:
Expand Down Expand Up @@ -228,14 +222,14 @@ publish to docker:
- docker logout

publish to gitlab:
<<: *publish_to_git_template
extends: .publish_to_git_template
variables:
SSH_PRIVATE_KEY_GIT: $SSH_PRIVATE_KEY_GITLAB_COM
GIT_HOST: gitlab.com
GIT_REPO: [email protected]:askanna/askanna-python.git

publish to github:
<<: *publish_to_git_template
extends: .publish_to_git_template
variables:
SSH_PRIVATE_KEY_GIT: $SSH_PRIVATE_KEY_GITHUB_COM
GIT_HOST: github.com
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,37 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.36.0
rev: v0.39.0
hooks:
- id: markdownlint

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.1
rev: v0.2.2
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix

- repo: https://github.com/ambv/black
rev: 23.10.0
rev: 24.2.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.7
hooks:
- id: bandit
additional_dependencies: ["toml"]
args: [--configfile, pyproject.toml]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
hooks:
- id: pyupgrade
args:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.24.0 (2024-02-21)

- Add support for Python 3.12 and drop support for Python 3.7
- Add created_by info to Workspace & Project dataclasses

## 0.23.0 (2023-04-05)

- Added new run filters: `status`, `trigger`, `created_by` and `package_suuid`
Expand Down
2 changes: 1 addition & 1 deletion askanna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The AskAnna CLI & Python SDK is part of the AskAnna platform to kickstart your data science projects.
"""

__version__ = "0.23.0"
__version__ = "0.24.0"

import re
import sys
Expand Down
6 changes: 1 addition & 5 deletions askanna/cli/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from typing import get_args

import click

Expand All @@ -15,11 +16,6 @@
from askanna.core.exceptions import GetError, PatchError
from askanna.sdk.run import RunSDK

try:
from typing import get_args
except ImportError: # pragma: no cover
from typing_extensions import get_args

HELP = """
This command will allow you to start a run in AskAnna.
"""
Expand Down
2 changes: 1 addition & 1 deletion askanna/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def read_config_from_url(url: str) -> Dict:
Get config from URL and return it as dict
"""
try:
r = requests.get(url)
r = requests.get(url, timeout=60)
except requests.exceptions.ConnectionError:
click.echo(f"Cannot open URL: {url}", err=True)
sys.exit(1)
Expand Down
7 changes: 1 addition & 6 deletions askanna/core/dataclasses/base.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import datetime
from dataclasses import dataclass
from typing import Any, Dict

try:
from typing import Literal
except ImportError: # pragma: no cover
from typing_extensions import Literal
from typing import Any, Dict, Literal

VISIBILITY = Literal["private", "public", "PRIVATE", "PUBLIC"]

Expand Down
2 changes: 1 addition & 1 deletion askanna/core/dataclasses/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dateutil import parser as dateutil_parser

from .base import VISIBILITY
from .relation import PackageRelation, CreatedByWithAvatarRelation, WorkspaceRelation
from .relation import CreatedByWithAvatarRelation, PackageRelation, WorkspaceRelation


@dataclass
Expand Down
15 changes: 5 additions & 10 deletions askanna/core/dataclasses/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,23 @@ def from_dict(cls, data: Dict[str, str]):


@dataclass
class WorkspaceRelation(BaseRelation):
...
class WorkspaceRelation(BaseRelation): ...


@dataclass
class ProjectRelation(BaseRelation):
...
class ProjectRelation(BaseRelation): ...


@dataclass
class PackageRelation(BaseRelation):
...
class PackageRelation(BaseRelation): ...


@dataclass
class JobRelation(BaseRelation):
...
class JobRelation(BaseRelation): ...


@dataclass
class RunRelation(BaseRelation):
...
class RunRelation(BaseRelation): ...


@dataclass
Expand Down
7 changes: 1 addition & 6 deletions askanna/core/dataclasses/run.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import json
from dataclasses import dataclass, field
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Literal, Optional, Union

from dateutil import parser as dateutil_parser

Expand All @@ -19,11 +19,6 @@
WorkspaceRelation,
)

try:
from typing import Literal
except ImportError: # pragma: no cover
from typing_extensions import Literal

STATUS = Literal["queued", "running", "finished", "failed"]
TRIGGER = Literal["api", "cli", "python-sdk", "webui", "schedule", "worker"]

Expand Down
2 changes: 1 addition & 1 deletion askanna/core/utils/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update_available() -> bool:
is available, return a info message with update instructions.
"""
try:
r = requests.get(PYPI_PROJECT_URL)
r = requests.get(PYPI_PROJECT_URL, timeout=60)
except requests.exceptions.ConnectionError:
return False
except requests.exceptions.HTTPError:
Expand Down
1 change: 1 addition & 0 deletions askanna/init.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This file contains anything that needs to be loaded for `import askanna` to work."""

import click

from askanna import USING_ASKANNA_CLI
Expand Down
26 changes: 14 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ dependencies = [

[project.optional-dependencies]
test = [
"faker~=19.11.0",
"numpy>=1.24.4", # numpy is only required for testing numpy support on supported data types
"pytest~=7.4.2",
"faker~=23.2.1",
"numpy>=1.24.4", # only required for testing NumPy support; NumPy 1.24.4 is latest version supported on Python 3.8
"pytest~=8.0.1",
"pytest-cov~=4.1.0",
"responses~=0.23.3",
"ruff~=0.1.1",
"responses~=0.25.0",
"ruff~=0.2.2",
"urllib3~=1.26.18",
]
dev = [
"askanna[test]",
"bandit~=1.7.5",
"black~=23.10.0",
"hatch~=1.7.0",
"isort~=5.12.0",
"pre-commit~=3.0.0",
"python-dotenv~=0.21.1",
"bandit~=1.7.7",
"black~=24.2.0",
"hatch~=1.9.3",
"isort~=5.13.2",
"pre-commit~=3.6.2",
"python-dotenv~=1.0.1",
]

[project.urls]
Expand Down Expand Up @@ -147,8 +147,10 @@ known_first_party = ["askanna"]
skips = ["B101"]

[tool.ruff]
target-version = "py37"
target-version = "py38"
line-length = 119

[tool.ruff.lint]
select = [
"F", # pyflakes
"E", # pycodestyle errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
url = f"https://api.askanna.eu/v1/result/{run_selected.suuid}/"
token = "Token " + os.getenv("AA_TOKEN")
headers = {"Authorization": token}
response = requests.get(url, headers=headers)
response = requests.get(url, headers=headers, timeout=60)

with open("model/model.pkl", "wb") as f:
f.write(response.content)
Expand Down

0 comments on commit 0063f22

Please sign in to comment.