Skip to content

Commit

Permalink
Merge pull request #10 from valohai/renovate
Browse files Browse the repository at this point in the history
Renovations
  • Loading branch information
akx authored Mar 19, 2024
2 parents 084fbfc + 860f4c6 commit c3521b8
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 211 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[coverage]
concurrency = multiprocessing

26 changes: 15 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@ jobs:
Test:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
python-version: 3.9
- uses: actions/checkout@v2
- run: pip install -e . -r requirements-dev.txt
- run: pip install -e .[test]
- run: py.test --cov art -vv .
- uses: codecov/codecov-action@v2
Lint:
- uses: codecov/codecov-action@v4
Mypy:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
cache: pip
python-version: 3.9
- uses: actions/checkout@v2
- run: pip install -e . -r requirements-dev.txt
- run: isort --check .
- run: black --check .
- run: flake8
- run: pip install -e .[mypy]
- run: mypy art --strict
Lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: pre-commit/[email protected]
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
hooks:
- id: ruff
args:
- --fix
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace
- id: mixed-line-ending
args:
- --fix=lf
- repo: https://github.com/crate-ci/typos
rev: v1.19.0
hooks:
- id: typos
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ art – an artifact uploader
[![codecov](https://codecov.io/gh/valohai/art/branch/master/graph/badge.svg)](https://codecov.io/gh/valohai/art)

Art is a simple tool to manage artifacts to deploy.

The original use case was to transition an ops workflow from cloning full Git repositories
with deploy keys, but there are probably other uses.

Expand Down Expand Up @@ -71,8 +71,8 @@ the following files would be pushed to S3:
* Wrapfiles are useful with e.g. Python wheels, which need to have their original filenames intact. Wrapping wheel artifacts into a wrapfile makes it possible to download a single file with a well-known name, unpack it and do e.g. `pip install *.whl`. It should be noted that the wrapfile is, on purpose, a [tarbomb](https://en.wikipedia.org/wiki/Tar_(computing)#Tarbomb).
* S3 access assumes your S3 credentials are available in one of the ways supported by the Boto library.
* The `--suffix-description` option makes Art autogenerate an additional suffix based on the `git describe --always --long --dirty` output of the source, so you get a canonical URL for the particular version. (That description output is also saved in the manifest file, so you can cross-correlate between an arbitrary suffix and this.)
* For S3 destinations, you can add an `?acl=...` parameter, where `...` must be one of S3's pre-canned ACLs:
`'private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control'`
* For S3 destinations, you can add an `?acl=...` parameter, where `...` must be one of S3's pre-canned ACLs:
`'private'|'public-read'|'public-read-write'|'authenticated-read'|'aws-exec-read'|'bucket-owner-read'|'bucket-owner-full-control'`
The default is whatever is the default for your bucket.


Expand Down
15 changes: 4 additions & 11 deletions art/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
def get_argument_parser() -> argparse.ArgumentParser:
ap = argparse.ArgumentParser()
source_group = ap.add_argument_group("Source options")
source_group.add_argument(
"--git-source", metavar="URL", help="Git repository URL (passed to `git clone`)"
)
source_group.add_argument(
"--git-ref", default="master", help="Git reference (default %(default)s)"
)
source_group.add_argument("--git-source", metavar="URL", help="Git repository URL (passed to `git clone`)")
source_group.add_argument("--git-ref", default="master", help="Git reference (default %(default)s)")
source_group.add_argument("--local-source", help="Local source path")
source_group.add_argument(
"--config-file",
Expand Down Expand Up @@ -74,8 +70,7 @@ def get_argument_parser() -> argparse.ArgumentParser:
action="append",
default=[],
help=(
"Add a file glob for adding to the destination. "
"You should probably use a configuration file instead."
"Add a file glob for adding to the destination. " "You should probably use a configuration file instead."
),
)
return ap
Expand Down Expand Up @@ -139,9 +134,7 @@ def clean_dest(dest: str) -> str:

def process_config_postfork(args: Args, config: ArtConfig) -> None:
if not config.dests:
raise Problem(
"No destination(s) specified (on command line or in config in source)"
)
raise Problem("No destination(s) specified (on command line or in config in source)")
config.dests = [clean_dest(dest) for dest in config.dests]
for file in args.files:
config.file_map.append(FileMapEntry(source=file))
Expand Down
12 changes: 2 additions & 10 deletions art/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,8 @@ def git_clone(config: ArtConfig) -> None:

def describe(config: ArtConfig) -> Dict[str, Any]:
description = (
check_output(
["git", "describe", "--always", "--long", "--dirty"], cwd=config.work_dir
)
.decode()
.strip()
)
rev = (
check_output(["git", "rev-parse", "--", "HEAD"], cwd=config.work_dir)
.decode()
.strip()
check_output(["git", "describe", "--always", "--long", "--dirty"], cwd=config.work_dir).decode().strip()
)
rev = check_output(["git", "rev-parse", "--", "HEAD"], cwd=config.work_dir).decode().strip()

return {"id": rev, "description": description}
10 changes: 3 additions & 7 deletions art/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ def run_prepare(config: ArtConfig) -> None:
check_call(prepare_step, shell=True, cwd=config.work_dir)


def fork_configs_from_data(
base_cfg: ArtConfig, cfg_data: Dict[str, Any]
) -> Iterable[ArtConfig]:
def fork_configs_from_data(base_cfg: ArtConfig, cfg_data: Dict[str, Any]) -> Iterable[ArtConfig]:
if not isinstance(cfg_data, dict):
raise TypeError(f"Invalid configuration (must be a dict, got {cfg_data!r})")
configs_dict = cfg_data["configs"] if "configs" in cfg_data else {None: cfg_data}
configs_dict = cfg_data.get("configs", {None: cfg_data})
for name, cfg_data in configs_dict.items():
subcfg = copy.deepcopy(base_cfg)
subcfg.update_from(cfg_data)
Expand All @@ -33,9 +31,7 @@ def fork_configs_from_data(
yield subcfg


def fork_configs_from_work_dir(
base_cfg: ArtConfig, filename: str = DEFAULT_CONFIG_FILENAME
) -> Iterable[ArtConfig]:
def fork_configs_from_work_dir(base_cfg: ArtConfig, filename: str = DEFAULT_CONFIG_FILENAME) -> Iterable[ArtConfig]:
repo_cfg_path = os.path.join(base_cfg.work_dir, filename)
if os.path.isfile(repo_cfg_path):
log.info(f"Updating config from {repo_cfg_path}")
Expand Down
4 changes: 1 addition & 3 deletions art/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ def get_s3_client() -> Any:
return _s3_client


def s3_write(
url: str, source_fp: IO[bytes], *, options: Dict[str, Any], dry_run: bool
) -> None:
def s3_write(url: str, source_fp: IO[bytes], *, options: Dict[str, Any], dry_run: bool) -> None:
purl = urlparse(url)
s3_client = get_s3_client()
assert purl.scheme == "s3"
Expand Down
4 changes: 1 addition & 3 deletions art/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def _get_writer_for_dest(dest: str) -> Callable: # type: ignore[type-arg]
raise ValueError(f"Invalid destination: {dest}")


def local_write(
dest: str, source_fp: IO[bytes], *, options: Dict[str, Any], dry_run: bool
) -> None:
def local_write(dest: str, source_fp: IO[bytes], *, options: Dict[str, Any], dry_run: bool) -> None:
if dry_run:
log.info("Dry-run: Would have written local file %s", dest)
return
Expand Down
4 changes: 1 addition & 3 deletions art_tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ def test_s3_acl(mocker):
mocker.patch.object(cli, "put_object")
body = io.BytesIO(b"test")
_write_file("s3://bukkit/key", body, options={"acl": "public-read"})
cli.put_object.assert_called_with(
Bucket="bukkit", Key="key", ACL="public-read", Body=body
)
cli.put_object.assert_called_with(Bucket="bukkit", Key="key", ACL="public-read", Body=body)
4 changes: 1 addition & 3 deletions art_tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@


def test_dest_options(mocker, tmpdir):
cfg = ArtConfig(
work_dir=str(tmpdir), dests=[str(tmpdir)], name="", repo_url=str(tmpdir)
)
cfg = ArtConfig(work_dir=str(tmpdir), dests=[str(tmpdir)], name="", repo_url=str(tmpdir))
mf = Manifest(files={})
wf = mocker.patch("art.write._write_file")
art.write.write(
Expand Down
4 changes: 0 additions & 4 deletions mypy.ini

This file was deleted.

73 changes: 69 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,71 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "art"
dynamic = ["version"]
description = "Artifact manager"
readme = "README.md"
license = "MIT"
authors = [
{ name = "Valohai", email = "[email protected]" },
]
build-backend = "setuptools.build_meta"
dependencies = [
"boto3",
"pyyaml",
]

[project.optional-dependencies]
mypy = [
"mypy~=1.9.0",
"types-PyYAML",
]
test = [
"build",
"pytest-cov",
"pytest-mock~=3.12",
"pytest~=8.1",
]

[project.scripts]
art = "art.command:run_command"

[tool.hatch.version]
path = "art/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"/art",
]

[tool.pytest.ini_options]
norecursedirs = [".git", ".tox"]

[tool.ruff]
line-length = 120

[tool.ruff.lint]
ignore = [
"D100",
"D101",
"D102",
"D103",
"D104",
"D107",
"D211",
"D213",
"SIM105",
]
select = [
"D",
"E",
"F",
"I",
"SIM",
"W",
]

[[tool.mypy.overrides]]
module = "boto3.*"
ignore_missing_imports = true
13 changes: 0 additions & 13 deletions requirements-dev.in

This file was deleted.

Loading

0 comments on commit c3521b8

Please sign in to comment.