From a5b3d261adeee79bbcf953352a097f68c592b4d4 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 1 Jul 2023 09:10:12 -0700 Subject: [PATCH 1/4] Test for 311 --- .github/{workflows => }/dependabot.yml | 0 .github/workflows/ci.yml | 9 +++++---- .pre-commit-config.yaml | 8 ++++---- .readthedocs.yaml | 2 +- LICENSE | 2 +- .../jpeg2000/tests/test_get_jp2_image.py | 4 ++-- hvpy/api_groups/jpeg2000/tests/test_get_jpx.py | 4 ++-- .../tests/test_get_jpx_closest_to_mid_point.py | 4 ++-- hvpy/facade.py | 6 +++--- pyproject.toml | 4 ++-- setup.cfg | 3 ++- tox.ini | 16 +++++++--------- 12 files changed, 31 insertions(+), 31 deletions(-) rename .github/{workflows => }/dependabot.yml (100%) diff --git a/.github/workflows/dependabot.yml b/.github/dependabot.yml similarity index 100% rename from .github/workflows/dependabot.yml rename to .github/dependabot.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0588f91..3d505ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,9 @@ jobs: with: submodules: false coverage: codecov - toxdeps: "'tox<4' tox-pypi-filter" + toxdeps: tox-pypi-filter envs: | - - linux: py310 + - linux: py311 - linux: codestyle test: needs: [core] @@ -34,13 +34,14 @@ jobs: with: submodules: false coverage: codecov - toxdeps: "'tox<4' tox-pypi-filter" + toxdeps: tox-pypi-filter libraries: | apt: - libopenjp2-7 - graphviz envs: | - - macos: py38 + - linux: py38 + - macos: py310 - windows: py39 - linux: build_docs publish: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff481c1..0b8e651 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,17 @@ repos: - repo: https://github.com/myint/docformatter - rev: v1.5.0 + rev: v1.7.3 hooks: - id: docformatter args: [--in-place, --pre-summary-newline, --make-summary-multi] - repo: https://github.com/myint/autoflake - rev: v2.0.0 + rev: v2.2.0 hooks: - id: autoflake args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable'] exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|__init__.py)$" - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.3.0 hooks: - id: black exclude: ".*(.fits|.fts|.fit|.txt|.csv)$" @@ -34,7 +34,7 @@ repos: - id: check-yaml - id: debug-statements - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v0.991' + rev: 'v1.4.1' hooks: - id: mypy additional_dependencies: [types-requests==2.28.0] diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 042ed4c..0d5daed 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -2,7 +2,7 @@ version: 2 build: os: ubuntu-20.04 tools: - python: "3.9" + python: "3.11" apt_packages: - libopenjp2-7 - graphviz diff --git a/LICENSE b/LICENSE index eec86db..069bcf3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 2-Clause License -Copyright (c) 2022, Helioviewer Project +Copyright (c) 2022-2023, Helioviewer Project All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/hvpy/api_groups/jpeg2000/tests/test_get_jp2_image.py b/hvpy/api_groups/jpeg2000/tests/test_get_jp2_image.py index ba53e64..ec620bd 100644 --- a/hvpy/api_groups/jpeg2000/tests/test_get_jp2_image.py +++ b/hvpy/api_groups/jpeg2000/tests/test_get_jp2_image.py @@ -8,14 +8,14 @@ def test_str_response(date): response = getJP2Image(date=date, sourceId=DataSource.AIA_335, jpip=True, json=False) assert isinstance(response, str) - assert response.startswith("jpip://") + assert response.startswith("jpips://") def test_json_response(date): response = getJP2Image(date=date, sourceId=14, jpip=True, json=True) assert isinstance(response, dict) assert "uri" in response - assert response["uri"].startswith("jpip://") + assert response["uri"].startswith("jpips://") def test_raw_response(date): diff --git a/hvpy/api_groups/jpeg2000/tests/test_get_jpx.py b/hvpy/api_groups/jpeg2000/tests/test_get_jpx.py index 4fa3c96..6646abe 100644 --- a/hvpy/api_groups/jpeg2000/tests/test_get_jpx.py +++ b/hvpy/api_groups/jpeg2000/tests/test_get_jpx.py @@ -29,7 +29,7 @@ def test_str_response(start_time, end_time): cadence=60, ) assert isinstance(response, str) - assert response.startswith("jpip://") + assert response.startswith("jpips://") def test_json_response(start_time, end_time): @@ -43,7 +43,7 @@ def test_json_response(start_time, end_time): cadence=60, ) assert isinstance(response, dict) - assert response["uri"].startswith("jpip://") + assert response["uri"].startswith("jpips://") response = getJPX( startTime=start_time, diff --git a/hvpy/api_groups/jpeg2000/tests/test_get_jpx_closest_to_mid_point.py b/hvpy/api_groups/jpeg2000/tests/test_get_jpx_closest_to_mid_point.py index 55d9293..cd0ca23 100644 --- a/hvpy/api_groups/jpeg2000/tests/test_get_jpx_closest_to_mid_point.py +++ b/hvpy/api_groups/jpeg2000/tests/test_get_jpx_closest_to_mid_point.py @@ -27,7 +27,7 @@ def test_str_response(start_times, end_times): jpip=True, ) assert isinstance(response, str) - assert response.startswith("jpip://") + assert response.startswith("jpips://") def test_json_response(start_times, end_times): @@ -40,7 +40,7 @@ def test_json_response(start_times, end_times): jpip=True, ) assert isinstance(response, dict) - assert response["uri"].startswith("jpip://") + assert response["uri"].startswith("jpips://") response = getJPXClosestToMidPoint( startTimes=start_times, diff --git a/hvpy/facade.py b/hvpy/facade.py index 21fd979..eb31d22 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -44,7 +44,7 @@ def getJP2Image( >>> from hvpy import getJP2Image >>> from datetime import datetime, timedelta >>> getJP2Image(date=datetime.today(), sourceId=14, jpip=True) - 'jpip://...' + 'jpips://...' """ params = getJP2ImageInputParameters(date=date, sourceId=sourceId, jpip=jpip, json=json) return execute_api_call(input_parameters=params) @@ -99,7 +99,7 @@ def getJPXClosestToMidPoint( ... linked=False, ... jpip=True ... ) - 'jpip://beta.helioviewer.org:8090/movies/SDO_AIA_335_...jpxmid' + 'jpips://beta.helioviewer.org:8090/movies/SDO_AIA_335_...jpxmid' """ params = getJPXClosestToMidPointInputParameters( startTimes=startTimes, @@ -140,7 +140,7 @@ def getJPX( ... jpip=True, ... verbose=False, ... cadence=60) - 'jpip://beta.helioviewer.org:8090/movies/...' + 'jpips://beta.helioviewer.org:8090/movies/...' """ params = getJPXInputParameters( startTime=startTime, diff --git a/pyproject.toml b/pyproject.toml index 14684ec..ad3ed19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ - "setuptools>=56,!=61.0.0", - "setuptools_scm[toml]>=6.2", + "setuptools", + "setuptools_scm[toml]", "wheel", ] build-backend = 'setuptools.build_meta' diff --git a/setup.cfg b/setup.cfg index 023108a..a85590d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,7 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Topic :: Scientific/Engineering :: Physics [options] @@ -41,7 +42,7 @@ tests = pytest>=6.0 docs = # Newer versions break for now - sphinx<5.1.0 + sphinx<6.0.0 sphinx-autodoc-typehints sphinx-automodapi sphinx-book-theme diff --git a/tox.ini b/tox.ini index 2f87820..2fda4e5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,25 +1,23 @@ [tox] +min_version = 4.0 envlist = - py{38,39,310} + py{38,39,310,311} build_docs codestyle requires = - setuptools >=56, !=61.0.0 - pip >= 19.3.1 -isolated_build = true + setuptools + pip [testenv] -passenv = HOME WINDIR LC_ALL LC_CTYPE CC CI TRAVIS setenv = - PYTEST_COMMAND = pytest -vvv -r a --pyargs hvpy --cov-report=xml --cov=hvpy --cov-config={toxinidir}/setup.cfg {toxinidir}/docs + PYTEST_COMMAND = pytest -vvv -r a --pyargs hvpy --cov-report=xml --cov=hvpy --cov-config={toxinidir}/setup.cfg --timeout=60 {toxinidir}/docs HELIOVIEWER_API_URL = https://api.beta.helioviewer.org/v2/ -# Run the tests in a temporary directory to make sure that we don't import -# the package from the source tree +# Run the tests in a temporary directory to make sure that we don't import the package from the source tree changedir = .tmp/{envname} description = run tests - online: that require remote data (as well as the offline ones) deps = + pytest-timeout extras = all tests From ded2fdb19a13fa4a76ef63f796e7d569f37a01a8 Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Sat, 1 Jul 2023 10:19:24 -0700 Subject: [PATCH 2/4] SUpport for pydantic 2.0 only --- hvpy/api_groups/jpeg2000/get_jp2_image.py | 6 +-- hvpy/api_groups/jpeg2000/get_jpx.py | 6 +-- .../jpeg2000/get_jpx_closest_to_mid_point.py | 6 +-- hvpy/api_groups/movies/queue_movie.py | 6 +-- .../official_clients/get_closest_image.py | 6 +-- hvpy/api_groups/screenshots/get_tile.py | 4 +- .../api_groups/screenshots/take_screenshot.py | 20 ++++---- hvpy/config.py | 6 ++- hvpy/core.py | 2 +- hvpy/facade.py | 46 +++++++++---------- hvpy/helpers.py | 32 ++++++------- hvpy/io.py | 17 ++++--- setup.cfg | 4 +- tox.ini | 1 - 14 files changed, 84 insertions(+), 78 deletions(-) diff --git a/hvpy/api_groups/jpeg2000/get_jp2_image.py b/hvpy/api_groups/jpeg2000/get_jp2_image.py index af6b4e2..1b6be90 100644 --- a/hvpy/api_groups/jpeg2000/get_jp2_image.py +++ b/hvpy/api_groups/jpeg2000/get_jp2_image.py @@ -1,7 +1,7 @@ from typing import Union from datetime import datetime -from pydantic import Field, validator +from pydantic import Field, field_validator from hvpy.datasource import DataSource from hvpy.io import HvpyParameters, OutputType @@ -37,8 +37,8 @@ class getJP2ImageInputParameters(HvpyParameters): sourceId: Union[int, DataSource] jpip: bool = False Json: bool = Field(False, alias="json") - _date_validator = validator("date", allow_reuse=True)(convert_date_to_isoformat) - _source_id_validator = validator("sourceId", allow_reuse=True)(_data_source_to_int) + _date_validator = field_validator("date")(convert_date_to_isoformat) + _source_id_validator = field_validator("sourceId")(_data_source_to_int) def get_output_type(self) -> OutputType: """ diff --git a/hvpy/api_groups/jpeg2000/get_jpx.py b/hvpy/api_groups/jpeg2000/get_jpx.py index db59370..e663b77 100644 --- a/hvpy/api_groups/jpeg2000/get_jpx.py +++ b/hvpy/api_groups/jpeg2000/get_jpx.py @@ -1,7 +1,7 @@ from typing import Union, Optional from datetime import datetime -from pydantic import validator +from pydantic import field_validator from hvpy.datasource import DataSource from hvpy.io import HvpyParameters, OutputType @@ -50,8 +50,8 @@ class getJPXInputParameters(HvpyParameters): verbose: bool = False jpip: bool = False cadence: Optional[int] = None - _date_validator = validator("startTime", "endTime", allow_reuse=True)(convert_date_to_isoformat) - _source_id_validator = validator("sourceId", allow_reuse=True)(_data_source_to_int) + _date_validator = field_validator("startTime", "endTime")(convert_date_to_isoformat) + _source_id_validator = field_validator("sourceId")(_data_source_to_int) def get_output_type(self) -> OutputType: """ diff --git a/hvpy/api_groups/jpeg2000/get_jpx_closest_to_mid_point.py b/hvpy/api_groups/jpeg2000/get_jpx_closest_to_mid_point.py index d0e17aa..09b9a31 100644 --- a/hvpy/api_groups/jpeg2000/get_jpx_closest_to_mid_point.py +++ b/hvpy/api_groups/jpeg2000/get_jpx_closest_to_mid_point.py @@ -1,7 +1,7 @@ from typing import List, Union from datetime import datetime -from pydantic import validator +from pydantic import field_validator from hvpy.datasource import DataSource from hvpy.io import HvpyParameters, OutputType @@ -44,8 +44,8 @@ class getJPXClosestToMidPointInputParameters(HvpyParameters): linked: bool = True verbose: bool = False jpip: bool = False - _date_validator = validator("startTimes", "endTimes", allow_reuse=True)(convert_date_to_unix) - _source_id_validator = validator("sourceId", allow_reuse=True)(_data_source_to_int) + _date_validator = field_validator("startTimes", "endTimes")(convert_date_to_unix) + _source_id_validator = field_validator("sourceId")(_data_source_to_int) def get_output_type(self) -> OutputType: """ diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index ac8b68f..1ca88c4 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -1,7 +1,7 @@ from typing import Optional from datetime import datetime -from pydantic import validator +from pydantic import field_validator from hvpy.io import HvpyParameters, OutputType from hvpy.utils import convert_date_to_isoformat @@ -134,9 +134,7 @@ class queueMovieInputParameters(HvpyParameters): movieIcons: Optional[int] = None followViewport: Optional[int] = None reqObservationDate: Optional[datetime] = None - _date_validator = validator("startTime", "endTime", "reqObservationDate", allow_reuse=True)( - convert_date_to_isoformat - ) + _date_validator = field_validator("startTime", "endTime", "reqObservationDate")(convert_date_to_isoformat) def get_output_type(self) -> OutputType: """ diff --git a/hvpy/api_groups/official_clients/get_closest_image.py b/hvpy/api_groups/official_clients/get_closest_image.py index 8df873f..5971238 100644 --- a/hvpy/api_groups/official_clients/get_closest_image.py +++ b/hvpy/api_groups/official_clients/get_closest_image.py @@ -1,7 +1,7 @@ from typing import Union, Optional from datetime import datetime -from pydantic import validator +from pydantic import field_validator from hvpy.datasource import DataSource from hvpy.io import HvpyParameters, OutputType @@ -33,8 +33,8 @@ class getClosestImageInputParameters(HvpyParameters): date: datetime sourceId: Union[int, DataSource] callback: Optional[str] = None - _date_validator = validator("date", allow_reuse=True)(convert_date_to_isoformat) - _source_id_validator = validator("sourceId", allow_reuse=True)(_data_source_to_int) + _date_validator = field_validator("date")(convert_date_to_isoformat) + _source_id_validator = field_validator("sourceId")(_data_source_to_int) def get_output_type(self) -> OutputType: """ diff --git a/hvpy/api_groups/screenshots/get_tile.py b/hvpy/api_groups/screenshots/get_tile.py index 0026c10..4bd5904 100644 --- a/hvpy/api_groups/screenshots/get_tile.py +++ b/hvpy/api_groups/screenshots/get_tile.py @@ -1,7 +1,7 @@ from typing import Optional from datetime import datetime -from pydantic import validator +from pydantic import field_validator from hvpy.io import HvpyParameters, OutputType from hvpy.utils import convert_date_to_isoformat @@ -65,7 +65,7 @@ class getTileInputParameters(HvpyParameters): diffTime: Optional[int] = None baseDiffTime: Optional[datetime] = None - _date_vaidator = validator("baseDiffTime", allow_reuse=True)(convert_date_to_isoformat) + _date_vaidator = field_validator("baseDiffTime")(convert_date_to_isoformat) def get_output_type(self) -> OutputType: """ diff --git a/hvpy/api_groups/screenshots/take_screenshot.py b/hvpy/api_groups/screenshots/take_screenshot.py index ece50e1..e016fd4 100644 --- a/hvpy/api_groups/screenshots/take_screenshot.py +++ b/hvpy/api_groups/screenshots/take_screenshot.py @@ -1,7 +1,7 @@ from typing import Optional from datetime import datetime -from pydantic import validator +from pydantic import field_validator from hvpy.io import HvpyParameters, OutputType from hvpy.utils import convert_date_to_isoformat @@ -98,18 +98,18 @@ class takeScreenshotInputParameters(HvpyParameters): scaleType: Optional[str] = None scaleX: Optional[int] = None scaleY: Optional[int] = None - width: Optional[str] = None - height: Optional[str] = None - x0: Optional[str] = None - y0: Optional[str] = None - x1: Optional[str] = None - y1: Optional[str] = None - x2: Optional[str] = None - y2: Optional[str] = None + width: Optional[int] = None + height: Optional[int] = None + x0: Optional[int] = None + y0: Optional[int] = None + x1: Optional[int] = None + y1: Optional[int] = None + x2: Optional[int] = None + y2: Optional[int] = None display: bool = False watermark: bool = False callback: Optional[str] = None - _date_vaidator = validator("date", allow_reuse=True)(convert_date_to_isoformat) + _date_vaidator = field_validator("date")(convert_date_to_isoformat) def get_output_type(self) -> OutputType: """ diff --git a/hvpy/config.py b/hvpy/config.py index 492d436..77e15c9 100644 --- a/hvpy/config.py +++ b/hvpy/config.py @@ -1,10 +1,12 @@ -from pydantic import BaseSettings, Field +from pydantic import Field +from pydantic_settings import BaseSettings, SettingsConfigDict __all__ = ["LiveSettings", "set_api_url", "get_api_url"] class Settings(BaseSettings): - api_url: str = Field("https://api.helioviewer.org/v2/", env="HELIOVIEWER_API_URL") + model_config = SettingsConfigDict(env_prefix="HELIOVIEWER_") + api_url: str = Field("https://api.helioviewer.org/v2/") def get_api_url() -> str: diff --git a/hvpy/core.py b/hvpy/core.py index 1220142..4b9de4b 100644 --- a/hvpy/core.py +++ b/hvpy/core.py @@ -47,6 +47,6 @@ def execute_api_call(input_parameters: HvpyParameters) -> Union[bytes, str, Dict Union[bytes, str, Dict[str, Any]] Parsed response from the API. """ - response = requests.get(input_parameters.url, params=input_parameters.dict()) + response = requests.get(input_parameters.url, params=input_parameters.model_dump()) response.raise_for_status() return parse_response(response, input_parameters.get_output_type()) diff --git a/hvpy/facade.py b/hvpy/facade.py index eb31d22..884a0fc 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -65,7 +65,7 @@ def getJP2Header( Examples -------- >>> from hvpy import getJP2Header - >>> getJP2Header(id=7654321,callback="xml_header") + >>> getJP2Header(id=7654321, callback="xml_header") 'xml_header(\\\'...')' """ params = getJP2HeaderInputParameters(id=id, callback=callback) @@ -99,7 +99,7 @@ def getJPXClosestToMidPoint( ... linked=False, ... jpip=True ... ) - 'jpips://beta.helioviewer.org:8090/movies/SDO_AIA_335_...jpxmid' + 'jpips://beta.helioviewer.org:8092/movies/...jpxmid' """ params = getJPXClosestToMidPointInputParameters( startTimes=startTimes, @@ -140,7 +140,7 @@ def getJPX( ... jpip=True, ... verbose=False, ... cadence=60) - 'jpips://beta.helioviewer.org:8090/movies/...' + 'jpips://beta.helioviewer.org:8092/movies/...' """ params = getJPXInputParameters( startTime=startTime, @@ -217,7 +217,7 @@ def getDataSources( -------- >>> from hvpy import getDataSources >>> getDataSources() - {'GOES-R': {'SUVI': {...: {'sourceId': ..., 'nickname': 'GOES-R SUVI 94', 'layeringOrder': 1, 'start': ..., 'end': ..., 'uiLabels': [{'label': 'Observatory', 'name': 'GOES-R'}, {'label': 'Detector', 'name': 'SUVI'}, ...} + {'GOES-R': {'SUVI': {'94': {'sourceId': 2000, 'nickname': 'GOES-R SUVI 94', 'layeringOrder': 1, 'start': '...', 'end': '...', 'uiLabels': [{'label': 'Observatory', 'name': 'GOES-R'}, {'label': 'Instrument', 'name': 'SUVI'}, {'label': 'Measurement', 'name': '94'}]}... """ params = getDataSourcesInputParameters( verbose=verbose, @@ -238,14 +238,14 @@ def takeScreenshot( scaleType: Optional[str] = None, scaleX: Optional[int] = None, scaleY: Optional[int] = None, - width: Optional[str] = None, - height: Optional[str] = None, - x0: Optional[str] = None, - y0: Optional[str] = None, - x1: Optional[str] = None, - y1: Optional[str] = None, - x2: Optional[str] = None, - y2: Optional[str] = None, + width: Optional[int] = None, + height: Optional[int] = None, + x0: Optional[int] = None, + y0: Optional[int] = None, + x1: Optional[int] = None, + y1: Optional[int] = None, + x2: Optional[int] = None, + y2: Optional[int] = None, display: bool = False, watermark: bool = False, callback: Optional[str] = None, @@ -332,14 +332,14 @@ def queueMovie( scaleY: Optional[float] = None, movieLength: Optional[float] = None, watermark: bool = True, - width: Optional[str] = None, - height: Optional[str] = None, - x0: Optional[str] = None, - y0: Optional[str] = None, - x1: Optional[str] = None, - y1: Optional[str] = None, - x2: Optional[str] = None, - y2: Optional[str] = None, + width: Optional[int] = None, + height: Optional[int] = None, + x0: Optional[int] = None, + y0: Optional[int] = None, + x1: Optional[int] = None, + y1: Optional[int] = None, + x2: Optional[int] = None, + y2: Optional[int] = None, callback: Optional[str] = None, size: int = 0, movieIcons: Optional[int] = None, @@ -412,8 +412,8 @@ def reQueueMovie( {Insert} Examples -------- - >>> from hvpy import reQueueMovie # doctest: +SKIP - >>> reQueueMovie(id="gxRN5", force=True) # doctest: +SKIP + >>> from hvpy import reQueueMovie + >>> reQueueMovie(id="gxRN5", force=True) # doctest: +SKIP {'id': 'gxRN5', 'eta': 274, 'queue': 0, 'token': '...'} """ params = reQueueMovieInputParameters( @@ -440,7 +440,7 @@ def getMovieStatus( Examples -------- >>> from hvpy import getMovieStatus - >>> getMovieStatus(id="h2n6n", format="mp4") + >>> getMovieStatus(id="h2n6n", format="mp4") # doctest: +SKIP {'frameRate': ..., 'numFrames': ..., 'startDate': '...', 'status': ..., 'endDate': '...', 'width': ..., 'height': ..., 'title': '...', 'thumbnails': {'icon': '...', 'small': '...', 'medium': '...', 'large': '...', 'full': '...'}, 'url': '...', 'statusLabel': 'Completed'} """ params = getMovieStatusInputParameters( diff --git a/hvpy/helpers.py b/hvpy/helpers.py index cb9f566..03eac3b 100644 --- a/hvpy/helpers.py +++ b/hvpy/helpers.py @@ -31,14 +31,14 @@ def createMovie( scaleY: Optional[float] = None, movieLength: Optional[float] = None, watermark: bool = True, - width: Optional[str] = None, - height: Optional[str] = None, - x0: Optional[str] = None, - y0: Optional[str] = None, - x1: Optional[str] = None, - y1: Optional[str] = None, - x2: Optional[str] = None, - y2: Optional[str] = None, + width: Optional[int] = None, + height: Optional[int] = None, + x0: Optional[int] = None, + y0: Optional[int] = None, + x1: Optional[int] = None, + y1: Optional[int] = None, + x2: Optional[int] = None, + y2: Optional[int] = None, size: int = 0, movieIcons: Optional[int] = None, followViewport: Optional[int] = None, @@ -141,14 +141,14 @@ def createScreenshot( scaleType: Optional[str] = None, scaleX: Optional[int] = None, scaleY: Optional[int] = None, - width: Optional[str] = None, - height: Optional[str] = None, - x0: Optional[str] = None, - y0: Optional[str] = None, - x1: Optional[str] = None, - y1: Optional[str] = None, - x2: Optional[str] = None, - y2: Optional[str] = None, + width: Optional[int] = None, + height: Optional[int] = None, + x0: Optional[int] = None, + y0: Optional[int] = None, + x1: Optional[int] = None, + y1: Optional[int] = None, + x2: Optional[int] = None, + y2: Optional[int] = None, watermark: bool = False, overwrite: bool = False, filename: Optional[Union[str, Path]] = None, diff --git a/hvpy/io.py b/hvpy/io.py index 4b48767..fad26f9 100644 --- a/hvpy/io.py +++ b/hvpy/io.py @@ -28,13 +28,18 @@ class HvpyParameters(BaseModel): Base model for all Helioviewer API parameters. """ - def dict(self) -> Dict[str, Any]: # type: ignore + def model_dump(self) -> Dict[str, Any]: # pydantic doesn't allow using lowercase 'json' as a field - d = super().dict() - if "Json" in d: - d["json"] = d["Json"] - del d["Json"] - return d + import warnings + + with warnings.catch_warnings(): + # Our datetime fields are strings(???) and pydantic complains about that + warnings.simplefilter("ignore") + dump = super().model_dump() + if "Json" in dump: + dump["json"] = dump["Json"] + del dump["Json"] + return dump def get_output_type(self) -> OutputType: """ diff --git a/setup.cfg b/setup.cfg index a85590d..b8ee000 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,11 +34,13 @@ setup_requires = setuptools_scm install_requires = requests>=2.27.0 - pydantic>=1.9.1,<2 + pydantic>=2.0.0 + pydantic-settings>=2.0.0 [options.extras_require] tests = pytest-astropy>=0.10 + pytest-timeout pytest>=6.0 docs = # Newer versions break for now diff --git a/tox.ini b/tox.ini index 2fda4e5..905683f 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,6 @@ changedir = .tmp/{envname} description = run tests deps = - pytest-timeout extras = all tests From 75a90bd8c166c72866bbdf97763bad76119ad472 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Briseno <94071409+dgarciabriseno@users.noreply.github.com> Date: Mon, 10 Jul 2023 16:25:39 -0400 Subject: [PATCH 3/4] Fix movie timeout test & add IRIS / GONG data sources (#98) * Add IRIS and GONG datasources * Update timeout test to have a shorter timeout * Fix codestyle * Increase test timeout to 2 minutes --- hvpy/datasource.py | 35 +++++++++++++++++++++++++++++++++++ hvpy/tests/test_helper.py | 2 +- tox.ini | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hvpy/datasource.py b/hvpy/datasource.py index 0725b60..430aaf5 100644 --- a/hvpy/datasource.py +++ b/hvpy/datasource.py @@ -438,6 +438,41 @@ class DataSource(Enum): Solar Orbiter instrument HRI, measurement 1216. """ + IRIS_SJI_1330 = 88 + """ + IRIS Slit Jaw Imager, measurement 1330. + """ + + IRIS_SJI_2796 = 89 + """ + IRIS Slit Jaw Imager, measurement 2796. + """ + + IRIS_SJI_1400 = 90 + """ + IRIS Slit Jaw Imager, measurement 1400. + """ + + IRIS_SJI_2832 = 92 + """ + IRIS Slit Jaw Imager, measurement 2832. + """ + + GONG_MAGNETOGRAM = 37 + """ + NSO GONG Magnetograms. + """ + + GONG_H_ALPHA = 94 + """ + NSO GONG H-Alpha. + """ + + GONG_FARSIDE = 95 + """ + NSO GONG Farside. + """ + SUVI_94 = 2000 """ GOES-R instrument SUVI, measurement 94. diff --git a/hvpy/tests/test_helper.py b/hvpy/tests/test_helper.py index 5e50038..bf64fdc 100644 --- a/hvpy/tests/test_helper.py +++ b/hvpy/tests/test_helper.py @@ -63,7 +63,7 @@ def test_createMovie_timeout(start_time, end_time, tmp_path): eventsLabels=True, imageScale=1, filename=f1, - timeout=0.5, + timeout=0.01, ) diff --git a/tox.ini b/tox.ini index 905683f..b283197 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ requires = [testenv] setenv = - PYTEST_COMMAND = pytest -vvv -r a --pyargs hvpy --cov-report=xml --cov=hvpy --cov-config={toxinidir}/setup.cfg --timeout=60 {toxinidir}/docs + PYTEST_COMMAND = pytest -vvv -r a --pyargs hvpy --cov-report=xml --cov=hvpy --cov-config={toxinidir}/setup.cfg --timeout=120 {toxinidir}/docs HELIOVIEWER_API_URL = https://api.beta.helioviewer.org/v2/ # Run the tests in a temporary directory to make sure that we don't import the package from the source tree changedir = .tmp/{envname} From 9ada3e851cb558563c54f7b94733e4541041058a Mon Sep 17 00:00:00 2001 From: Nabil Freij Date: Mon, 10 Jul 2023 13:48:56 -0700 Subject: [PATCH 4/4] Minor tweaks to intersphinx_mapping --- .pre-commit-config.yaml | 2 +- docs/conf.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b8e651..3d9131b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/myint/docformatter - rev: v1.7.3 + rev: v1.7.4 hooks: - id: docformatter args: [--in-place, --pre-summary-newline, --make-summary-multi] diff --git a/docs/conf.py b/docs/conf.py index 0d6a488..457d9d3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,12 +44,8 @@ # -- Options for intersphinx extension ----------------------------------------- intersphinx_mapping = { "python": ("https://docs.python.org/3/", None), - "numpy": ("https://numpy.org/doc/stable/", None), - "scipy": ("https://docs.scipy.org/doc/scipy/reference/", None), - "matplotlib": ("https://matplotlib.org/stable", None), - "aiapy": ("https://aiapy.readthedocs.io/en/stable/", None), - "astropy": ("https://docs.astropy.org/en/stable/", None), "requests": ("https://requests.readthedocs.io/en/stable/", None), + "pydantic": ("https://docs.pydantic.dev/latest/", None), } # -- Options for HTML output ---------------------------------------------------