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

Convert deprecation warnings to errors #482

Merged
merged 25 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5031927
read deprecation warnings to errors and comment out product arg code
JessicaS11 Dec 20, 2023
1cac5f6
comment filename_pattern arg code
JessicaS11 Dec 20, 2023
d2fffbc
query dataset deprecation to error
JessicaS11 Dec 20, 2023
d04ea3d
icesat2data deprecation error
JessicaS11 Dec 20, 2023
585a815
Merge branch 'development' into deprecations
JessicaS11 Dec 22, 2023
f450398
remove deprecated code and convert warning to error in auth
JessicaS11 Dec 22, 2023
5bfd3b9
update test warning to error
JessicaS11 Dec 22, 2023
1d5d465
remove test for deprecated args
JessicaS11 Dec 22, 2023
ce0e714
raise deprecation error for earthdata_login()
JessicaS11 Jan 2, 2024
1fada73
update authentication admonition in notebooks
JessicaS11 Jan 2, 2024
6305372
remove kwarg from error
JessicaS11 Jan 3, 2024
51dd5b1
Merge branch 'development' into deprecations
JessicaS11 Jan 4, 2024
85ba7ec
update admonitions in notebooks
JessicaS11 Jan 4, 2024
b756057
remove _check_source_from_pattern function
JessicaS11 Jan 4, 2024
192f107
update admonitions
JessicaS11 Jan 4, 2024
06284c0
remove earthdata_login test
JessicaS11 Jan 4, 2024
05d241a
Merge branch 'development' into deprecations
JessicaS11 Jan 4, 2024
ed3abf3
Merge branch 'development' into deprecations
JessicaS11 Jan 4, 2024
cda3f87
note full deprecation in docstring of filename_pattern and product
rwegener2 Jan 5, 2024
d000e4e
move deprecated arguments to the bottom of the doc string and argumen…
rwegener2 Jan 5, 2024
706ffe6
consolodate deprecated arguments
rwegener2 Jan 5, 2024
94ab0ce
remove unused import warnings
rwegener2 Jan 5, 2024
c3eb899
removed unneeded check
JessicaS11 Jan 5, 2024
49357be
black formatting
JessicaS11 Jan 5, 2024
67d1786
GitHub action UML generation auto-update
rwegener2 Jan 5, 2024
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
4 changes: 1 addition & 3 deletions doc/source/example_notebooks/IS2_DEM_comparison_WIP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@
},
"source": [
"```{admonition} Important Authentication Update\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is no longer required, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed in the [ICESat-2 Data Access Notebook](https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html) example. The `.earthdata_login()` function is still available for backwards compatibility.\n",
"\n",
"If you are unable to remove `earthdata_login()` calls from your workflow, note that certain inputs, such as `earthdata_uid` and `email`, are no longer required. e.g. `region_a.earthdata_login(earthdata_uid, email)` becomes `region_a.earthdata_login()`\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is deprecated and will result in an error, as icepyx will call the login function as needed. The user will still need to provide their credentials.\n",
"```"
]
},
Expand Down
6 changes: 2 additions & 4 deletions doc/source/example_notebooks/IS2_cloud_data_access.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@
},
"source": [
"```{admonition} Important Authentication Update\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is no longer required, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed in the [ICESat-2 Data Access Notebook](https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html) example. The `.earthdata_login()` function is still available for backwards compatibility.\n",
"\n",
"If you are unable to remove `earthdata_login()` calls from your workflow, note that certain inputs, such as `earthdata_uid` and `email`, are no longer required. e.g. `region_a.earthdata_login(earthdata_uid, email)` becomes `region_a.earthdata_login()`\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is deprecated and will result in an error, as icepyx will call the login function as needed. The user will still need to provide their credentials.\n",
"```"
]
},
Expand Down Expand Up @@ -386,7 +384,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
10 changes: 4 additions & 6 deletions doc/source/example_notebooks/IS2_data_access.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,7 @@
},
"source": [
"```{admonition} Important Authentication Update\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is no longer required, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed above. The `.earthdata_login()` function is still available for backwards compatibility.\n",
"\n",
"If you are unable to remove `earthdata_login()` calls from your workflow, note that certain inputs, such as `earthdata_uid` and `email`, are no longer required. e.g. `region_a.earthdata_login(earthdata_uid, email)` becomes `region_a.earthdata_login()`\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is deprecated and will result in an error, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed above.\n",
"```"
]
},
Expand Down Expand Up @@ -626,9 +624,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "icepyx-dev",
"display_name": "icepyx",
"language": "python",
"name": "icepyx-dev"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -640,7 +638,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@
},
"source": [
"```{admonition} Important Authentication Update\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is no longer required, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed in the [ICESat-2 Data Access Notebook](https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html) example. The `.earthdata_login()` function is still available for backwards compatibility.\n",
"\n",
"If you are unable to remove `earthdata_login()` calls from your workflow, note that certain inputs, such as `earthdata_uid` and `email`, are no longer required. e.g. `region_a.earthdata_login(earthdata_uid, email)` becomes `region_a.earthdata_login()`\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is deprecated and will result in an error, as icepyx will call the login function as needed. The user will still need to provide their credentials.\n",
"```"
]
},
Expand Down
6 changes: 2 additions & 4 deletions doc/source/example_notebooks/IS2_data_read-in.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@
},
"source": [
"```{admonition} Important Authentication Update\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is no longer required, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed in the [ICESat-2 Data Access Notebook](https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html) example. The `.earthdata_login()` function is still available for backwards compatibility.\n",
"\n",
"If you are unable to remove `earthdata_login()` calls from your workflow, note that certain inputs, such as `earthdata_uid` and `email`, are no longer required. e.g. `region_a.earthdata_login(earthdata_uid, email)` becomes `region_a.earthdata_login()`\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is deprecated and will result in an error, as icepyx will call the login function as needed. The user will still need to provide their credentials.\n",
"```"
]
},
Expand Down Expand Up @@ -330,7 +328,7 @@
"```{admonition} Read Module Update\n",
"Previously, icepyx required two additional conditions: 1) a `product` argument and 2) that your files either matched the default `filename_pattern` or that the user provided their own `filename_pattern`. These two requirements have been removed. `product` is now read directly from the file metadata (the root group's `short_name` attribute). Flexibility to specify multiple files via the `filename_pattern` has been replaced with the [glob string](https://docs.python.org/3/library/glob.html) feature, and by allowing a list of filepaths as an argument.\n",
"\n",
"The `product` and `filename_pattern` arguments have been maintained for backwards compatibility, but will be fully removed in icepyx version 1.0.0.\n",
"The `product` and `filename_pattern` arguments are now deprecated and were removed in icepyx version 1.0.0.\n",
"```"
]
},
Expand Down
4 changes: 1 addition & 3 deletions doc/source/example_notebooks/IS2_data_variables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,7 @@
},
"source": [
"```{admonition} Important Authentication Update\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is no longer required, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed in the [ICESat-2 Data Access Notebook](https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html) example. The `.earthdata_login()` function is still available for backwards compatibility.\n",
"\n",
"If you are unable to remove `earthdata_login()` calls from your workflow, note that certain inputs, such as `earthdata_uid` and `email`, are no longer required. e.g. `region_a.earthdata_login(earthdata_uid, email)` becomes `region_a.earthdata_login()`\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is deprecated and will result in an error, as icepyx will call the login function as needed. The user will still need to provide their credentials.\n",
"```"
]
},
Expand Down
4 changes: 1 addition & 3 deletions doc/source/example_notebooks/IS2_data_visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@
},
"source": [
"```{admonition} Important Authentication Update\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is no longer required, as icepyx will call the login function as needed. The user will still need to provide their credentials using one of the three methods decribed in the [ICESat-2 Data Access Notebook](https://icepyx.readthedocs.io/en/latest/example_notebooks/IS2_data_access.html) example. The `.earthdata_login()` function is still available for backwards compatibility.\n",
"\n",
"If you are unable to remove `earthdata_login()` calls from your workflow, note that certain inputs, such as `earthdata_uid` and `email`, are no longer required. e.g. `region_a.earthdata_login(earthdata_uid, email)` becomes `region_a.earthdata_login()`\n",
"Previously, icepyx required you to explicitly use the `.earthdata_login()` function to login. Running this function is deprecated and will result in an error, as icepyx will call the login function as needed. The user will still need to provide their credentials.\n",
"```"
]
},
Expand Down
42 changes: 21 additions & 21 deletions icepyx/core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import warnings

