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

add workflow #83

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
61 changes: 33 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
default_language_version:
python: python3.9

default_stages: [commit, push]
ci:
autoupdate_schedule: monthly

# https://pre-commit.com/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: LICENSE

- repo: local
- id: check-docstring-first
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py39-plus
types: [python]
language: system

- repo: local
- id: black
- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: isort
name: isort
entry: poetry run isort --settings-path pyproject.toml
types: [python]
language: system

- repo: local
- id: blackdoc
additional_dependencies: ["black==24.10.0"]
- id: blackdoc-autoupdate-black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
hooks:
- id: black
name: black
entry: poetry run black --config pyproject.toml
types: [python]
language: system
- id: ruff
args: [--fix]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
args: [--extra-keys=metadata.kernelspec metadata.language_info.version]
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
hooks:
- id: prettier
- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format
- id: taplo-lint
args: [--no-schema]
47 changes: 24 additions & 23 deletions tests_metiers/test_new_caledonia.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@

import datetime
import shapely
import geopandas as gpd
import cdsodatacli
import logging
import time

if __name__ == '__main__':
t0 = time.time()
import argparse

parser = argparse.ArgumentParser(description="testsnewrelease")
parser.add_argument("--verbose", action="store_true", default=False)
parser.add_argument("--cache", action="store_true", default=None,
help='cache directory to store answer from CDS as json files [default is None]')
parser.add_argument('--mode',choices=['seq','multi'],
parser.add_argument('--mode', choices=['seq', 'multi'],
help='mode of query seq-> sequential multi-> multithread [default is sequential]',
default='seq',required=False)
default='seq', required=False)
args = parser.parse_args()
fmt = "%(asctime)s %(levelname)s %(filename)s(%(lineno)d) %(message)s"
if args.verbose:
Expand All @@ -26,14 +27,14 @@
level=logging.INFO, format=fmt, datefmt="%d/%m/%Y %H:%M:%S", force=True
)

sta = datetime.datetime(2014,4,6)
sta = datetime.datetime(2022,1,6)
sta = datetime.datetime(2014, 4, 6)
sta = datetime.datetime(2022, 1, 6)
sta = datetime.datetime.today() - datetime.timedelta(days=365)
sta = datetime.datetime(2023,1,1)
sta = datetime.datetime(2023, 1, 1)
# sta = datetime.datetime.today() - datetime.timedelta(days=7)
sto = datetime.datetime.today()
sto = datetime.datetime(2023,11,13)
logging.info('from %s to %s',sta,sto)
sto = datetime.datetime(2023, 11, 13)
logging.info('from %s to %s', sta, sto)
# 17° 52′ 46″ S 162° 36′ 31″ E
# 22° 56′ 36″ S 168° 12′ 02″ E
latmin = -17.87944444
Expand All @@ -43,21 +44,21 @@
# poly = shapely.wkt.loads("POLYGON ((162 -19, 169 -19, 169 -23, 162 -23, 162 -19))")
# cache_dir = '/home1/scratch/agrouaze/cache_cdsodata/'
# cache_dir = None
poly = shapely.geometry.Polygon([(lonmin,latmin),(lonmax,latmin),(lonmax,latmax),(lonmin,latmax),(lonmin,latmin)])
poly = shapely.geometry.Polygon(
[(lonmin, latmin), (lonmax, latmin), (lonmax, latmax), (lonmin, latmax), (lonmin, latmin)])
gdf = gpd.GeoDataFrame({
"start_datetime" : [ sta ],
"end_datetime" : [ sto],
"geometry" : [ poly],
"collection" : [ "SENTINEL-1"],
"name" : [ "1SDV"],
"sensormode" : [ 'IW'],
"producttype" : [ 'SLC'],
"Attributes" : [ None],
})
logging.info('cache_dir : %s',args.cache)
"start_datetime": [sta],
"end_datetime": [sto],
"geometry": [poly],
"collection": ["SENTINEL-1"],
"name": ["1SDV"],
"sensormode": ['IW'],
"producttype": ['SLC'],
"Attributes": [None],
})
logging.info('cache_dir : %s', args.cache)
# mode = 'multi'
collected_data_norm = cdsodatacli.query.fetch_data(gdf, min_sea_percent=30,cache_dir=args.cache,mode=args.mode)
collected_data_norm = cdsodatacli.query.fetch_data(gdf, min_sea_percent=30, cache_dir=args.cache, mode=args.mode)
logging.info("%s", collected_data_norm)
elapsed = time.time()-t0
logging.info('over total time: %1.1f sec',elapsed)

elapsed = time.time() - t0
logging.info('over total time: %1.1f sec', elapsed)
Loading