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

Update deps & add ruff isort to pre-commit #102

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -9,12 +9,15 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.14
rev: v0.6.7
hooks:
- id: ruff
- id: ruff
args: [--select, I, --fix]
name: ruff-isort
- id: ruff-format

- repo: https://github.com/adrienverge/yamllint
rev: v1.33.0
rev: v1.35.1
hooks:
- id: yamllint
11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ exclude_lines = [
exclude = [
"__init__.py",
]
line-length = 110
target-version = "py311"

[tool.ruff.lint]
ignore = [
"COM812",
"N802",
"N803",
"N806",
Expand All @@ -71,7 +76,6 @@ ignore = [
"N815",
"N816",
]
line-length = 110
select = [
"E", # pycodestyle
"F", # pyflakes
Expand All @@ -81,18 +85,17 @@ select = [
"FBT", # flake8-boolean-trap
"UP", # pyupgrade
]
target-version = "py311"
extend-select = [
"RUF100", # Warn about unused noqa
]

[tool.ruff.lint.isort]
known-first-party = ["lsst", "tests"]

[tool.ruff.pycodestyle]
[tool.ruff.lint.pycodestyle]
max-doc-length = 79

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.pytest.ini_options]
Expand Down
3 changes: 2 additions & 1 deletion requirements/dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
aiosqlite
asgi-lifespan
coverage[toml]
greenlet==3.0.3 # Pin back to allow playwright 1.47
httpx
mypy
pre-commit
pylint
pytest
pytest-asyncio
pytest-cov
pytest-playwright
pytest-timeout
ruff
sqlalchemy[mypy]
types-pyyaml
types-tabulate
pytest-playwright
402 changes: 303 additions & 99 deletions requirements/dev.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements/main.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ uvicorn[standard]
# Other dependencies.
asyncpg
click
greenlet==3.0.3 # Pin back to allow playwright 1.47
jinja2
lsst-ctrl-bps
lsst-ctrl-bps-panda
Expand Down
664 changes: 340 additions & 324 deletions requirements/main.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/campaign.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Campaign table"""

from .. import db
from . import options, wrappers
from .commands import campaign_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Group table"""

from .. import db
from ..client.client import CMClient
from . import options, wrappers
Expand Down
3 changes: 2 additions & 1 deletion src/lsst/cmservice/cli/job.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""CLI to manage Job table"""
from ..client.client import CMClient

from .. import db
from ..client.client import CMClient
from . import options, wrappers
from .commands import job_group

Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/pipetask_error_type.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage PipetaskErrorType table"""

from .. import db
from . import options, wrappers
from .commands import pipetask_error_type_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/product_set.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage ProductSet table"""

from .. import db
from . import options, wrappers
from .commands import product_set_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/production.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Production table"""

from .. import db
from . import options, wrappers
from .commands import production_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/queue.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Queue table"""

from .. import db
from ..client.client import CMClient
from . import options, wrappers
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Script table"""

from .. import db
from . import options, wrappers
from .commands import script_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/script_dependency.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage ScriptDependency table"""

from .. import db
from . import options, wrappers
from .commands import script_dependency_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/script_template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage ScriptTemplate table"""

from .. import db
from . import options, wrappers
from .commands import script_template_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/spec_block.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage SpecBlock table"""

from .. import db
from . import options, wrappers
from .commands import spec_block_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/specificaiton.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Specification table"""

from .. import db
from . import options, wrappers
from .commands import specification_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/step.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Step table"""

from .. import db
from . import options, wrappers
from .commands import step_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/step_dependency.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage Group table"""

from .. import db
from . import options, wrappers
from .commands import step_dependency_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/task_set.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage TaskSet table"""

from .. import db
from . import options, wrappers
from .commands import task_set_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/cli/wms_task_report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI to manage WmsTaskReport table"""

from .. import db
from . import options, wrappers
from .commands import wms_task_report_group
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Top level for python client API"""

from __future__ import annotations

import httpx
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/groups.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Group tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/jobs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Job tables"""

from __future__ import annotations

from collections.abc import Sequence
Expand Down
10 changes: 5 additions & 5 deletions src/lsst/cmservice/client/loaders.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from __future__ import annotations

import os
import yaml

from typing import Any, TYPE_CHECKING
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any

import httpx
import yaml

from .. import models
from ..common.enums import ErrorActionEnum, ErrorFlavorEnum, ErrorSourceEnum
from ..common.errors import CMYamlParseError
from .. import models
from . import wrappers

if TYPE_CHECKING:
from .client import CMClient
from pydantic import BaseModel

from .client import CMClient


def update_include_dict(
orig_dict: dict[str, Any],
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/pipetask_error_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing PipetaskErrorType tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/pipetask_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Group tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/product_sets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing ProductSet tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/productions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Production tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/queues.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Group tables"""

from __future__ import annotations

from datetime import datetime, timedelta
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/script_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing ScriptDependency tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/script_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing ScriptError tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/script_templates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing ScriptTemplate tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/scripts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Script tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/spec_blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing SpecBlock tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/specifications.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Specification tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/step_dependencies.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing StepDependency tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/steps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing Step tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/task_sets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing TaskSet tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/client/wms_task_reports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""python for client API for managing WmsTaskReport tables"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 0 additions & 1 deletion src/lsst/cmservice/common/errors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""cm-service specific error types"""


from sqlalchemy.exc import IntegrityError


Expand Down
1 change: 1 addition & 0 deletions src/lsst/cmservice/common/slurm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for working with slurm jobs"""

import subprocess

from .enums import StatusEnum
Expand Down
1 change: 0 additions & 1 deletion src/lsst/cmservice/db/specification.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations


from sqlalchemy import JSON
from sqlalchemy.ext.asyncio import async_scoped_session
from sqlalchemy.ext.hybrid import hybrid_property
Expand Down
1 change: 0 additions & 1 deletion src/lsst/cmservice/handlers/element_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ..db.node import NodeMixin
from ..db.script import Script
from ..db.script_dependency import ScriptDependency

from .functions import add_steps


Expand Down
2 changes: 1 addition & 1 deletion src/lsst/cmservice/handlers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from sqlalchemy import select
from sqlalchemy.ext.asyncio import async_scoped_session

from lsst.ctrl.bps.wms_service import WmsJobReport, WmsStates, WmsRunReport
from lsst.ctrl.bps.bps_reports import compile_job_summary
from lsst.ctrl.bps.wms_service import WmsJobReport, WmsRunReport, WmsStates

from ..common.enums import StatusEnum
from ..common.errors import CMYamlParseError
Expand Down
8 changes: 3 additions & 5 deletions src/lsst/cmservice/handlers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,26 @@
import yaml
from sqlalchemy.ext.asyncio import async_scoped_session


from lsst.cmservice.common.bash import write_bash_script
from lsst.cmservice.db.element import ElementMixin
from lsst.cmservice.db.job import Job
from lsst.cmservice.db.script import Script
from lsst.cmservice.db.task_set import TaskSet
from lsst.cmservice.db.wms_task_report import WmsTaskReport
from lsst.ctrl.bps import BaseWmsService, WmsStates, WmsRunReport
from lsst.ctrl.bps import BaseWmsService, WmsRunReport, WmsStates
from lsst.utils import doImport

from ..common.butler import remove_run_collections
from ..common.enums import LevelEnum, StatusEnum, TaskStatusEnum, WmsMethodEnum
from ..common.errors import (
CMBadExecutionMethodError,
CMBadParameterTypeError,
CMIDMismatchError,
CMMissingScriptInputError,
CMBadParameterTypeError,
)
from .functions import load_manifest_report, load_wms_reports, status_from_bps_report, compute_job_status
from .functions import compute_job_status, load_manifest_report, load_wms_reports, status_from_bps_report
from .script_handler import FunctionHandler, ScriptHandler


WMS_TO_TASK_STATUS_MAP = {
WmsStates.UNKNOWN: TaskStatusEnum.missing,
WmsStates.MISFIT: TaskStatusEnum.missing,
Expand Down
Loading
Loading