import earthaccess
from icepyx.core.exceptions import DeprecationError


class AuthenticationError(Exception):
Expand All @@ -15,20 +16,23 @@ class AuthenticationError(Exception):

class EarthdataAuthMixin:
"""
This mixin class generates the needed authentication sessions and tokens, including for NASA Earthdata cloud access.
This mixin class generates the needed authentication sessions and tokens,
including for NASA Earthdata cloud access.
Authentication is completed using the [earthaccess library](https://nsidc.github.io/earthaccess/).
Methods for authenticating are:
1. Storing credentials as environment variables ($EARTHDATA_LOGIN and $EARTHDATA_PASSWORD)
2. Entering credentials interactively
3. Storing credentials in a .netrc file (not recommended for security reasons)
More details on using these methods is available in the [earthaccess documentation](https://nsidc.github.io/earthaccess/tutorials/restricted-datasets/#auth).

This class can be inherited by any other class that requires authentication. For
example, the `Query` class inherits this one, and so a Query object has the
`.session` property. The method `earthdata_login()` is included for backwards compatibility.
This class can be inherited by any other class that requires authentication.
For example, the `Query` class inherits this one, and so a Query object has the
`.session` property.
The method `earthdata_login()` is included for backwards compatibility.

The class can be created without any initialization parameters, and the properties will
be populated when they are called. It can alternately be initialized with an
be populated when they are called.
It can alternately be initialized with an
earthaccess.auth.Auth object, which will then be used to create a session or
s3login_credentials as they are called.

Expand Down Expand Up @@ -90,8 +94,8 @@ def session(self):
@property
def s3login_credentials(self):
"""
A dictionary which stores login credentials for AWS s3 access. This property is accessed
if using AWS cloud data.
A dictionary which stores login credentials for AWS s3 access.
This property is accessed if using AWS cloud data.

