From 14f45a02a034476d39b1b02c8ce06680926a410c Mon Sep 17 00:00:00 2001 From: Fabian Gebhart <16943048+fgebhart@users.noreply.github.com> Date: Sun, 27 Oct 2024 20:45:18 +0100 Subject: [PATCH] cleanup, use ruff --- .pre-commit-config.yaml | 17 ++--- mapa/stac.py | 2 - mapa/test.ipynb | 149 ---------------------------------------- 3 files changed, 4 insertions(+), 164 deletions(-) delete mode 100644 mapa/test.ipynb diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2eedf46..a21a948 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,5 @@ repos: - - repo: https://github.com/psf/black - rev: 23.1.0 - hooks: - - id: black - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -14,12 +9,8 @@ repos: - id: end-of-file-fixer types: [python] - - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - - - repo: https://github.com/pycqa/isort - rev: 5.12.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.7.1 hooks: - - id: isort + - id: ruff + - id: ruff-format diff --git a/mapa/stac.py b/mapa/stac.py index 8748f96..46695d4 100644 --- a/mapa/stac.py +++ b/mapa/stac.py @@ -16,7 +16,6 @@ def _download_file(url: str, local_file: Path) -> Path: - log.info(f"downloading {url} to {local_file}") request.urlretrieve(url, local_file) return local_file @@ -60,7 +59,6 @@ def fetch_stac_items_for_bbox( ) search = client.search(collections=[conf.PLANETARY_COMPUTER_COLLECTION], bbox=bbox) items = list(search.items()) - log.info(f"got items: {items}") n = len(items) if progress_bar: progress_bar.steps += n diff --git a/mapa/test.ipynb b/mapa/test.ipynb deleted file mode 100644 index edb7d4f..0000000 --- a/mapa/test.ipynb +++ /dev/null @@ -1,149 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "import pystac\n", - "import planetary_computer\n", - "import rioxarray\n", - "\n", - "# item_url = \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/alos-dem/items/ALPSMLC30_S025E044_DSM\"\n", - "item_url = \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/alos-dem/items/ALPSMLC30_N025E025_DSM\"\n", - "# item_url = \"https://planetarycomputer.microsoft.com/api/stac/v1\"" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "<Item id=ALPSMLC30_N025E025_DSM>" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Load the individual item metadata and sign the assets\n", - "item = pystac.Item.from_file(item_url)\n", - "item" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "<Item id=ALPSMLC30_N025E025_DSM>" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "signed_item = planetary_computer.sign(item)\n", - "signed_item" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'https://ai4edataeuwest.blob.core.windows.net/alos-dem/AW3D30_global/ALPSMLC30_N025E025_DSM.tif'" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Open one of the data assets \n", - "asset_href = item.assets[\"data\"].href\n", - "asset_href\n", - "# ds = rioxarray.open_rasterio(asset_href)\n", - "# ds" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'https://ai4edataeuwest.blob.core.windows.net/alos-dem/AW3D30_global/ALPSMLC30_N025E025_DSM.tif?st=2024-10-26T18%3A58%3A20Z&se=2024-10-27T19%3A43%3A20Z&sp=rl&sv=2024-05-04&sr=c&skoid=9c8ff44a-6a2c-4dfb-b298-1c9212f64d9a&sktid=72f988bf-86f1-41af-91ab-2d7cd011db47&skt=2024-10-27T14%3A16%3A22Z&ske=2024-11-03T14%3A16%3A22Z&sks=b&skv=2024-05-04&sig=E6V4kgv4wXmu1Pib6WncldWBCa94/cNnvbJtHoIaQlU%3D'" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Open one of the data assets \n", - "asset_href = item.assets[\"data\"].href\n", - "asset_href\n", - "# ds = rioxarray.open_rasterio(asset_href)\n", - "# ds" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Open one of the data assets \n", - "asset_href = signed_item.assets[\"data\"].href\n", - "ds = rioxarray.open_rasterio(asset_href)\n", - "ds" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}