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

DM-43199: Move to black and isort #91

Merged
merged 5 commits into from
Mar 6, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/do_not_merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Check commits can be merged"
on:
push:
branches:
- main
pull_request:

jobs:
do-not-merge-checker:
runs-on: ubuntu-latest

steps:
- name: Check that there are no commits that should not be merged
uses: gsactions/commit-message-checker@v2
with:
excludeDescription: "true" # optional: this excludes the description body of a pull request
excludeTitle: "true" # optional: this excludes the title of a pull request
checkAllCommitMessages: "true" # optional: this checks all commits associated with a pull request
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
# Check for message indicating that there is a commit that should
# not be merged.
pattern: ^(?!DO NOT MERGE)
flags: "i"
error: |
"This step failed because there is a commit containing the text
'DO NOT MERGE'. Remove this commit from the branch before merging
or change the commit summary."

- uses: actions/checkout@v3

- name: Check requirements.txt for branches
shell: bash
run: |
FILE="requirements.txt requirements/main.in requirements/test.in"
MATCH=tickets/DM-
if grep -q $MATCH $FILE
then
echo "Ticket branches found in $FILE:"
grep -n $MATCH $FILE
exit 1
fi
11 changes: 11 additions & 0 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check Python formatting

on:
push:
branches:
- main
pull_request:

jobs:
call-workflow:
uses: lsst/rubin_workflows/.github/workflows/formatting.yaml@main
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: check-yaml

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
additional_dependencies: [toml]

- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion config/quickLookIsr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
config.doWrite = False # this task writes separately, no need for this
config.doSaturation = True # saturation very important for roundness measurement in qfm
config.doSaturationInterpolation = True
config.overscan.fitType = 'MEDIAN_PER_ROW'
config.overscan.fitType = "MEDIAN_PER_ROW"
config.overscan.doParallelOverscan = True
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tool.isort]
profile = "black"
line_length = 110
known_first_party = ["lsst", "tests"]

[tool.black]
line-length = 110
target-version = ["py311"]
1 change: 1 addition & 0 deletions python/lsst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
1 change: 1 addition & 0 deletions python/lsst/summit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
8 changes: 4 additions & 4 deletions python/lsst/summit/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from .bestEffort import *
from .spectrumExaminer import *
from .nightReport import *
from .butlerUtils import *
from .imageExaminer import *
from .nightReport import *
from .peekExposure import *
from .quickLook import *
from .butlerUtils import *
from .spectrumExaminer import *
from .utils import *
from .peekExposure import *
21 changes: 9 additions & 12 deletions python/lsst/summit/utils/assessPeekExposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,27 @@


import atexit
from collections import namedtuple
import logging
import multiprocessing
import os
import shutil
import time
import os
import warnings
from collections import namedtuple
from pathlib import Path

import lsst.afw.display as afwDisplay
import matplotlib.pyplot as plt
import numpy as np
from astropy.table import Table
from astropy.utils.exceptions import AstropyUserWarning
from tabulate import tabulate
from tqdm import tqdm

import lsst.afw.display as afwDisplay
from lsst.afw.geom import ellipses
from lsst.daf.butler.datastore.cache_manager import DatastoreCacheManager
from lsst.summit.utils.bestEffort import BestEffortIsr
from lsst.summit.utils.peekExposure import PeekExposureTask
from tabulate import tabulate
from tqdm import tqdm

# Set logger level to higher than CRITICAL to suppress all output
silentLogger = logging.getLogger("silentLogger")
Expand Down Expand Up @@ -135,9 +136,7 @@ def doWork(idx, row, doPlot):
mode = "photo"

t0 = time.time()
result = pet.run(
exp, mode=mode, doDisplay=doPlot, binSize=binSize, donutDiameter=donutDiameter
)
result = pet.run(exp, mode=mode, doDisplay=doPlot, binSize=binSize, donutDiameter=donutDiameter)
t1 = time.time()
runtime = t1 - t0

Expand Down Expand Up @@ -185,9 +184,7 @@ def doWork(idx, row, doPlot):
else:
fwhm = np.nan
display.show_colorbar(False)
ax.set_title(
f"{exposureId=} {inTag=} {outTag=} {fwhm=:.2f} arcsec", color="w"
)
ax.set_title(f"{exposureId=} {inTag=} {outTag=} {fwhm=:.2f} arcsec", color="w")
path = Path(args.plotdir)
path.mkdir(parents=True, exist_ok=True)
fn = f"test_pet_{idx:04d}_{exposureId:d}_{inTag}_{outTag}.png"
Expand All @@ -208,7 +205,7 @@ def main(args):
warnings.simplefilter("ignore", category=AstropyUserWarning)
table = Table.read(path)
table["exposureId"] = table["day_obs"] * 100_000 + table["sequence_number"]
table = table[args.start:args.end]
table = table[args.start : args.end]

intags = np.unique(table["finalTag"])

Expand Down