Skip to content

Commit

Permalink
cruft: update template
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Feb 3, 2024
1 parent 590bc5c commit 179928d
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/iterative/cookiecutter-dvc-plugin",
"commit": "91159828cdce86290b97bf4985732651805523c4",
"commit": "55dea263c00d5e174aed89451c29f6b7ef0f9577",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: 3.9
- name: Install
run: |
pip install --upgrade pip wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
pyv: ["3.8", "3.9", "3.10"]
pyv: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
31 changes: 6 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ repos:
language: fail
files: \.rej$
repo: local
- hooks:
- id: black
language_version: python3
repo: https://github.com/ambv/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.2.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
Expand All @@ -26,21 +27,6 @@ repos:
- ba,datas,fo,uptodate
repo: https://github.com/codespell-project/codespell
rev: v2.1.0
- hooks:
- id: isort
language_version: python3
repo: https://github.com/timothycrosley/isort
rev: 5.12.0
- hooks:
- id: flake8
language_version: python3
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-string-format
repo: https://github.com/pycqa/flake8
rev: 3.9.2
- repo: local
hooks:
- id: mypy
Expand All @@ -49,11 +35,6 @@ repos:
files: ^dvc_oss/
language: system
types: [python]
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
- hooks:
- args:
- -i
Expand Down
10 changes: 5 additions & 5 deletions dvc_oss/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import logging
import os
import threading
from typing import ClassVar

from funcy import wrap_prop

from dvc.utils.objects import cached_property
from dvc_objects.fs.base import ObjectFileSystem
from funcy import wrap_prop

logger = logging.getLogger(__name__)


# pylint:disable=abstract-method
class OSSFileSystem(ObjectFileSystem):
protocol = "oss"
REQUIRES = {"ossfs": "ossfs"}
REQUIRES: ClassVar[dict[str, str]] = {"ossfs": "ossfs"}
PARAM_CHECKSUM = "etag"
LIST_OBJECT_PAGE_SIZE = 100

def _prepare_credentials(self, **config):
login_info = {}
login_info["key"] = config.get("oss_key_id") or os.getenv(
"OSS_ACCESS_KEY_ID"
)
login_info["key"] = config.get("oss_key_id") or os.getenv("OSS_ACCESS_KEY_ID")
login_info["secret"] = config.get("oss_key_secret") or os.getenv(
"OSS_ACCESS_KEY_SECRET"
)
Expand Down
1 change: 0 additions & 1 deletion dvc_oss/tests/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class OSS(Cloud, CloudURLInfo):

IS_OBJECT_STORAGE = True

@staticmethod
Expand Down
4 changes: 2 additions & 2 deletions dvc_oss/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from dvc.testing.fixtures import * # noqa, pylint: disable=wildcard-import,unused-import
from dvc.testing.fixtures import * # noqa: F403

from .fixtures import * # noqa, pylint: disable=wildcard-import,unused-import
from .fixtures import * # noqa: F403
19 changes: 6 additions & 13 deletions dvc_oss/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def docker_compose_file():

@pytest.fixture(scope="session")
def oss_server(
docker_compose, docker_services # pylint: disable=unused-argument
docker_compose,
docker_services, # pylint: disable=unused-argument
):
import oss2

