Skip to content

Commit

Permalink
Merge branch 'main' into speed_up_repr_tiled
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair authored Jan 6, 2025
2 parents cf5125e + 5ad3fda commit 231e89a
Show file tree
Hide file tree
Showing 18 changed files with 209 additions and 112 deletions.
11 changes: 9 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/sunpy/package-template",
"commit": "aec53b81aed2e7e534045e59303d82712fe82fb1",
"commit": "c60ccf2ddc71d3cf126cea15132a15da307864f7",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -10,13 +10,20 @@
"author_name": "NSO / AURA",
"author_email": "[email protected]",
"project_url": "https://github.com/DKISTDC/dkist",
"github_repo": "DKISTDC/dkist",
"sourcecode_url": "https://github.com/DKISTDC/dkist",
"download_url": "https://pypi.org/project/dkist",
"documentation_url": "https://docs.dkist.nso.edu/projects/python-tools/en/stable/",
"changelog_url": "https://docs.dkist.nso.edu/projects/python-tools/en/stable/whatsnew/changelog.html",
"issue_tracker_url": "https://github.com/DKISTDC/dkist/issues",
"license": "BSD 3-Clause",
"minimum_python_version": "3.10",
"use_compiled_extensions": "n",
"enable_dynamic_dev_versions": "y",
"include_example_code": "n",
"include_cruft_update_github_workflow": "y",
"_sphinx_theme": "alabaster",
"use_extended_ruff_linting": "y",
"_sphinx_theme": "dkist",
"_parent_project": "",
"_install_requires": "",
"_copy_without_render": [
Expand Down
50 changes: 33 additions & 17 deletions .github/workflows/sub_package_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- add-paths: .
body: apply the changes to this repo.
branch: cruft/update
commit-message: "Automatic package template update"
title: Updates from the package template

steps:
- uses: actions/checkout@v4

Expand All @@ -55,25 +47,49 @@ jobs:
echo "has_changes=$CHANGES" >> "$GITHUB_OUTPUT"
- name: Run update if available
id: cruft_update
if: steps.check.outputs.has_changes == '1'
run: |
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
cruft update --skip-apply-ask --refresh-private-variables
cruft_output=$(cruft update --skip-apply-ask --refresh-private-variables)
echo $cruft_output
git restore --staged .
- name: Create pull request
if [[ "$cruft_output" == *"Failed to cleanly apply the update, there may be merge conflicts."* ]]; then
echo merge_conflicts=1 >> $GITHUB_OUTPUT
else
echo merge_conflicts=0 >> $GITHUB_OUTPUT
fi
- name: Check if only .cruft.json is modified
id: cruft_json
if: steps.check.outputs.has_changes == '1'
run: |
git status --porcelain=1
if [[ "$(git status --porcelain=1)" == " M .cruft.json" ]]; then
echo "Only .cruft.json is modified. Exiting workflow early."
echo "has_changes=0" >> "$GITHUB_OUTPUT"
else
echo "has_changes=1" >> "$GITHUB_OUTPUT"
fi
- name: Create pull request
if: steps.cruft_json.outputs.has_changes == '1'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: ${{ matrix.add-paths }}
commit-message: ${{ matrix.commit-message }}
branch: ${{ matrix.branch }}
add-paths: "."
commit-message: "Automatic package template update"
branch: "cruft/update"
delete-branch: true
branch-suffix: timestamp
title: ${{ matrix.title }}
draft: ${{ steps.cruft_update.outputs.merge_conflicts == '1' }}
title: "Updates from the package template"
labels: |
no changelog
body: |
This is an autogenerated PR, which will ${{ matrix.body }}.
[Cruft](https://cruft.github.io/cruft/) has detected updates from the Package Template
This is an autogenerated PR, which will applies the latest changes from the [SunPy Package Template](https://github.com/sunpy/package-template).
If this pull request has been opened as a draft there are conflicts which need fixing.
**To run the CI on this pull request you will need to close it and reopen it.**
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
# This should be before any formatting hooks like isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.6.9"
rev: "v0.8.3"
hooks:
- id: ruff
args: ["--fix"]
Expand Down
90 changes: 67 additions & 23 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target-version = "py310"
line-length = 110
line-length = 120
exclude = [
".git,",
"__pycache__",
Expand All @@ -10,65 +10,109 @@ exclude = [

[lint]
select = [
"F",
"E",
"F",
"W",
"UP",
"PT",
"BLE",
# "A",
"C4",
"ICN",
"G",
"INP",
"PT",
"Q",
"RSE",
"PIE",
"T20",
"RET",
"TID",
"PTH",
"PD",
"PLC",
"PLE",
"FLY",
"NPY",
# "PERF",
"RUF",
]

extend-ignore = [
# pycodestyle (E, W)
"E501", # LineTooLong # TODO! fix
"E501", # ignore line length will use a formatter instead
"E702",
"E711",
"E741",
"F405",
"F403",
"F821",
"F841",
# pyupgrade (UP)
"UP038", # Use | in isinstance - not compatible with models and is slower
# pytest (PT)
"PT001", # Always use pytest.fixture()
"PT004", # Fixtures which don't return anything should have leading _
"PT007", # Parametrize should be lists of tuples # TODO! fix
"PT011", # Too broad exception assert # TODO! fix
"PT023", # Always use () on pytest decorators
# pyupgrade
"UP038", # Use | in isinstance - not compatible with models and is slower
# Returns (RET)
"RET502", # Do not implicitly return None in function able to return non-None value
"RET503", # Missing explicit return at the end of function able to return non-None value
# Pathlib (PTH)
"PTH123", # open() should be replaced by Path.open()
# Ruff
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`
"RUF015", # Prefer `next(iter(...))` over single element slice
# flake8-pie (PIE)
"PIE808", # Disallow passing 0 as the first argument to range
# flake8-use-pathlib (PTH)
"PTH123", # open() should be replaced by Path.open()
# Ruff (RUF)
"RUF003", # Ignore ambiguous quote marks, doesn't allow ' in comments
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF013", # PEP 484 prohibits implicit `Optional`
"RUF015", # Prefer `next(iter(...))` over single element slice
]

[lint.per-file-ignores]
# Part of configuration, not a package.
"setup.py" = ["INP001"]
"conftest.py" = ["INP001"]
"setup.py" = [
"INP001", # File is part of an implicit namespace package.
]
"conftest.py" = [
"INP001", # File is part of an implicit namespace package.
]
"docs/conf.py" = [
"E402" # Module imports not at top of file
"E402", # Module imports not at top of file
"A001",
"BLE001",
"T201",
]
"docs/*.py" = [
"INP001", # Implicit-namespace-package. The examples are not a package.
"INP001", # File is part of an implicit namespace package.
]
"examples/**.py" = [
"T201", # allow use of print in examples
"INP001", # File is part of an implicit namespace package.
]
"__init__.py" = [
"E402", # Module level import not at top of cell
"F401", # Unused import
"F403", # from {name} import * used; unable to detect undefined names
"F405", # {name} may be undefined, or defined from star imports
]
"test_*.py" = [
"E402", # Module level import not at top of cell
"B011",
"D",
"E402",
"PGH001",
"S101",
]
"dkist/logger.py" = [
"PTH",
"BLE001",
]
"dkist/tests/generate_*" = [
"T20",
]
"dkist/utils/sysinfo.py" = [
"T20",
]
"dkist/net/globus/auth.py" = [
"T201",
]
"__init__.py" = ["E402", "F401", "F403"]
"test_*.py" = ["B011", "D", "E402", "PGH001", "S101"]
"dkist/logger.py" = ["PTH"]

[lint.flake8-import-conventions.extend-aliases]
"astropy.units" = "u"
Expand Down
2 changes: 1 addition & 1 deletion dkist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
__version__ = "unknown"


__all__ = ["TiledDataset", "Dataset", "load_dataset", "system_info", "conf"]
__all__ = ["Dataset", "TiledDataset", "conf", "load_dataset", "system_info"]


def write_default_config(overwrite=False):
Expand Down
4 changes: 2 additions & 2 deletions dkist/_dev/scm_version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Try to use setuptools_scm to get the current version; this is only used
# in development installations from the git repository.
import os.path
from pathlib import Path

try:
from setuptools_scm import get_version

version = get_version(root=os.path.join("..", ".."), relative_to=__file__)
version = get_version(root=Path('../..'), relative_to=__file__)
except ImportError:
raise
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion dkist/data/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ._sample import _SAMPLE_DATASETS, VISP_HEADER, _get_sample_datasets

__all__ = ["download_all_sample_data", *sorted(_SAMPLE_DATASETS.keys()), "VISP_HEADER"]
__all__ = ["download_all_sample_data", *sorted(_SAMPLE_DATASETS.keys()), "VISP_HEADER"] # noqa: PLE0604


# See PEP 562 (https://peps.python.org/pep-0562/) for module-level __dir__()
Expand Down
2 changes: 1 addition & 1 deletion dkist/dataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def pp_matrix(wcs):
----------
wcs : `BaseHighLevelWCS` or `BaseLowLevelWCS`
"""
print(_get_pp_matrix(wcs))
print(_get_pp_matrix(wcs)) # noqa: T201


def extract_pc_matrix(headers, naxes=None):
Expand Down
2 changes: 1 addition & 1 deletion dkist/io/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from dkist import log

__all__ = ["BaseFITSLoader", "AstropyFITSLoader"]
__all__ = ["AstropyFITSLoader", "BaseFITSLoader"]


common_parameters = """
Expand Down
34 changes: 27 additions & 7 deletions dkist/net/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,33 @@
from sunpy.net.attr import Range as _Range
from sunpy.net.attr import SimpleAttr as _SimpleAttr

__all__ = ["PageSize", "Page", "Dataset", "WavelengthBand", "Embargoed", "Observable",
"Experiment", "Proposal", "TargetType", "Recipe",
"FriedParameter", "PolarimetricAccuracy", "ExposureTime",
"EmbargoEndTime", "BrowseMovie", "BoundingBox",
"SpectralSampling", "SpatialSampling", "TemporalSampling", "SummitSoftwareVersion",
"WorkflowName", "WorkflowVersion", "ObservingProgramExecutionID",
"InstrumentProgramExecutionID", "HeaderVersion"]
__all__ = [
"BoundingBox",
"BrowseMovie",
"Dataset",
"EmbargoEndTime",
"Embargoed",
"Experiment",
"ExposureTime",
"FriedParameter",
"HeaderVersion",
"InstrumentProgramExecutionID",
"Observable",
"ObservingProgramExecutionID",
"Page",
"PageSize",
"PolarimetricAccuracy",
"Proposal",
"Recipe",
"SpatialSampling",
"SpectralSampling",
"SummitSoftwareVersion",
"TargetType",
"TemporalSampling",
"WavelengthBand",
"WorkflowName",
"WorkflowVersion",
]


# SimpleAttrs
Expand Down
2 changes: 1 addition & 1 deletion dkist/net/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from . import attrs as dattrs
from .attr_walker import walker

__all__ = ["DKISTQueryResponseTable", "DKISTClient"]
__all__ = ["DKISTClient", "DKISTQueryResponseTable"]


class DKISTQueryResponseTable(QueryResponseTable):
Expand Down
2 changes: 1 addition & 1 deletion dkist/net/globus/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .auth import ensure_globus_authorized, get_refresh_token_authorizer

__all__ = ["get_data_center_endpoint_id", "get_endpoint_id", "get_directory_listing"]
__all__ = ["get_data_center_endpoint_id", "get_directory_listing", "get_endpoint_id"]


def get_transfer_client(force_reauth=False):
Expand Down
1 change: 0 additions & 1 deletion dkist/net/globus/tests/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def test_process_event_list(transfer_client, mock_task_event_list):
assert all(isinstance(e, tuple) for e in events)
assert all(all(isinstance(item, tuple) for item in e) for e in events)

print(events)
assert len(json_events) == 1
assert isinstance(json_events, tuple)
assert isinstance(json_events[0], dict)
Expand Down
2 changes: 1 addition & 1 deletion dkist/net/globus/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .endpoints import (auto_activate_endpoint, get_data_center_endpoint_id,
get_endpoint_id, get_local_endpoint_id, get_transfer_client)

__all__ = ["watch_transfer_progress", "start_transfer_from_file_list"]
__all__ = ["start_transfer_from_file_list", "watch_transfer_progress"]


def start_transfer_from_file_list(
Expand Down
2 changes: 1 addition & 1 deletion dkist/utils/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from astropy.table import Table

__all__ = ["dehumanize_inventory", "humanize_inventory", "INVENTORY_KEY_MAP"]
__all__ = ["INVENTORY_KEY_MAP", "dehumanize_inventory", "humanize_inventory"]


class DefaultMap(defaultdict):
Expand Down
Loading

0 comments on commit 231e89a

Please sign in to comment.