Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add harmony-py as a dependency #627

Draft
wants to merge 13 commits into
base: harmony
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions icepyx/core/APIformatting.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""Generate and format information for submitting to API (CMR and NSIDC)."""

import datetime as dt
from typing import Any, Generic, Literal, Optional, TypeVar, Union, overload
from typing import Any, Generic, Literal, Optional, TypeVar, overload

from icepyx.core.exceptions import ExhaustiveTypeGuardException, TypeGuardException
from icepyx.core.types import (
from icepyx.core.harmony import HarmonyTemporal
from icepyx.core.types.api import (
CMRParams,
EGIParamsSubset,
EGIRequiredParams,
)

# ----------------------------------------------------------------------
Expand Down Expand Up @@ -38,18 +37,17 @@
assert isinstance(start, dt.datetime)
assert isinstance(end, dt.datetime)

if key == "temporal":
if key == "temporal": # search option.
fmt_timerange = (

Check failure on line 41 in icepyx/core/APIformatting.py

View workflow job for this annotation

GitHub Actions / test

Type "str" is not assignable to declared type "HarmonyTemporal"   "str" is not assignable to "HarmonyTemporal" (reportAssignmentType)
start.strftime("%Y-%m-%dT%H:%M:%SZ")
+ ","
+ end.strftime("%Y-%m-%dT%H:%M:%SZ")
)
elif key == "time":
fmt_timerange = (
start.strftime("%Y-%m-%dT%H:%M:%S")
+ ","
+ end.strftime("%Y-%m-%dT%H:%M:%S")
)
elif key == "time": # subsetting option.
# Format for harmony. This will do subsetting.
# TODO: change `key` to something more clear. `temporal` is the key
# passed into Harmony, so this is very confusing!
fmt_timerange: HarmonyTemporal = {"start": start, "stop": end}
else:
raise ValueError("An invalid time key was submitted for formatting.")

Expand Down Expand Up @@ -212,20 +210,22 @@
self,
instance: 'Parameters[Literal["required"]]',
owner: Any,
) -> EGIRequiredParams: ...
): # -> EGIRequiredParams: ...
...

@overload
def __get__(
self,
instance: 'Parameters[Literal["subset"]]',
owner: Any,
) -> EGIParamsSubset: ...
): # -> EGIParamsSubset: ...
...

def __get__(
self,
instance: "Parameters",
owner: Any,
) -> Union[CMRParams, EGIRequiredParams, EGIParamsSubset]:
) -> CMRParams:
"""
Returns the dictionary of formatted keys associated with the
parameter object.
Expand Down Expand Up @@ -265,6 +265,9 @@
self,
partype: T,
values: Optional[dict] = None,
# TODO: 'download" reqtype appears to never get used. `None` is most
# common, and `search` is passed in when creating required cmr
# parameters to search for matching granules.
reqtype: Optional[Literal["search", "download"]] = None,
):
assert partype in [
Expand Down
Loading
Loading