diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3d4a4f..5ebd28b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: tests: # if: github.event_name == 'push' || github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: matrix: python-version: [3.7.9] @@ -23,7 +23,7 @@ jobs: # Hack to get setup-python to work on act # https://github.com/nektos/act/issues/251#issuecomment-706412948 if [ ! -f "/etc/lsb-release" ] ; then - echo "DISTRIB_RELEASE=18.04" > /etc/lsb-release + echo "DISTRIB_RELEASE=20.04" > /etc/lsb-release fi # Hack needed for ES to start if [ ! -d "/tmp/localstack/es_backup" ] ; then diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38b294d..8c2bbae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,9 @@ repos: - "click==7.1.2" - repo: https://github.com/PyCQA/isort - rev: 5.4.2 + # See https://stackoverflow.com/a/75295105/1259982 for + # rev value + rev: 5.11.5 hooks: - id: isort args: ["--profile", "black"] diff --git a/cbers2stac/elasticsearch/es.py b/cbers2stac/elasticsearch/es.py index 2efda5c..c92f245 100644 --- a/cbers2stac/elasticsearch/es.py +++ b/cbers2stac/elasticsearch/es.py @@ -9,7 +9,7 @@ from typing import Any, Dict, List, Tuple, Union from aws_requests_auth.boto_utils import BotoAWSRequestsAuth -from elasticsearch_dsl import Q, Search +from elasticsearch_dsl import Q, Search # pylint: disable=wrong-import-order from cbers2stac.layers.common.utils import ( STAC_API_VERSION, @@ -22,7 +22,9 @@ static_to_api_collection, ) from elasticsearch import Elasticsearch, RequestsHttpConnection -from elasticsearch.helpers import bulk + +from elasticsearch.helpers import bulk # isort: skip + # Get rid of "Found credentials in environment variables" messages logging.getLogger("botocore.credentials").disabled = True diff --git a/cbers2stac/layers/common/cbers_2_stac.py b/cbers2stac/layers/common/cbers_2_stac.py index bfd331d..18ae50d 100755 --- a/cbers2stac/layers/common/cbers_2_stac.py +++ b/cbers2stac/layers/common/cbers_2_stac.py @@ -293,6 +293,7 @@ def build_asset( return asset +@typing.no_type_check def build_stac_item_keys(cbers_am, buckets): """ Builds a STAC item dict based on CBERS_AM metadata @@ -529,6 +530,11 @@ def candidate_xml_files(xml_file: str) -> List[str]: ): for optics in ["", "_LEFT", "_RIGHT"]: xml_options.append(re.sub(r"_L(\d+)_", f"_L\\g<1>{optics}_", xml_file)) + elif group["satellite"] == "CBERS" and group["camera"] == "PAN10M": + # CB4 PAN10M uses band4 for old INPE catalog and BAND3 for new + # catalog + xml_options.append(xml_file) + xml_options.append(re.sub(r"_BAND4", r"_BAND3", xml_file)) else: xml_options.append(xml_file) return xml_options diff --git a/test/cbers_am_2_stac_test.py b/test/cbers_am_2_stac_test.py index 6823f5d..77db5c9 100644 --- a/test/cbers_am_2_stac_test.py +++ b/test/cbers_am_2_stac_test.py @@ -69,6 +69,14 @@ def test_candidate_xml_files(): "CBERS_4_AWFI_20220614_170_099_L4_RIGHT_BAND14.xml", ] + # CBERS4 PAN10M special case + options = candidate_xml_files("CBERS_4_PAN10M_20230301_092_100_L2_BAND4.xml") + assert len(options) == 2 + assert options == [ + "CBERS_4_PAN10M_20230301_092_100_L2_BAND4.xml", + "CBERS_4_PAN10M_20230301_092_100_L2_BAND3.xml", + ] + def test_get_keys_from_cbers4(): """test_get_keys_from_cbers"""