Because s3 tokens are only good for one hour, this function will automatically check if an
hour has elapsed since the last token use and generate a new token if necessary.
Expand All @@ -115,9 +119,12 @@ def set_s3_creds():
def earthdata_login(self, uid=None, email=None, s3token=None, **kwargs) -> None:
"""
Authenticate with NASA Earthdata to enable data ordering and download.
Credential storage details are described in the EathdataAuthMixin class section.
Credential storage details are described in the
EathdataAuthMixin class section.

**Note:** This method is maintained for backward compatibility. It is no longer required to explicitly run `.earthdata_login()`. Authentication will be performed by the module as needed when `.session` or `.s3login_credentials` are accessed.
**Note:** This method is deprecated and will be removed in a future release.
It is no longer required to explicitly run `.earthdata_login()`.
Authentication will be performed by the module as needed.

Parameters
----------
Expand All @@ -126,7 +133,8 @@ def earthdata_login(self, uid=None, email=None, s3token=None, **kwargs) -> None:
email : string, default None
Deprecated keyword for backwards compatibility.
s3token : boolean, default None
Deprecated keyword to generate AWS s3 ICESat-2 data access credentials
Deprecated keyword to generate AWS s3 ICESat-2
data access credentials
kwargs : key:value pairs
Keyword arguments to be passed into earthaccess.login().

Expand All @@ -140,15 +148,7 @@ def earthdata_login(self, uid=None, email=None, s3token=None, **kwargs) -> None:
No .netrc found in /Users/username

"""
warnings.warn(
"It is no longer required to explicitly run the `.earthdata_login()` method. Authentication will be performed by the module as needed.",
DeprecationWarning,
stacklevel=2,
raise DeprecationError(
"It is no longer required to explicitly run the `.earthdata_login()` method."
"Authentication will be performed by the module as needed.",
)

if uid != None or email != None or s3token != None:
warnings.warn(
"The user id (uid) and/or email keyword arguments are no longer required.",
DeprecationWarning,
stacklevel=2,
)
6 changes: 2 additions & 4 deletions icepyx/core/icesat2data.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import warnings
from icepyx.core.exceptions import DeprecationError


class Icesat2Data:
def __init__(
self,
):
warnings.filterwarnings("always")
warnings.warn(
DeprecationError(
"DEPRECATED. Please use icepyx.Query to create a download data object (all other functionality is the same)",
DeprecationWarning,
)
6 changes: 2 additions & 4 deletions icepyx/core/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import matplotlib.pyplot as plt
from pathlib import Path # used in docstring tests
import pprint
import warnings

import icepyx.core.APIformatting as apifmt
from icepyx.core.auth import EarthdataAuthMixin
from icepyx.core.exceptions import DeprecationError
import icepyx.core.granules as granules
from icepyx.core.granules import Granules
import icepyx.core.is2ref as is2ref
Expand Down Expand Up @@ -455,10 +455,8 @@ def dataset(self):
--------
product
"""
warnings.filterwarnings("always")
warnings.warn(
DeprecationError(
"In line with most common usage, 'dataset' has been replaced by 'product'.",
DeprecationWarning,
)

@property
Expand Down
Loading
Loading