From e52fe7caf64d35539b99e57604e2636e9ad4cc4e Mon Sep 17 00:00:00 2001 From: akash5100 Date: Tue, 12 Jul 2022 14:53:29 +0530 Subject: [PATCH 01/19] init files --- hvpy/api_groups/movies/__init__.py | 0 hvpy/api_groups/movies/tests/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 hvpy/api_groups/movies/__init__.py create mode 100644 hvpy/api_groups/movies/tests/__init__.py diff --git a/hvpy/api_groups/movies/__init__.py b/hvpy/api_groups/movies/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hvpy/api_groups/movies/tests/__init__.py b/hvpy/api_groups/movies/tests/__init__.py new file mode 100644 index 0000000..e69de29 From 0baadceea46c9118c5ae0d3727702eb0f9c8124f Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 20:50:38 +0530 Subject: [PATCH 02/19] Adds queueMovie endpoint --- hvpy/api_groups/movies/queue_movie.py | 117 ++++++++++++++++++ .../movies/tests/test_queue_movie.py | 15 +++ hvpy/facade.py | 75 ++++++++++- hvpy/parameters.py | 3 +- 4 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 hvpy/api_groups/movies/queue_movie.py create mode 100644 hvpy/api_groups/movies/tests/test_queue_movie.py diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py new file mode 100644 index 0000000..c8fd51e --- /dev/null +++ b/hvpy/api_groups/movies/queue_movie.py @@ -0,0 +1,117 @@ +from typing import Optional +from datetime import datetime + +from pydantic import validator + +from hvpy.io import HvpyParameters, OutputType +from hvpy.utils import convert_date_to_isoformat + + +class queueMovieInputParameters(HvpyParameters): + """ + Handles the input parameters of the queueMovie API. + + {Shared} + Attributes + ---------- + startTime : datetime + Date and time of the first frame of the movie. + endTime : datetime + Date and time of the final frame of the movie. + layers : str + Image datasource layers to include in the movie. + events : str + List of feature/event types and FRMs to use to annotate the movie. + eventsLabels : bool + Annotate each event marker with a text label. + imageScale : float + Image scale in arcseconds per pixel. + format : str, optional + Movie format (mp4, webm, flv). Default value is mp4. + frameRate : str, optional + Movie frames per second. 15 frames per second by default. + maxFrames : str, optional + Maximum number of frames in the movie. May be capped by the server. + scale : bool, optional + Optionally overlay an image scale indicator. + scaleType : str, optional + Image scale indicator + scaleX : float, optional + Horizontal offset of the image scale indicator in arcseconds with respect to the center of the Sun. + scaleY : float, optional + Vertical offset of the image scale indicator in arcseconds with respect to the center of the Sun. + movieLength : float, optional + movie length in seconds. + watermark : bool, optional + Optionally overlay a Helioviewer.org watermark image. Enabled by default + width : str, optional + Width of the field of view in pixels. (Used in conjunction width x0,`y0`, and height). + height : str, optional + Height of the field of view in pixels. (Used in conjunction width x0,`y0`, and width). + x0 : str, optional + The horizontal offset of the center of the field of view from the center of the Sun. Used in conjunction with y0, width, and height. + y0 : str, optional + The vertical offset of the center of the field of view from the center of the Sun. Used in conjunction with x0, width, and height. + x1 : str, optional + The horizontal offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with y1, x2, and y2. + y1 : str, optional + The vertical offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, x2, and y2. + x2 : str, optional + The horizontal offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and y2. + y2 : str, optional + The vertical offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and x2. + callback : str, optional + Wrap the response object in a function call of your choosing. + size : int, optional + Scale video to preset size. Default value is 0. + movieIcons : int, optional + Display other user generated movies on the video. + followViewport : int, optional + Rotate field of view of movie with Sun. + reqObservationDate : datetime, optional + Viewport time. Used when 'followViewport' enabled to shift viewport area to correct coordinates + + + References + ---------- + * ``__ + {Shared} + """ + + startTime: datetime + endTime: datetime + layers: str + events: str + eventsLabels: bool + imageScale: float + format: Optional[str] = "mp4" + frameRate: Optional[str] = "15" + maxFrames: Optional[str] = None + scale: Optional[bool] = None + scaleType: Optional[str] = None + scaleX: Optional[float] = None + scaleY: Optional[float] = None + movieLength: Optional[float] = None + watermark: Optional[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 + callback: Optional[str] = None + size: Optional[int] = None + movieIcons: Optional[int] = None + followViewport: Optional[int] = None + reqObservationDate: Optional[datetime] = None + _date_validator = validator("startTime", "endTime", "reqObservationalDate", allow_reuse=True, check_fields=False)( + convert_date_to_isoformat + ) + + def get_output_type(self) -> OutputType: + """ + Returns the output type of the API call. + """ + return OutputType.JSON diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py new file mode 100644 index 0000000..de22683 --- /dev/null +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -0,0 +1,15 @@ +from datetime import datetime + +from hvpy import queueMovie + + +def test_queue(): + response = queueMovie( + startTime=datetime(2022, 7, 12, 12, 12, 12), + endTime=datetime(2022, 7, 13, 12, 12, 12), + layers="[12,7,22],[13,7,22]", + events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + eventsLabels=False, + imageScale=21.04, + ) + print(response) diff --git a/hvpy/facade.py b/hvpy/facade.py index d668b83..7a15a9b 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -1,11 +1,11 @@ -from typing import Any, Dict, Union +from typing import Any, Dict, Union, Optional from datetime import datetime from hvpy.core import execute_api_call from hvpy.parameters import * from hvpy.utils import add_shared_docstring -__all__ = ["getJP2Image"] +__all__ = ["getJP2Image", "queueMovie"] @add_shared_docstring(getJP2ImageInputParameters) @@ -27,3 +27,74 @@ def getJP2Image( """ params = getJP2ImageInputParameters(date=date, sourceId=sourceId, jpip=jpip, json=json) return execute_api_call(input_parameters=params) + + +@add_shared_docstring(queueMovieInputParameters) +def queueMovie( + startTime: datetime, + endTime: datetime, + layers: str, + events: str, + eventsLabels: bool, + imageScale: float, + format: Optional[str] = "mp4", + frameRate: Optional[str] = "15", + maxFrames: Optional[str] = None, + scale: Optional[bool] = None, + scaleType: Optional[str] = None, + scaleX: Optional[float] = None, + scaleY: Optional[float] = None, + movieLength: Optional[float] = None, + watermark: Optional[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, + callback: Optional[str] = None, + size: Optional[int] = None, + movieIcons: Optional[int] = None, + followViewport: Optional[int] = None, + reqObservationDate: Optional[datetime] = None, +) -> Union[bytes, str, Dict[str, Any]]: + """ + Queue a movie for download from the helioviewer.org API. + + {Insert} + Examples + -------- + """ + params = queueMovieInputParameters( + startTime=startTime, + endTime=endTime, + layers=layers, + events=events, + eventsLabels=eventsLabels, + imageScale=imageScale, + format=format, + frameRate=frameRate, + maxFrames=maxFrames, + scale=scale, + scaleType=scaleType, + scaleX=scaleX, + scaleY=scaleY, + movieLength=movieLength, + watermark=watermark, + width=width, + height=height, + x0=x0, + y0=y0, + x1=x1, + y1=y1, + x2=x2, + y2=y2, + callback=callback, + size=size, + movieIcons=movieIcons, + followViewport=followViewport, + reqObservationDate=reqObservationDate, + ) + return execute_api_call(input_parameters=params) diff --git a/hvpy/parameters.py b/hvpy/parameters.py index 6c9bbdf..97106cd 100644 --- a/hvpy/parameters.py +++ b/hvpy/parameters.py @@ -1,3 +1,4 @@ from hvpy.api_groups.jpeg2000.get_jp2_image import getJP2ImageInputParameters +from hvpy.api_groups.movies.queue_movie import queueMovieInputParameters -__all__ = ["getJP2ImageInputParameters"] +__all__ = ["getJP2ImageInputParameters", "queueMovieInputParameters"] From 728e1e29c6851a2187db68e90abcd645de2917f9 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 21:27:27 +0530 Subject: [PATCH 03/19] tweaks to docs build --- hvpy/api_groups/movies/queue_movie.py | 2 +- hvpy/facade.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index c8fd51e..d31d9f7 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -11,9 +11,9 @@ class queueMovieInputParameters(HvpyParameters): """ Handles the input parameters of the queueMovie API. - {Shared} Attributes ---------- + {Shared} startTime : datetime Date and time of the first frame of the movie. endTime : datetime diff --git a/hvpy/facade.py b/hvpy/facade.py index 7a15a9b..072f4c1 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -63,6 +63,8 @@ def queueMovie( """ Queue a movie for download from the helioviewer.org API. + Parameters + ---------- {Insert} Examples -------- From 6c579d076a1c20201920112bb28ccd4b4c1961a2 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 21:35:36 +0530 Subject: [PATCH 04/19] fix for failing docs build --- hvpy/api_groups/movies/queue_movie.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index d31d9f7..d9fac0b 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -14,9 +14,9 @@ class queueMovieInputParameters(HvpyParameters): Attributes ---------- {Shared} - startTime : datetime + startTime : datetime.datetime Date and time of the first frame of the movie. - endTime : datetime + endTime : datetime.datetime Date and time of the final frame of the movie. layers : str Image datasource layers to include in the movie. @@ -68,7 +68,7 @@ class queueMovieInputParameters(HvpyParameters): Display other user generated movies on the video. followViewport : int, optional Rotate field of view of movie with Sun. - reqObservationDate : datetime, optional + reqObservationDate : datetime.datetime, optional Viewport time. Used when 'followViewport' enabled to shift viewport area to correct coordinates From 70c0fe07054d30148c178b829e3db284a82a788d Mon Sep 17 00:00:00 2001 From: akash5100 Date: Tue, 12 Jul 2022 14:53:29 +0530 Subject: [PATCH 05/19] init files --- hvpy/api_groups/movies/__init__.py | 0 hvpy/api_groups/movies/tests/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 hvpy/api_groups/movies/__init__.py create mode 100644 hvpy/api_groups/movies/tests/__init__.py diff --git a/hvpy/api_groups/movies/__init__.py b/hvpy/api_groups/movies/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hvpy/api_groups/movies/tests/__init__.py b/hvpy/api_groups/movies/tests/__init__.py new file mode 100644 index 0000000..e69de29 From 0dcddedcba910acb0f5ebc679df5208658f27d68 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 20:50:38 +0530 Subject: [PATCH 06/19] Adds queueMovie endpoint --- hvpy/api_groups/movies/queue_movie.py | 117 ++++++++++++++++++ .../movies/tests/test_queue_movie.py | 15 +++ hvpy/facade.py | 72 +++++++++++ hvpy/parameters.py | 2 + 4 files changed, 206 insertions(+) create mode 100644 hvpy/api_groups/movies/queue_movie.py create mode 100644 hvpy/api_groups/movies/tests/test_queue_movie.py diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py new file mode 100644 index 0000000..c8fd51e --- /dev/null +++ b/hvpy/api_groups/movies/queue_movie.py @@ -0,0 +1,117 @@ +from typing import Optional +from datetime import datetime + +from pydantic import validator + +from hvpy.io import HvpyParameters, OutputType +from hvpy.utils import convert_date_to_isoformat + + +class queueMovieInputParameters(HvpyParameters): + """ + Handles the input parameters of the queueMovie API. + + {Shared} + Attributes + ---------- + startTime : datetime + Date and time of the first frame of the movie. + endTime : datetime + Date and time of the final frame of the movie. + layers : str + Image datasource layers to include in the movie. + events : str + List of feature/event types and FRMs to use to annotate the movie. + eventsLabels : bool + Annotate each event marker with a text label. + imageScale : float + Image scale in arcseconds per pixel. + format : str, optional + Movie format (mp4, webm, flv). Default value is mp4. + frameRate : str, optional + Movie frames per second. 15 frames per second by default. + maxFrames : str, optional + Maximum number of frames in the movie. May be capped by the server. + scale : bool, optional + Optionally overlay an image scale indicator. + scaleType : str, optional + Image scale indicator + scaleX : float, optional + Horizontal offset of the image scale indicator in arcseconds with respect to the center of the Sun. + scaleY : float, optional + Vertical offset of the image scale indicator in arcseconds with respect to the center of the Sun. + movieLength : float, optional + movie length in seconds. + watermark : bool, optional + Optionally overlay a Helioviewer.org watermark image. Enabled by default + width : str, optional + Width of the field of view in pixels. (Used in conjunction width x0,`y0`, and height). + height : str, optional + Height of the field of view in pixels. (Used in conjunction width x0,`y0`, and width). + x0 : str, optional + The horizontal offset of the center of the field of view from the center of the Sun. Used in conjunction with y0, width, and height. + y0 : str, optional + The vertical offset of the center of the field of view from the center of the Sun. Used in conjunction with x0, width, and height. + x1 : str, optional + The horizontal offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with y1, x2, and y2. + y1 : str, optional + The vertical offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, x2, and y2. + x2 : str, optional + The horizontal offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and y2. + y2 : str, optional + The vertical offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and x2. + callback : str, optional + Wrap the response object in a function call of your choosing. + size : int, optional + Scale video to preset size. Default value is 0. + movieIcons : int, optional + Display other user generated movies on the video. + followViewport : int, optional + Rotate field of view of movie with Sun. + reqObservationDate : datetime, optional + Viewport time. Used when 'followViewport' enabled to shift viewport area to correct coordinates + + + References + ---------- + * ``__ + {Shared} + """ + + startTime: datetime + endTime: datetime + layers: str + events: str + eventsLabels: bool + imageScale: float + format: Optional[str] = "mp4" + frameRate: Optional[str] = "15" + maxFrames: Optional[str] = None + scale: Optional[bool] = None + scaleType: Optional[str] = None + scaleX: Optional[float] = None + scaleY: Optional[float] = None + movieLength: Optional[float] = None + watermark: Optional[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 + callback: Optional[str] = None + size: Optional[int] = None + movieIcons: Optional[int] = None + followViewport: Optional[int] = None + reqObservationDate: Optional[datetime] = None + _date_validator = validator("startTime", "endTime", "reqObservationalDate", allow_reuse=True, check_fields=False)( + convert_date_to_isoformat + ) + + def get_output_type(self) -> OutputType: + """ + Returns the output type of the API call. + """ + return OutputType.JSON diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py new file mode 100644 index 0000000..de22683 --- /dev/null +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -0,0 +1,15 @@ +from datetime import datetime + +from hvpy import queueMovie + + +def test_queue(): + response = queueMovie( + startTime=datetime(2022, 7, 12, 12, 12, 12), + endTime=datetime(2022, 7, 13, 12, 12, 12), + layers="[12,7,22],[13,7,22]", + events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + eventsLabels=False, + imageScale=21.04, + ) + print(response) diff --git a/hvpy/facade.py b/hvpy/facade.py index 1225a5e..202b244 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -13,6 +13,7 @@ "getStatus", "getClosestImage", "getDataSources", + "queueMovie", ] @@ -209,3 +210,74 @@ def getDataSources( callback=callback, ) return execute_api_call(input_parameters=params) + + +@add_shared_docstring(queueMovieInputParameters) +def queueMovie( + startTime: datetime, + endTime: datetime, + layers: str, + events: str, + eventsLabels: bool, + imageScale: float, + format: Optional[str] = "mp4", + frameRate: Optional[str] = "15", + maxFrames: Optional[str] = None, + scale: Optional[bool] = None, + scaleType: Optional[str] = None, + scaleX: Optional[float] = None, + scaleY: Optional[float] = None, + movieLength: Optional[float] = None, + watermark: Optional[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, + callback: Optional[str] = None, + size: Optional[int] = None, + movieIcons: Optional[int] = None, + followViewport: Optional[int] = None, + reqObservationDate: Optional[datetime] = None, +) -> Union[bytes, str, Dict[str, Any]]: + """ + Queue a movie for download from the helioviewer.org API. + + {Insert} + Examples + -------- + """ + params = queueMovieInputParameters( + startTime=startTime, + endTime=endTime, + layers=layers, + events=events, + eventsLabels=eventsLabels, + imageScale=imageScale, + format=format, + frameRate=frameRate, + maxFrames=maxFrames, + scale=scale, + scaleType=scaleType, + scaleX=scaleX, + scaleY=scaleY, + movieLength=movieLength, + watermark=watermark, + width=width, + height=height, + x0=x0, + y0=y0, + x1=x1, + y1=y1, + x2=x2, + y2=y2, + callback=callback, + size=size, + movieIcons=movieIcons, + followViewport=followViewport, + reqObservationDate=reqObservationDate, + ) + return execute_api_call(input_parameters=params) diff --git a/hvpy/parameters.py b/hvpy/parameters.py index e10de4f..7524970 100644 --- a/hvpy/parameters.py +++ b/hvpy/parameters.py @@ -3,6 +3,7 @@ from hvpy.api_groups.jpeg2000.get_jpx import getJPXInputParameters from hvpy.api_groups.jpeg2000.get_jpx_closest_to_mid_point import getJPXClosestToMidPointInputParameters from hvpy.api_groups.jpeg2000.get_status import getStatusInputParameters +from hvpy.api_groups.movies.queue_movie import queueMovieInputParameters from hvpy.api_groups.official_clients.get_closest_image import getClosestImageInputParameters from hvpy.api_groups.official_clients.get_data_sources import getDataSourcesInputParameters @@ -14,4 +15,5 @@ "getStatusInputParameters", "getClosestImageInputParameters", "getDataSourcesInputParameters", + "queueMovieInputParameters", ] From a3e3e4022067115ff8a64b93cc1b23a558cf28ee Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 21:27:27 +0530 Subject: [PATCH 07/19] tweaks to docs build --- hvpy/api_groups/movies/queue_movie.py | 2 +- hvpy/facade.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index c8fd51e..d31d9f7 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -11,9 +11,9 @@ class queueMovieInputParameters(HvpyParameters): """ Handles the input parameters of the queueMovie API. - {Shared} Attributes ---------- + {Shared} startTime : datetime Date and time of the first frame of the movie. endTime : datetime diff --git a/hvpy/facade.py b/hvpy/facade.py index 202b244..4943e71 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -246,6 +246,8 @@ def queueMovie( """ Queue a movie for download from the helioviewer.org API. + Parameters + ---------- {Insert} Examples -------- From 9958e17dd5ce9ba22a8c6e62446d7ee1062b2f43 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 21:35:36 +0530 Subject: [PATCH 08/19] fix for failing docs build --- hvpy/api_groups/movies/queue_movie.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index d31d9f7..d9fac0b 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -14,9 +14,9 @@ class queueMovieInputParameters(HvpyParameters): Attributes ---------- {Shared} - startTime : datetime + startTime : datetime.datetime Date and time of the first frame of the movie. - endTime : datetime + endTime : datetime.datetime Date and time of the final frame of the movie. layers : str Image datasource layers to include in the movie. @@ -68,7 +68,7 @@ class queueMovieInputParameters(HvpyParameters): Display other user generated movies on the video. followViewport : int, optional Rotate field of view of movie with Sun. - reqObservationDate : datetime, optional + reqObservationDate : datetime.datetime, optional Viewport time. Used when 'followViewport' enabled to shift viewport area to correct coordinates From c779f4af2fcca14cc5fa79d5d3ce0667cd562cbd Mon Sep 17 00:00:00 2001 From: akash5100 Date: Thu, 21 Jul 2022 20:26:28 +0530 Subject: [PATCH 09/19] test for queueMovie --- .../movies/tests/test_queue_movie.py | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py index de22683..318eaed 100644 --- a/hvpy/api_groups/movies/tests/test_queue_movie.py +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -1,15 +1,37 @@ from datetime import datetime +import pytest + from hvpy import queueMovie +from hvpy.api_groups.movies.queue_movie import queueMovieInputParameters def test_queue(): response = queueMovie( - startTime=datetime(2022, 7, 12, 12, 12, 12), - endTime=datetime(2022, 7, 13, 12, 12, 12), + startTime=datetime(2022, 7, 20, 12, 12, 12), + endTime=datetime(2022, 7, 21, 12, 12, 12), layers="[12,7,22],[13,7,22]", events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", eventsLabels=False, - imageScale=21.04, + imageScale=1, ) - print(response) + assert response["id"] is not None + assert response["eta"] is not None + assert response["queue"] is not None + assert response["token"] is not None + + +def test_error_handling(): + with pytest.raises(TypeError, match="missing 1 required positional argument: 'imageScale'"): + response = queueMovie( + startTime=datetime(2022, 7, 20, 12, 12, 12), + endTime=datetime(2022, 7, 21, 12, 12, 12), + layers="[12,7,22],[13,7,22]", + events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + eventsLabels=False, + ) + + +def test_url_property(): + params = queueMovieInputParameters(id=9838343) + assert params.url == "https://api.helioviewer.org/v2/queueMovie/" From 1dffc43ef742ae7f28649e7b886bc30a7ecf0fde Mon Sep 17 00:00:00 2001 From: akash5100 Date: Thu, 21 Jul 2022 20:51:03 +0530 Subject: [PATCH 10/19] Fix failing test --- hvpy/api_groups/movies/tests/test_queue_movie.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py index 318eaed..2e160fc 100644 --- a/hvpy/api_groups/movies/tests/test_queue_movie.py +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -23,7 +23,7 @@ def test_queue(): def test_error_handling(): with pytest.raises(TypeError, match="missing 1 required positional argument: 'imageScale'"): - response = queueMovie( + queueMovie( startTime=datetime(2022, 7, 20, 12, 12, 12), endTime=datetime(2022, 7, 21, 12, 12, 12), layers="[12,7,22],[13,7,22]", @@ -33,5 +33,12 @@ def test_error_handling(): def test_url_property(): - params = queueMovieInputParameters(id=9838343) + params = queueMovieInputParameters( + startTime=datetime(2022, 7, 20, 12, 12, 12), + endTime=datetime(2022, 7, 21, 12, 12, 12), + layers="[12,7,22],[13,7,22]", + events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + eventsLabels=False, + imageScale=1, + ) assert params.url == "https://api.helioviewer.org/v2/queueMovie/" From 79d2f62b48121ea061b2a2ff992061822e2fa2e3 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Tue, 12 Jul 2022 14:53:29 +0530 Subject: [PATCH 11/19] init files --- hvpy/api_groups/movies/__init__.py | 0 hvpy/api_groups/movies/tests/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 hvpy/api_groups/movies/__init__.py create mode 100644 hvpy/api_groups/movies/tests/__init__.py diff --git a/hvpy/api_groups/movies/__init__.py b/hvpy/api_groups/movies/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hvpy/api_groups/movies/tests/__init__.py b/hvpy/api_groups/movies/tests/__init__.py new file mode 100644 index 0000000..e69de29 From 09fa86c7318bb23f0bf5f7cd35896c9d38c8fe4c Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 20:50:38 +0530 Subject: [PATCH 12/19] Adds queueMovie endpoint --- hvpy/api_groups/movies/queue_movie.py | 117 ++++++++++++++++++ .../movies/tests/test_queue_movie.py | 15 +++ hvpy/facade.py | 73 +++++++++++ hvpy/parameters.py | 2 + 4 files changed, 207 insertions(+) create mode 100644 hvpy/api_groups/movies/queue_movie.py create mode 100644 hvpy/api_groups/movies/tests/test_queue_movie.py diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py new file mode 100644 index 0000000..c8fd51e --- /dev/null +++ b/hvpy/api_groups/movies/queue_movie.py @@ -0,0 +1,117 @@ +from typing import Optional +from datetime import datetime + +from pydantic import validator + +from hvpy.io import HvpyParameters, OutputType +from hvpy.utils import convert_date_to_isoformat + + +class queueMovieInputParameters(HvpyParameters): + """ + Handles the input parameters of the queueMovie API. + + {Shared} + Attributes + ---------- + startTime : datetime + Date and time of the first frame of the movie. + endTime : datetime + Date and time of the final frame of the movie. + layers : str + Image datasource layers to include in the movie. + events : str + List of feature/event types and FRMs to use to annotate the movie. + eventsLabels : bool + Annotate each event marker with a text label. + imageScale : float + Image scale in arcseconds per pixel. + format : str, optional + Movie format (mp4, webm, flv). Default value is mp4. + frameRate : str, optional + Movie frames per second. 15 frames per second by default. + maxFrames : str, optional + Maximum number of frames in the movie. May be capped by the server. + scale : bool, optional + Optionally overlay an image scale indicator. + scaleType : str, optional + Image scale indicator + scaleX : float, optional + Horizontal offset of the image scale indicator in arcseconds with respect to the center of the Sun. + scaleY : float, optional + Vertical offset of the image scale indicator in arcseconds with respect to the center of the Sun. + movieLength : float, optional + movie length in seconds. + watermark : bool, optional + Optionally overlay a Helioviewer.org watermark image. Enabled by default + width : str, optional + Width of the field of view in pixels. (Used in conjunction width x0,`y0`, and height). + height : str, optional + Height of the field of view in pixels. (Used in conjunction width x0,`y0`, and width). + x0 : str, optional + The horizontal offset of the center of the field of view from the center of the Sun. Used in conjunction with y0, width, and height. + y0 : str, optional + The vertical offset of the center of the field of view from the center of the Sun. Used in conjunction with x0, width, and height. + x1 : str, optional + The horizontal offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with y1, x2, and y2. + y1 : str, optional + The vertical offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, x2, and y2. + x2 : str, optional + The horizontal offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and y2. + y2 : str, optional + The vertical offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and x2. + callback : str, optional + Wrap the response object in a function call of your choosing. + size : int, optional + Scale video to preset size. Default value is 0. + movieIcons : int, optional + Display other user generated movies on the video. + followViewport : int, optional + Rotate field of view of movie with Sun. + reqObservationDate : datetime, optional + Viewport time. Used when 'followViewport' enabled to shift viewport area to correct coordinates + + + References + ---------- + * ``__ + {Shared} + """ + + startTime: datetime + endTime: datetime + layers: str + events: str + eventsLabels: bool + imageScale: float + format: Optional[str] = "mp4" + frameRate: Optional[str] = "15" + maxFrames: Optional[str] = None + scale: Optional[bool] = None + scaleType: Optional[str] = None + scaleX: Optional[float] = None + scaleY: Optional[float] = None + movieLength: Optional[float] = None + watermark: Optional[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 + callback: Optional[str] = None + size: Optional[int] = None + movieIcons: Optional[int] = None + followViewport: Optional[int] = None + reqObservationDate: Optional[datetime] = None + _date_validator = validator("startTime", "endTime", "reqObservationalDate", allow_reuse=True, check_fields=False)( + convert_date_to_isoformat + ) + + def get_output_type(self) -> OutputType: + """ + Returns the output type of the API call. + """ + return OutputType.JSON diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py new file mode 100644 index 0000000..de22683 --- /dev/null +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -0,0 +1,15 @@ +from datetime import datetime + +from hvpy import queueMovie + + +def test_queue(): + response = queueMovie( + startTime=datetime(2022, 7, 12, 12, 12, 12), + endTime=datetime(2022, 7, 13, 12, 12, 12), + layers="[12,7,22],[13,7,22]", + events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + eventsLabels=False, + imageScale=21.04, + ) + print(response) diff --git a/hvpy/facade.py b/hvpy/facade.py index 4b26ea9..3317be2 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -15,6 +15,7 @@ "getDataSources", "takeScreenshot", "downloadScreenshot", + "queueMovie", ] @@ -298,3 +299,75 @@ def downloadScreenshot(id: int) -> Union[bytes, str, Dict[str, Any]]: """ params = downloadScreenshotInputParameters(id=id) return execute_api_call(input_parameters=params) + +@add_shared_docstring(queueMovieInputParameters) +def queueMovie( + startTime: datetime, + endTime: datetime, + layers: str, + events: str, + eventsLabels: bool, + imageScale: float, + format: Optional[str] = "mp4", + frameRate: Optional[str] = "15", + maxFrames: Optional[str] = None, + scale: Optional[bool] = None, + scaleType: Optional[str] = None, + scaleX: Optional[float] = None, + scaleY: Optional[float] = None, + movieLength: Optional[float] = None, + watermark: Optional[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, + callback: Optional[str] = None, + size: Optional[int] = None, + movieIcons: Optional[int] = None, + followViewport: Optional[int] = None, + reqObservationDate: Optional[datetime] = None, +) -> Union[bytes, str, Dict[str, Any]]: + """ + Queue a movie for download from the helioviewer.org API. + + Parameters + ---------- + {Insert} + Examples + -------- + """ + params = queueMovieInputParameters( + startTime=startTime, + endTime=endTime, + layers=layers, + events=events, + eventsLabels=eventsLabels, + imageScale=imageScale, + format=format, + frameRate=frameRate, + maxFrames=maxFrames, + scale=scale, + scaleType=scaleType, + scaleX=scaleX, + scaleY=scaleY, + movieLength=movieLength, + watermark=watermark, + width=width, + height=height, + x0=x0, + y0=y0, + x1=x1, + y1=y1, + x2=x2, + y2=y2, + callback=callback, + size=size, + movieIcons=movieIcons, + followViewport=followViewport, + reqObservationDate=reqObservationDate, + ) + return execute_api_call(input_parameters=params) diff --git a/hvpy/parameters.py b/hvpy/parameters.py index 2b6bfd1..8dda465 100644 --- a/hvpy/parameters.py +++ b/hvpy/parameters.py @@ -3,6 +3,7 @@ from hvpy.api_groups.jpeg2000.get_jpx import getJPXInputParameters from hvpy.api_groups.jpeg2000.get_jpx_closest_to_mid_point import getJPXClosestToMidPointInputParameters from hvpy.api_groups.jpeg2000.get_status import getStatusInputParameters +from hvpy.api_groups.movies.queue_movie import queueMovieInputParameters from hvpy.api_groups.official_clients.get_closest_image import getClosestImageInputParameters from hvpy.api_groups.official_clients.get_data_sources import getDataSourcesInputParameters from hvpy.api_groups.screenshots.download_screenshot import downloadScreenshotInputParameters @@ -18,4 +19,5 @@ "getDataSourcesInputParameters", "takeScreenshotInputParameters", "downloadScreenshotInputParameters", + "queueMovieInputParameters", ] From d69bd7767ce5ee1590b8755b156b08e69411dbf4 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 21:27:27 +0530 Subject: [PATCH 13/19] tweaks to docs build --- hvpy/api_groups/movies/queue_movie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index c8fd51e..d31d9f7 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -11,9 +11,9 @@ class queueMovieInputParameters(HvpyParameters): """ Handles the input parameters of the queueMovie API. - {Shared} Attributes ---------- + {Shared} startTime : datetime Date and time of the first frame of the movie. endTime : datetime From b25e1ccb3e9c29496de694c29fcce6cd5e1f8b0b Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 13 Jul 2022 21:35:36 +0530 Subject: [PATCH 14/19] fix for failing docs build --- hvpy/api_groups/movies/queue_movie.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index d31d9f7..d9fac0b 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -14,9 +14,9 @@ class queueMovieInputParameters(HvpyParameters): Attributes ---------- {Shared} - startTime : datetime + startTime : datetime.datetime Date and time of the first frame of the movie. - endTime : datetime + endTime : datetime.datetime Date and time of the final frame of the movie. layers : str Image datasource layers to include in the movie. @@ -68,7 +68,7 @@ class queueMovieInputParameters(HvpyParameters): Display other user generated movies on the video. followViewport : int, optional Rotate field of view of movie with Sun. - reqObservationDate : datetime, optional + reqObservationDate : datetime.datetime, optional Viewport time. Used when 'followViewport' enabled to shift viewport area to correct coordinates From 9a2ba5ec7977aa45732c4acfbcd4564972edc872 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Thu, 21 Jul 2022 20:26:28 +0530 Subject: [PATCH 15/19] test for queueMovie --- .../movies/tests/test_queue_movie.py | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py index de22683..318eaed 100644 --- a/hvpy/api_groups/movies/tests/test_queue_movie.py +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -1,15 +1,37 @@ from datetime import datetime +import pytest + from hvpy import queueMovie +from hvpy.api_groups.movies.queue_movie import queueMovieInputParameters def test_queue(): response = queueMovie( - startTime=datetime(2022, 7, 12, 12, 12, 12), - endTime=datetime(2022, 7, 13, 12, 12, 12), + startTime=datetime(2022, 7, 20, 12, 12, 12), + endTime=datetime(2022, 7, 21, 12, 12, 12), layers="[12,7,22],[13,7,22]", events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", eventsLabels=False, - imageScale=21.04, + imageScale=1, ) - print(response) + assert response["id"] is not None + assert response["eta"] is not None + assert response["queue"] is not None + assert response["token"] is not None + + +def test_error_handling(): + with pytest.raises(TypeError, match="missing 1 required positional argument: 'imageScale'"): + response = queueMovie( + startTime=datetime(2022, 7, 20, 12, 12, 12), + endTime=datetime(2022, 7, 21, 12, 12, 12), + layers="[12,7,22],[13,7,22]", + events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + eventsLabels=False, + ) + + +def test_url_property(): + params = queueMovieInputParameters(id=9838343) + assert params.url == "https://api.helioviewer.org/v2/queueMovie/" From 7819002b0c954314e35d576eb841904963d16804 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Thu, 21 Jul 2022 20:51:03 +0530 Subject: [PATCH 16/19] Fix failing test --- hvpy/api_groups/movies/tests/test_queue_movie.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py index 318eaed..2e160fc 100644 --- a/hvpy/api_groups/movies/tests/test_queue_movie.py +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -23,7 +23,7 @@ def test_queue(): def test_error_handling(): with pytest.raises(TypeError, match="missing 1 required positional argument: 'imageScale'"): - response = queueMovie( + queueMovie( startTime=datetime(2022, 7, 20, 12, 12, 12), endTime=datetime(2022, 7, 21, 12, 12, 12), layers="[12,7,22],[13,7,22]", @@ -33,5 +33,12 @@ def test_error_handling(): def test_url_property(): - params = queueMovieInputParameters(id=9838343) + params = queueMovieInputParameters( + startTime=datetime(2022, 7, 20, 12, 12, 12), + endTime=datetime(2022, 7, 21, 12, 12, 12), + layers="[12,7,22],[13,7,22]", + events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + eventsLabels=False, + imageScale=1, + ) assert params.url == "https://api.helioviewer.org/v2/queueMovie/" From 91d6862e2600b7bfb688d87c83e94771faa9e271 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Tue, 2 Aug 2022 14:42:04 +0530 Subject: [PATCH 17/19] Update docstring and utils for None datetime object --- hvpy/api_groups/movies/queue_movie.py | 128 ++++++++++++++++---------- hvpy/utils.py | 4 +- 2 files changed, 80 insertions(+), 52 deletions(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index d9fac0b..1fd0407 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -9,68 +9,94 @@ class queueMovieInputParameters(HvpyParameters): """ - Handles the input parameters of the queueMovie API. + Handles the input parameters of the ``queueMovie`` API. Attributes ---------- {Shared} - startTime : datetime.datetime - Date and time of the first frame of the movie. - endTime : datetime.datetime - Date and time of the final frame of the movie. - layers : str + startTime + Datetime of the first frame of the movie. + endTime + Datetime of the final frame of the movie. + layers Image datasource layers to include in the movie. - events : str + events List of feature/event types and FRMs to use to annotate the movie. - eventsLabels : bool - Annotate each event marker with a text label. - imageScale : float + eventsLabels + Boolean to indicate if the event labels should be included in the movie. + imageScale Image scale in arcseconds per pixel. - format : str, optional - Movie format (mp4, webm, flv). Default value is mp4. - frameRate : str, optional - Movie frames per second. 15 frames per second by default. - maxFrames : str, optional - Maximum number of frames in the movie. May be capped by the server. - scale : bool, optional - Optionally overlay an image scale indicator. - scaleType : str, optional - Image scale indicator - scaleX : float, optional + format + Movie format (mp4, webm, flv). + Default value is `mp4`, optional. + frameRate + Movie frames per second. + Default value is `15` frames per second, optional. + maxFrames + Maximum number of frames in the movie, can be capped by the server. + Default value is `None`, optional. + scale + Overlay an image scale indicator. + Default value is `None`, optional. + scaleType + Set the image scale indicator. + Default value is `None`, optional. + scaleX Horizontal offset of the image scale indicator in arcseconds with respect to the center of the Sun. - scaleY : float, optional + Default value is `None`, optional. + scaleY Vertical offset of the image scale indicator in arcseconds with respect to the center of the Sun. - movieLength : float, optional + Default value is `None`, optional. + movieLength movie length in seconds. - watermark : bool, optional - Optionally overlay a Helioviewer.org watermark image. Enabled by default - width : str, optional - Width of the field of view in pixels. (Used in conjunction width x0,`y0`, and height). - height : str, optional - Height of the field of view in pixels. (Used in conjunction width x0,`y0`, and width). - x0 : str, optional - The horizontal offset of the center of the field of view from the center of the Sun. Used in conjunction with y0, width, and height. - y0 : str, optional - The vertical offset of the center of the field of view from the center of the Sun. Used in conjunction with x0, width, and height. - x1 : str, optional - The horizontal offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with y1, x2, and y2. - y1 : str, optional - The vertical offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, x2, and y2. - x2 : str, optional - The horizontal offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and y2. - y2 : str, optional - The vertical offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). Used in conjunction with x1, y1, and x2. - callback : str, optional + Default value is `None`, optional. + watermark + Optionally overlay a Helioviewer.org watermark image. + Default value is `True`, optional. + width + Width of the field of view in pixels. (Used in conjunction width `x0`,`y0`, and height). + Default value is `None`, optional. + height + Height of the field of view in pixels. (Used in conjunction width `x0`,`y0`, and width). + Default value is `None`, optional. + x0 + The horizontal offset of the center of the field of view from the center of the Sun. Used in conjunction with `y0`, width, and height. + Default value is `None`, optional. + y0 + The vertical offset of the center of the field of view from the center of the Sun. Used in conjunction with `x0`, width, and height. + Default value is `None`, optional. + x1 + The horizontal offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). + Used in conjunction with `y1`, `x2`, and `y2`. + Default value is `None`, optional. + y1 + The vertical offset of the top-left corner of the field of view with respect to the center of the Sun (in arcseconds). + Used in conjunction with `x1`, `x2`, and `y2`. + Default value is `None`, optional. + x2 + The horizontal offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). + Used in conjunction with `x1`, `y1`, and `y2`. + Default value is `None`, optional. + y2 + The vertical offset of the bottom-right corner of the field of view with respect to the center of the Sun (in arcseconds). + Used in conjunction with `x1`, `y1`, and `x2`. + Default value is `None`, optional. + callback Wrap the response object in a function call of your choosing. - size : int, optional - Scale video to preset size. Default value is 0. - movieIcons : int, optional + Default value is `None`, optional. + size + Scale video to preset size. + Default value is `0`, optional. + movieIcons Display other user generated movies on the video. - followViewport : int, optional + Default value is `None`, optional. + followViewport Rotate field of view of movie with Sun. - reqObservationDate : datetime.datetime, optional - Viewport time. Used when 'followViewport' enabled to shift viewport area to correct coordinates - + Default value is `None`, optional. + reqObservationDate + Viewport datetime. + Used when 'followViewport' enabled to shift viewport area to correct coordinates + Default value is `None`, optional. References ---------- @@ -102,11 +128,11 @@ class queueMovieInputParameters(HvpyParameters): x2: Optional[str] = None y2: Optional[str] = None callback: Optional[str] = None - size: Optional[int] = None + size: Optional[int] = 0 movieIcons: Optional[int] = None followViewport: Optional[int] = None reqObservationDate: Optional[datetime] = None - _date_validator = validator("startTime", "endTime", "reqObservationalDate", allow_reuse=True, check_fields=False)( + _date_validator = validator("startTime", "endTime", "reqObservationDate", allow_reuse=True)( convert_date_to_isoformat ) diff --git a/hvpy/utils.py b/hvpy/utils.py index c6e9d27..3a83d49 100644 --- a/hvpy/utils.py +++ b/hvpy/utils.py @@ -19,7 +19,9 @@ def convert_date_to_isoformat(v: datetime) -> str: """ Converts the date from a datetime object to a string in the ISO format. """ - return v.isoformat() + "Z" + if v: + return v.isoformat() + "Z" + return "" def convert_date_to_unix(v: list) -> str: From d417b627724acb27bb7a2045f566a1f6e8a29cbb Mon Sep 17 00:00:00 2001 From: akash5100 Date: Tue, 2 Aug 2022 15:33:14 +0530 Subject: [PATCH 18/19] Add example in docstr --- hvpy/api_groups/movies/tests/test_queue_movie.py | 2 +- hvpy/facade.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hvpy/api_groups/movies/tests/test_queue_movie.py b/hvpy/api_groups/movies/tests/test_queue_movie.py index 2e160fc..44a04e3 100644 --- a/hvpy/api_groups/movies/tests/test_queue_movie.py +++ b/hvpy/api_groups/movies/tests/test_queue_movie.py @@ -6,7 +6,7 @@ from hvpy.api_groups.movies.queue_movie import queueMovieInputParameters -def test_queue(): +def test_json_response(): response = queueMovie( startTime=datetime(2022, 7, 20, 12, 12, 12), endTime=datetime(2022, 7, 21, 12, 12, 12), diff --git a/hvpy/facade.py b/hvpy/facade.py index c8e1731..cc6d395 100644 --- a/hvpy/facade.py +++ b/hvpy/facade.py @@ -340,6 +340,16 @@ def queueMovie( {Insert} Examples -------- + >>> from hvpy import queueMovie + >>> queueMovie( + ... startTime=datetime(2022, 7, 21, 12, 12, 12), + ... endTime=datetime(2022, 7, 22, 12, 12, 12), + ... layers="[12,7,22],[13,7,11]", + ... events="[AR,HMI_HARP;SPoCA,1],[CH,all,1]", + ... eventsLabels=False, + ... imageScale=2.44, + ... ) + {'id': ...} """ params = queueMovieInputParameters( startTime=startTime, From beb4ac70e157b7813f428f436e339f9698d5d1f4 Mon Sep 17 00:00:00 2001 From: akash5100 Date: Wed, 3 Aug 2022 20:32:44 +0530 Subject: [PATCH 19/19] remove quotes for values in docstring --- hvpy/api_groups/movies/queue_movie.py | 6 +++--- hvpy/utils.py | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hvpy/api_groups/movies/queue_movie.py b/hvpy/api_groups/movies/queue_movie.py index 1fd0407..c74f08d 100644 --- a/hvpy/api_groups/movies/queue_movie.py +++ b/hvpy/api_groups/movies/queue_movie.py @@ -28,10 +28,10 @@ class queueMovieInputParameters(HvpyParameters): Image scale in arcseconds per pixel. format Movie format (mp4, webm, flv). - Default value is `mp4`, optional. + Default value is "mp4", optional. frameRate Movie frames per second. - Default value is `15` frames per second, optional. + Default value is 15 frames per second, optional. maxFrames Maximum number of frames in the movie, can be capped by the server. Default value is `None`, optional. @@ -86,7 +86,7 @@ class queueMovieInputParameters(HvpyParameters): Default value is `None`, optional. size Scale video to preset size. - Default value is `0`, optional. + Default value is 0, optional. movieIcons Display other user generated movies on the video. Default value is `None`, optional. diff --git a/hvpy/utils.py b/hvpy/utils.py index 48f9c56..9c53667 100644 --- a/hvpy/utils.py +++ b/hvpy/utils.py @@ -1,4 +1,4 @@ -from typing import Any, Union, Callable +from typing import Any, Callable from datetime import datetime __all__ = ["add_shared_docstring", "convert_date_to_isoformat", "convert_date_to_unix"] @@ -15,13 +15,12 @@ def decorator(func): return decorator -def convert_date_to_isoformat(v: datetime) -> Union[str, None]: +def convert_date_to_isoformat(v: datetime) -> str: """ Converts the date from a datetime object to a string in the ISO format. """ - if v: + if v is not None: return v.isoformat() + "Z" - return None def convert_date_to_unix(v: list) -> str: