Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

Commit

Permalink
chore(infra): PDM (#209)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
  • Loading branch information
frostming and aarnphm authored Jul 21, 2023
1 parent 4584c4d commit fdb8fae
Show file tree
Hide file tree
Showing 23 changed files with 2,177 additions and 3,236 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[flake8]
ignore = E203, E266, W503, E402
max-line-length = 88
exclude = .venv
36 changes: 20 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ name: Bentoctl-CI
on:
push:
branches: [ main ]
paths-ignore:
- 'docs/**'
- '*.md'
pull_request:
branches: [ main ]
paths-ignore:
- 'docs/**'
- '*.md'
# schedule:
# - cron '0 2 * * *'

Expand All @@ -17,44 +23,42 @@ jobs:
lint_and_format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: 3.7
- name: Install Poetry
uses: snok/install-poetry@v1
python-version: '3.10'
cache: 'true'

- name: Install test dependencies
run: ./ci/install_test_deps.sh.cmd
run: pdm install
- name: Run linting script
run: ./ci/linter.sh
run: pdm lint

unit_tests:
name: ${{ matrix.os }} Python ${{ matrix.python-version }} Unit Tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9' ]
python-version: [ '3.8', '3.11' ]
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all tags and branches

- name: Setup python
uses: actions/setup-python@v2
uses: pdm-project/setup-pdm@v3
with :
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install Poetry
uses: snok/install-poetry@v1
cache: 'true'

- name: Install test dependencies
run: ./ci/install_test_deps.sh.cmd
run: pdm install

- name: Run unit-tests
run: ./ci/unit_tests.sh
run: pdm test
shell: bash

- name: Upload test coverage to Codecov
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Release

on:
push:
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade build
- name: Build
run: python -m build
- name: Archive
uses: actions/upload-artifact@v2
with:
name: dist
path: dist/*

release:
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
__pycache__
__pycache__/
*.egg-info/
testop_spec.yaml
.idea/
.DS_Store
.coverage
dist/*
dist/
unit.xml

site
.pdm-build/
.pdm-python
13 changes: 0 additions & 13 deletions Makefile

This file was deleted.

29 changes: 20 additions & 9 deletions bentoctl/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from bentoml_cli.utils import validate_docker_tag
except ImportError:
logger.warning(
"'bentoml._internal.utils.docker.validate_tag not imported. Validation dissabled"
"'bentoml._internal.utils.docker.validate_tag' not imported. "
"Validation dissabled."
)
validate_docker_tag = None

Expand Down Expand Up @@ -156,7 +157,8 @@ def generate(deployment_config_file, values_only, save_path):
"--allow",
multiple=True,
default=None,
help="Allow extra privileged entitlement (e.g., 'network.host', 'security.insecure').",
help="Allow extra privileged entitlement "
"(e.g., 'network.host', 'security.insecure').",
)
@click.option("--build-arg", multiple=True, help="Set build-time variables.")
@click.option(
Expand All @@ -174,19 +176,22 @@ def generate(deployment_config_file, values_only, save_path):
"--cache-from",
multiple=True,
default=None,
help="External cache sources (e.g., 'user/app:cache', 'type=local,src=path/to/dir').",
help="External cache sources "
"(e.g., 'user/app:cache', 'type=local,src=path/to/dir').",
)
@click.option(
"--cache-to",
multiple=True,
default=None,
help="Cache export destinations (e.g., 'user/app:cache', 'type=local,dest=path/to/dir').",
help="Cache export destinations "
"(e.g., 'user/app:cache', 'type=local,dest=path/to/dir').",
)
@click.option(
"--load",
is_flag=True,
default=True,
help="Shorthand for '--output=type=docker'. Note that '--push' and '--load' are mutually exclusive.",
help="Shorthand for '--output=type=docker'. "
"Note that '--push' and '--load' are mutually exclusive.",
)
@click.option(
"--no-cache",
Expand All @@ -210,7 +215,8 @@ def generate(deployment_config_file, values_only, save_path):
"--progress",
default="auto",
type=click.Choice(["auto", "tty", "plain"]),
help="Set type of progress output ('auto', 'plain', 'tty'). Use plain to show container output.",
help="Set type of progress output ('auto', 'plain', 'tty'). "
"Use plain to show container output.",
)
@click.option(
"--pull",
Expand All @@ -222,7 +228,8 @@ def generate(deployment_config_file, values_only, save_path):
"--push",
is_flag=True,
default=False,
help="Shorthand for '--output=type=registry'. Note that '--push' and '--load' are mutually exclusive.",
help="Shorthand for '--output=type=registry'. "
"Note that '--push' and '--load' are mutually exclusive.",
)
@click.option(
"--target",
Expand Down Expand Up @@ -293,11 +300,15 @@ def build(
if platform and len(platform) > 1:
if not push:
click.echo(
"Multiple '--platform' arguments were found. Make sure to also use '--push' to push images to a repository or generated images will not be saved. For more information, see https://docs.docker.com/engine/reference/commandline/buildx_build/#load."
"Multiple '--platform' arguments were found. "
"Make sure to also use '--push' to push images to a repository or "
"generated images will not be saved. For more information, see "
"https://docs.docker.com/engine/reference/commandline/buildx_build/#load." # noqa: E501
)
if push:
click.echo(
"'--push' flag detected. bentoctl will not attempt to create repository and push image into it."
"'--push' flag detected. bentoctl will not attempt to "
"create repository and push image into it."
)
load = False
dry_run = True
Expand Down
6 changes: 5 additions & 1 deletion bentoctl/deployment_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ def create_deployable(self, destination_dir=os.curdir) -> str:
)

def create_repository(self):
(repository_url, username, password,) = self.operator.create_repository(
(
repository_url,
username,
password,
) = self.operator.create_repository(
repository_name=self.repository_name,
operator_spec=self.operator_spec,
)
Expand Down
1 change: 0 additions & 1 deletion bentoctl/utils/operator_helpers/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def generate_terraform_template(self, _, destination_dir: str):

@staticmethod
def generate_terraform_values(name: str, spec: dict, destination_dir: str):

params = DeploymentValues(name, spec, "terraform")
values_file = os.path.join(destination_dir, TERRAFORM_VALUES_FILE_NAME)
params.to_params_file(values_file)
Expand Down
1 change: 0 additions & 1 deletion bentoctl/utils/temp_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def __init__(
cleanup=True,
prefix="temp",
):

self._cleanup = cleanup
self._prefix = prefix
self.path = None
Expand Down
6 changes: 4 additions & 2 deletions bentoctl/utils/usage_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

@lru_cache(maxsize=1)
def do_not_track() -> bool: # pragma: no cover
# Returns True if and only if the environment variable is defined and has value True.
# The function is cached for better performance.
"""
Returns True if and only if the environment variable is defined and has value True.
The function is cached for better performance.
"""
return os.environ.get(BENTOML_DO_NOT_TRACK, str(False)).lower() == "true"


Expand Down
11 changes: 0 additions & 11 deletions ci/install_test_deps.sh.cmd

This file was deleted.

42 changes: 0 additions & 42 deletions ci/linter.sh

This file was deleted.

14 changes: 0 additions & 14 deletions ci/unit_tests.sh

This file was deleted.

5 changes: 0 additions & 5 deletions dev/format.sh

This file was deleted.

18 changes: 0 additions & 18 deletions dev/lint.sh

This file was deleted.

Loading

0 comments on commit fdb8fae

Please sign in to comment.