From 6355597e04f18b7cd304e7252d020a748886a3b6 Mon Sep 17 00:00:00 2001 From: betolink Date: Fri, 27 Jan 2023 15:22:12 -0600 Subject: [PATCH] fixing netrc #196 --- .github/workflows/documentation.yml | 13 ++++++------- earthaccess/api.py | 7 ++++--- earthaccess/results.py | 14 +++++++++++++- tests/unit/fixtures/.placeholder | 0 4 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 tests/unit/fixtures/.placeholder diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index e86343df..3ff34fc0 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -18,16 +18,15 @@ on: jobs: documentation: runs-on: ubuntu-latest - + defaults: + run: + shell: bash -l {0} steps: - - uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2 + - uses: actions/checkout@v3 + uses: mamba-org/provision-with-micromamba@main with: - python-version: 3.9 - channels: conda-forge - mamba-version: "*" - activate-environment: earthaccess-dev environment-file: binder/environment-dev.yml + activate-name: earthaccess-dev - name: Get full python version id: full-python-version run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") diff --git a/earthaccess/api.py b/earthaccess/api.py index dcb73d03..0a07794e 100644 --- a/earthaccess/api.py +++ b/earthaccess/api.py @@ -106,7 +106,7 @@ def search_data( return query.get_all() -def login(strategy: str = "interactive") -> Auth: +def login(strategy: str = "interactive", persist: bool = False) -> Auth: """Authenticate with Earthdata login (https://urs.earthdata.nasa.gov/) Parameters: @@ -122,8 +122,9 @@ def login(strategy: str = "interactive") -> Auth: Returns: an instance of Auth. """ - earthaccess.__auth__.login(strategy=strategy) - earthaccess.__store__ = Store(earthaccess.__auth__) + earthaccess.__auth__.login(strategy=strategy, persist=persist) + if earthaccess.__auth__ is not None: + earthaccess.__store__ = Store(earthaccess.__auth__) return earthaccess.__auth__ diff --git a/earthaccess/results.py b/earthaccess/results.py index 7e8fea9c..8de0590d 100644 --- a/earthaccess/results.py +++ b/earthaccess/results.py @@ -257,7 +257,19 @@ def size(self) -> float: ] ) except Exception: - total_size = 0 + try: + total_size = sum( + [ + float(s["SizeInBytes"]) + for s in self[ + "umm.DataGranule.ArchiveAndDistributionInformation" + ] + if "ArchiveAndDistributionInformation" + in self["umm"]["DataGranule"] + ] + ) / (1024 * 1024) + except Exception: + total_size = 0 return total_size def _derive_s3_link(self, links: List[str]) -> List[str]: diff --git a/tests/unit/fixtures/.placeholder b/tests/unit/fixtures/.placeholder new file mode 100644 index 00000000..e69de29b