Skip to content

Commit

Permalink
Fixup API parameter types
Browse files Browse the repository at this point in the history
Co-Authored-By: Jessica Scheick <[email protected]>
  • Loading branch information
mfisher87 and JessicaS11 committed Sep 5, 2024
1 parent 0440fa9 commit df78ca2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions icepyx/core/granules.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import icepyx.core.APIformatting as apifmt
from icepyx.core.auth import EarthdataAuthMixin
import icepyx.core.exceptions
from icepyx.core.types import CMRParams, EGISpecificParams
from icepyx.core.types import CMRParams, EGISpecificRequiredParams
from icepyx.core.urls import DOWNLOAD_BASE_URL, GRANULE_SEARCH_BASE_URL, ORDER_BASE_URL


Expand Down Expand Up @@ -177,7 +177,7 @@ def __init__(
def get_avail(
self,
CMRparams: CMRParams | None,
reqparams: EGISpecificParams | None,
reqparams: EGISpecificRequiredParams | None,
cloud=False,
):
"""
Expand Down Expand Up @@ -271,7 +271,7 @@ def get_avail(
def place_order(
self,
CMRparams: CMRParams,
reqparams: EGISpecificParams,
reqparams: EGISpecificRequiredParams,
subsetparams,
verbose,
subset=True,
Expand Down
6 changes: 3 additions & 3 deletions icepyx/core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import icepyx.core.is2ref as is2ref
import icepyx.core.spatial as spat
import icepyx.core.temporal as tp
from icepyx.core.types import CMRParams, EGISpecificParams, EGISpecificParamsSubset
from icepyx.core.types import CMRParams, EGIParamsSubset, EGISpecificRequiredParams
import icepyx.core.validate_inputs as val
from icepyx.core.variables import Variables as Variables
from icepyx.core.visualization import Visualize
Expand Down Expand Up @@ -579,7 +579,7 @@ def CMRparams(self) -> CMRParams:
return self._CMRparams.fmted_keys

@property
def reqparams(self) -> EGISpecificParams:
def reqparams(self) -> EGISpecificRequiredParams:
"""
Display the required key:value pairs that will be submitted.
It generates the dictionary if it does not already exist.
Expand All @@ -605,7 +605,7 @@ def reqparams(self) -> EGISpecificParams:
# @property
# DevQuestion: if I make this a property, I get a "dict" object is not callable
# when I try to give input kwargs... what approach should I be taking?
def subsetparams(self, **kwargs) -> EGISpecificParamsSubset | dict[Never, Never]:
def subsetparams(self, **kwargs) -> EGIParamsSubset | dict[Never, Never]:
"""
Display the subsetting key:value pairs that will be submitted.
It generates the dictionary if it does not already exist
Expand Down
30 changes: 19 additions & 11 deletions icepyx/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ class EGISpecificParamsBase(TypedDict):


class EGISpecificParamsSearch(EGISpecificParamsBase):
"""Parameters for searching through EGI."""


class EGISpecificParamsOrder(EGISpecificParamsBase):
"""Parameters for ordering through EGI."""

# TODO: Does this type need page_* attributes?
"""Parameters for interacting with EGI."""


class EGISpecificParamsDownload(EGISpecificParamsBase):
Expand All @@ -94,10 +88,24 @@ class EGISpecificParamsDownload(EGISpecificParamsBase):
# token, email


class EGISpecificParamsSubset(EGISpecificParamsBase):
class EGIParamsSubsetBase(TypedDict):
"""Parameters for subsetting with EGI."""

time: NotRequired[str]
format: NotRequired[str]
projection: NotRequired[str]
projection_parameters: NotRequired[str]
Coverage: NotRequired[str]

EGISpecificParams = (
EGISpecificParamsSearch | EGISpecificParamsDownload | EGISpecificParamsSubset
)

class EGIParamsSubsetBbox(EGIParamsSubsetBase):
bbox: str


class EGIParamsSubsetBoundingShape(EGIParamsSubsetBase):
Boundingshape: str


EGIParamsSubset = EGIParamsSubsetBbox | EGIParamsSubsetBoundingShape

EGISpecificRequiredParams = EGISpecificParamsSearch | EGISpecificParamsDownload

0 comments on commit df78ca2

Please sign in to comment.