Skip to content

Commit

Permalink
Merge branch 'master' into other-major-breaking-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaze committed Sep 25, 2024
2 parents 747ba13 + 549d8c3 commit a1aedc5
Show file tree
Hide file tree
Showing 228 changed files with 10,175 additions and 2,896 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytests-upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
defaults:
run:
shell: bash -l {0}
timeout-minutes: 45
# timeout-minutes: 45
strategy:
fail-fast: true
matrix:
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
defaults:
run:
shell: bash -l {0}
timeout-minutes: 45
# timeout-minutes: 45
strategy:
fail-fast: true
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run:
shell: bash -l {0}
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 45
# timeout-minutes: 45
strategy:
max-parallel: 12
fail-fast: false
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
run:
shell: bash -l {0}
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 45
# timeout-minutes: 45
strategy:
max-parallel: 12
fail-fast: false
Expand Down
19 changes: 16 additions & 3 deletions HOW_TO_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- [ ] Create a new branch for this release: ``git checkout -b releasev0.X.Y``
- [ ] Update release version in ``./docs/whats-new.rst``
- [ ] Increase release version in ``./setup.py``
- [ ] Create a PR to prepare it, name it with one of the [Nature emoji](https://www.webfx.com/tools/emoji-cheat-sheet/#tabs-3) and make sure it was [never used before](https://github.com/euroargodev/argopy/pulls?q=is%3Apr+label%3Arelease+)
- [ ] Create a PR to prepare it, name it with one of the [Nature emoji](https://www.webfx.com/tools/emoji-cheat-sheet/#tabs-3) and make sure it was [never used before](https://github.com/euroargodev/argopy/pulls?q=is%3Apr+label%3Arelease+)
- [ ] [Activate RTD build for this branch](https://app.readthedocs.org/dashboard/argopy/version/create/)

# Prepare code for release

Expand All @@ -14,7 +15,19 @@
- [ ] If code is marked as deprecated since version = v0.X.Y-2 : delete code (code will raise an error)
- [ ] Update the documentation according to new deprecations

## Code clean-up
## Update static content
- [ ] Update CI tests data used by mocked ftp and http servers. Use CLI [citests_httpdata_manager](https://github.com/euroargodev/argopy/blob/master/cli/citests_httpdata_manager):
```bash
cd cli
./citests_httpdata_manager -a clear --force --refresh
./citests_httpdata_manager -a download
./citests_httpdata_manager -a check
```
- [ ] Update list of valid Reference tables from the [NVS server](https://vocab.nerc.ac.uk/collection/?filter=Argo)
- [ ] Update [static assets files](https://github.com/euroargodev/argopy/tree/master/argopy/static/assets)
- [ ] Update the [cheatsheet PDF](https://github.com/euroargodev/argopy/blob/master/docs/_static/argopy-cheatsheet.pdf) with all new release features

## Code clean-up and update
- [ ] Run [codespell](https://github.com/codespell-project/codespell) from repo root and fix errors: ``codespell -q 2``
- [ ] Run [flake8](https://github.com/PyCQA/flake8) from repo root and fix errors

Expand All @@ -23,7 +36,7 @@
- [ ] Update pinned dependencies versions in ``./ci/requirements/py*-*-pinned.yml`` environment files using [upstream CI tests](https://github.com/euroargodev/argopy/actions/workflows/pytests-upstream.yml) information
- [ ] Possibly update ``./requirements.txt`` and ``./docs/requirements.txt`` if the oldest dependencies versions were upgraded
- [ ] Make sure that all CI tests are passed
- [ ] [Activate](https://readthedocs.org/projects/argopy/versions/) and make sure the documentation for the release branch is [built on RTD](https://readthedocs.org/projects/argopy/builds/)
- [ ] Make sure the documentation for this release branch is [built on RTD](https://readthedocs.org/projects/argopy/builds/)

## Preparation conclusion
- [ ] Merge this PR to master
Expand Down
19 changes: 17 additions & 2 deletions argopy/data_fetchers/argovis_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,12 @@ def uri(self):
)
boxes = self.Chunker.fit_transform()
for box in boxes:
urls.append(Fetch_box(box=box, ds=self.dataset_id).get_url())
opts = {
"ds": self.dataset_id,
"fs": self.fs,
"server": self.server,
}
urls.append(Fetch_box(box=box, **opts).get_url())
else:
urls.append(self.get_url())
else:
Expand Down Expand Up @@ -556,6 +561,16 @@ def uri(self):
)
boxes = self.Chunker.fit_transform()
for box in boxes:
urls.append(Fetch_box(box=box, ds=self.dataset_id).get_url())
opts = {
"ds": self.dataset_id,
"fs": self.fs,
"server": self.server,
}
urls.append(
Fetch_box(
box=box,
**opts,
).get_url()
)

return self.url_encode(urls)
1 change: 0 additions & 1 deletion argopy/data_fetchers/erddap_refdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def _add_attributes(self, this): # noqa: C901

return this


@property
def _minimal_vlist(self):
"""Return the minimal list of variables to retrieve measurements for"""
Expand Down
50 changes: 50 additions & 0 deletions argopy/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""A bunch of custom errors used in argopy."""
from typing import List
import warnings
import logging

log = logging.getLogger("argopy.errors")

class NoData(ValueError):
"""Raise for no data"""
Expand Down Expand Up @@ -152,3 +157,48 @@ class ErddapHTTPNotFound(APIServerError):
"""Raise when erddap resource is not found"""

pass


class OptionDeprecatedWarning(DeprecationWarning):
"""When an option being deprecated is used
This is a class to emit a warning when an option being deprecated is used.
Parameters
----------
reason: str, optional, default=None
Text message to send with deprecation warning
version: str, optional, default=None
ignore_caller: List, optional, default=[]
"""
def __init__(self, reason: str = None, version: str = None, ignore_caller: List = []):
import inspect
ignore_caller = [ignore_caller]

if isinstance(reason, str):

fmt = "\nCall to deprecated option: {reason}"
if version is not None:
fmt = "%s -- Deprecated since version {version}" % fmt

issue_deprec = True
stack = inspect.stack()
for s in stack:
if "<module>" in s.function:
break
elif s.function in ignore_caller:
issue_deprec = False

if issue_deprec:
warnings.simplefilter("always", DeprecationWarning)
warnings.warn(
fmt.format(reason=reason, version=version),
category=DeprecationWarning,
stacklevel=2,
)
warnings.simplefilter("default", DeprecationWarning)
else:
log.warning(fmt.format(reason=reason, version=version))

else:
raise TypeError(repr(type(reason)))
40 changes: 26 additions & 14 deletions argopy/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
import logging

from .options import OPTIONS, _VALIDATORS
from .errors import InvalidFetcherAccessPoint, InvalidFetcher, OptionValueError
from .errors import (
InvalidFetcherAccessPoint,
InvalidFetcher,
OptionValueError,
OptionDeprecatedWarning,
)
from .related import (
get_coriolis_profile_id,
)
from .utils.checkers import (
is_box,
is_indexbox,
check_wmo,
check_cyc
)
from .utils.checkers import is_box, is_indexbox, check_wmo, check_cyc
from .utils.lists import (
list_available_data_src,
list_available_index_src,
Expand Down Expand Up @@ -166,8 +166,15 @@ def __init__(self, mode: str = "", src: str = "", ds: str = "", **fetcher_kwargs
if self._src == "argovis" and (
self._mode == "expert" or self._mode == "research"
):
raise OptionValueError("The 'argovis' data source fetching is only available in 'standard' user mode")
raise OptionValueError(
"The 'argovis' data source fetching is only available in 'standard' user mode"
)

if self._src == "gdac" and "ftp" in self.fetcher_kwargs:
OptionDeprecatedWarning(
reason="The GDAC 'ftp' argument is deprecated, it will be replaced by 'gdac' in versions >= 0.1.18",
version="v0.0.17",
)

def __repr__(self):
para = (
Expand Down Expand Up @@ -299,7 +306,7 @@ def domain(self):

@property
def mission(self):
if self._dataset_id == 'bgc':
if self._dataset_id == "bgc":
return "BGC"
else:
return "core+deep"
Expand Down Expand Up @@ -592,18 +599,21 @@ def to_index(self, full: bool = False, coriolis_id: bool = False) -> pd.DataFram
:class:`pandas.DataFrame`
Argo-like index of fetched data
"""

def prt(txt):
msg = [txt]
if self._request != self.__repr__():
msg.append(self._request)
log.debug("\n".join(msg))

def add_coriolis(this_df):
if 'id' not in this_df:
if "id" not in this_df:
this_df["id"] = None

def fc(row):
row["id"] = get_coriolis_profile_id(row["wmo"], row["cyc"])["ID"].values[0]
row["id"] = get_coriolis_profile_id(row["wmo"], row["cyc"])[
"ID"
].values[0]
return row

this_df = this_df.apply(fc, axis=1)
Expand All @@ -626,7 +636,9 @@ def fc(row):
if self._AccessPoint == "float":
idx.search_wmo(self._AccessPoint_data["wmo"])
if self._AccessPoint == "profile":
idx.search_wmo_cyc(self._AccessPoint_data["wmo"], self._AccessPoint_data["cyc"])
idx.search_wmo_cyc(
self._AccessPoint_data["wmo"], self._AccessPoint_data["cyc"]
)

# Then export search result to Index dataframe:
df = idx.to_dataframe()
Expand Down Expand Up @@ -673,7 +685,7 @@ def fc(row):
df = add_coriolis(df) if coriolis_id else df

# Possibly replace the light index with the full version:
if 'profiler_code' not in df or self._request == self.__repr__():
if "profiler_code" not in df or self._request == self.__repr__():
prt("to_index replaced the light index with the full version")
self._index = df

Expand All @@ -691,7 +703,7 @@ def fc(row):
return df

def load(self, force: bool = False, **kwargs):
""" Fetch data (and compute a profile index) if not already in memory
"""Fetch data (and compute a profile index) if not already in memory
Apply the default to_xarray() and to_index() methods and store results in memory.
You can access loaded measurements structure with the `data` and `index` properties.
Expand Down
2 changes: 1 addition & 1 deletion argopy/related/argo_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def parse(self, file):
else:
# print("-", line)
record[tag].append(line)
except UnboundLocalError as e:
except UnboundLocalError:
pass
elif len(line) == 2:
record[line] = []
Expand Down
12 changes: 5 additions & 7 deletions argopy/related/reference_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class ArgoNVSReferenceTables:

valid_ref = [
"R01",
"RR2",
"RD2",
"RP2",
"R03",
"R04",
"R05",
Expand All @@ -46,8 +43,6 @@ class ArgoNVSReferenceTables:
"R12",
"R13",
"R15",
"RMC",
"RTV",
"R16",
"R18",
"R19",
Expand All @@ -60,9 +55,12 @@ class ArgoNVSReferenceTables:
"R26",
"R27",
"R28",
"R29",
"R30",
"R40",
"RD2",
"RMC",
"RP2",
"RR2",
"RTV",
]
"""List of all available Reference Tables"""

Expand Down
2 changes: 1 addition & 1 deletion argopy/static/assets/admt_documentation_catalogue.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ADMT documentation catalogue",
"long_name": "Titles and DOIs of all the official ADMT documentation",
"last_update": "2024-09-12T14:13:10.643203+00:00",
"last_update": "2024-09-20T09:27:55.161297+00:00",
"data": {
"catalogue": [
{
Expand Down
2 changes: 1 addition & 1 deletion argopy/static/assets/api_coriolis_parameter_codes.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parameters",
"long_name": "All valid requests to https://api-coriolis.ifremer.fr/legacy/parameter?code={code}",
"last_update": "2024-09-12T14:13:10.597080+00:00",
"last_update": "2024-09-20T09:27:55.145057+00:00",
"data": {
"valid_codes": [
"9",
Expand Down
2 changes: 1 addition & 1 deletion argopy/static/assets/data_types.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "data_types",
"long_name": "Expected data types of Argo variables",
"last_update": "2024-09-12T14:12:40.949768+00:00",
"last_update": "2024-09-20T09:26:28.473595+00:00",
"data": {
"str": [
"PLATFORM_NUMBER",
Expand Down
2 changes: 1 addition & 1 deletion argopy/static/assets/institutions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "institutions",
"long_name": "Institution names from Argo reference table 4",
"last_update": "2024-09-12T14:12:41.637174+00:00",
"last_update": "2024-09-20T09:26:28.990073+00:00",
"data": {
"institutions": {
"PL": "IOPAN, Institute of Oceanology Polish Academy of Science",
Expand Down
2 changes: 1 addition & 1 deletion argopy/static/assets/profilers.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "profilers",
"long_name": "Profiler codes and description from Argo reference table 8",
"last_update": "2024-09-12T14:12:42.118648+00:00",
"last_update": "2024-09-20T09:26:30.350138+00:00",
"data": {
"profilers": {
"841": "PROVOR float with SBE conductivity sensor",
Expand Down
2 changes: 1 addition & 1 deletion argopy/static/assets/variables_bgc_synthetic.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "BGC synthetic netcdf files variables",
"long_name": "Variables from the Ifremer Erddap ArgoFloats-synthetic-BGC dataset based on GDAC synthetic netcdf files",
"last_update": "2024-09-12T14:13:10.711233+00:00",
"last_update": "2024-09-20T09:27:55.354835+00:00",
"data": {
"variables": [
"BBP470",
Expand Down
Binary file not shown.
Loading

0 comments on commit a1aedc5

Please sign in to comment.