Expand All @@ -26,9 +27,7 @@ def oss_server(

def _check():
try:
auth = oss2.Auth(
EMULATOR_OSS_ACCESS_KEY_ID, EMULATOR_OSS_ACCESS_KEY_SECRET
)
auth = oss2.Auth(EMULATOR_OSS_ACCESS_KEY_ID, EMULATOR_OSS_ACCESS_KEY_SECRET)
oss2.Bucket(auth, endpoint, "mybucket").get_bucket_info()
return True
except oss2.exceptions.NoSuchBucket:
Expand All @@ -49,20 +48,14 @@ def _make_oss():
url = OSS.get_url()
ret = OSS(url)

auth = oss2.Auth(
ret.config["oss_key_id"], ret.config["oss_key_secret"]
)
bucket = oss2.Bucket(
auth, ret.config["oss_endpoint"], TEST_OSS_REPO_BUCKET
)
auth = oss2.Auth(ret.config["oss_key_id"], ret.config["oss_key_secret"])
bucket = oss2.Bucket(auth, ret.config["oss_endpoint"], TEST_OSS_REPO_BUCKET)
try:
bucket.get_bucket_info()
except oss2.exceptions.NoSuchBucket:
bucket.create_bucket(
oss2.BUCKET_ACL_PUBLIC_READ,
oss2.models.BucketCreateConfig(
oss2.BUCKET_STORAGE_CLASS_STANDARD
),
oss2.models.BucketCreateConfig(oss2.BUCKET_STORAGE_CLASS_STANDARD),
)

return ret
Expand Down
8 changes: 1 addition & 7 deletions dvc_oss/tests/test_dvc.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import pytest
from dvc.testing.api_tests import ( # noqa, pylint: disable=unused-import
TestAPI,
)
from dvc.testing.remote_tests import ( # noqa, pylint: disable=unused-import
TestRemote,
)


@pytest.fixture
def remote(make_remote):
yield make_remote(name="upstream", typ="oss")
return make_remote(name="upstream", typ="oss")
142 changes: 97 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,63 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "dvc_oss/_dvc_oss_version.py"

[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''

[tool.isort]
profile = "black"
known_first_party = ["dvc_oss"]
line_length = 79
[project]
name = "dvc-oss"
description = "oss plugin for dvc"
readme = "README.rst"
keywords = [
"dvc",
"oss",
]
license = { text = "Apache License 2.0" }
maintainers = [{ name = "Iterative", email = "[email protected]" }]
authors = [{ name = "Iterative", email = "[email protected]" }]
requires-python = ">=3.9"
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]
dependencies = [
"dvc",
"ossfs>=2023.12.0",
]

[project.optional-dependencies]
tests = [
"wheel==0.37.0",
"dvc[testing]",
# Test requirements
"pytest==6.2.5",
"pytest-cov==3.0.0",
"pytest-xdist==2.4.0",
"pytest-mock==3.6.1",
"pytest-lazy-fixture==0.6.3",
"flaky==3.7.0",
"mock==4.0.3",
"wget==3.2",
"filelock==3.3.2",
"xmltodict==0.12.0",
# required by collective.checkdocs
"Pygments==2.10.0",
"collective.checkdocs==0.2",
"pydocstyle==6.1.1",
# type-checking
"mypy==0.981",
"types-requests==2.25.11",
"types-tabulate==0.8.3",
"types-toml==0.10.1",
# optional dependencies
'pywin32>=225; sys_platform == "win32"',
]

[project.urls]
Documentation = "https://dvc.org/doc"
Source = "https://github.com/iterative/dvc-oss"

[tool.pytest.ini_options]
log_level = "debug"
Expand All @@ -51,29 +86,46 @@ warn_redundant_casts = true
warn_unreachable = true
files = ["dvc_oss"]

[tool.pylint.master]
extension-pkg-whitelist = ["pygit2"]
init-hook = "import sys; sys.path.append(str('tests'))"
load-plugins = ["pylint_pytest"]

[tool.pylint.message_control]
disable = [
"format", "refactoring", "spelling", "design",
"invalid-name", "duplicate-code", "fixme",
"unused-wildcard-import", "cyclic-import", "wrong-import-order",
"wrong-import-position", "ungrouped-imports", "multiple-imports",
"logging-format-interpolation", "logging-fstring-interpolation",
"missing-function-docstring", "missing-module-docstring",
"missing-class-docstring", "raise-missing-from", "import-outside-toplevel",
[tool.ruff]
output-format = "full"
show-fixes = true

[tool.ruff.lint]
ignore = [
"N818", "S101", "ISC001", "PT004", "PT007", "RET502", "RET503", "SIM105", "SIM108", "SIM117",
"TRY003", "TRY300", "PLR2004", "PLW2901", "LOG007",
]
enable = ["c-extension-no-member", "no-else-return"]
select = [
"F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10",
"EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET",
"SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY",
"FLY", "PERF101", "LOG", "RUF", "RUF022", "RUF023", "RUF024", "RUF025", "RUF026",
]
preview = true
explicit-preview-rules = true

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
parametrize-names-type = "csv"
raises-extend-require-match-for = ["dvc.exceptions.DvcException"]

[tool.ruff.lint.flake8-tidy-imports]

[tool.ruff.lint.flake8-type-checking]
strict = true

[tool.ruff.lint.flake8-unused-arguments]
ignore-variadic-names = true

[tool.ruff.lint.isort]
known-first-party = ["dvc", "dvc_data", "dvc_objects"]

[tool.ruff.lint.pep8-naming]
extend-ignore-names = ["M", "SCM"]

[tool.pylint.typecheck]
generated-members = ["pytest.lazy_fixture", "logging.TRACE", "logger.trace", "sys.getwindowsversion", "argparse.Namespace"]
ignored-classes = ["Dvcfile"]
ignored-modules = ["azure"]
signature-mutators = ["funcy.decorators.decorator"]
[tool.ruff.lint.pylint]
max-args = 10

[tool.pylint.variables]
dummy-variables-rgx = "_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_"
ignored-argument-names = "_.*|^ignored_|^unused_|args|kwargs"
[tool.ruff.lint.per-file-ignores]
"dvc_oss/tests/**" = ["S", "ARG001", "ARG002", "TRY002", "TRY301"]
Loading

0 comments on commit 179928d

Please sign in to comment.