eotdl 2023.6.14.post8__py3-none-any.whl → 2023.6.14.post10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
eotdl/auth/__init__.py CHANGED
@@ -1 +1 @@
1
- from .main import is_logged, auth, generate_logout_url
1
+ from .main import is_logged, auth, generate_logout_url, with_auth
eotdl/auth/main.py CHANGED
@@ -1,7 +1,5 @@
1
1
  from ..src.repos import AuthRepo, APIRepo
2
- from ..src.usecases.auth.IsLogged import IsLogged
3
- from ..src.usecases.auth.Auth import Auth
4
- from ..src.usecases.auth.Logout import Logout
2
+ from ..src.usecases.auth import IsLogged, Auth, Logout
5
3
 
6
4
 
7
5
  def is_logged():
@@ -31,3 +29,12 @@ def generate_logout_url():
31
29
  inputs = _logout.Inputs()
32
30
  outputs = _logout(inputs)
33
31
  return outputs.logout_url
32
+
33
+
34
+ # auth decorator
35
+ def with_auth(func):
36
+ def wrapper(*args, **kwargs):
37
+ user = auth()
38
+ return func(*args, **kwargs, user=user)
39
+
40
+ return wrapper
@@ -29,8 +29,7 @@ def get(name: str, path: str = None):
29
29
  path: Path to download the dataset to
30
30
  """
31
31
  try:
32
- user = auth()
33
- dst_path = download_dataset(name, path, user, typer.echo)
32
+ dst_path = download_dataset(name, path, typer.echo)
34
33
  typer.echo(f"Dataset {name} downloaded to {dst_path}")
35
34
  except Exception as e:
36
35
  typer.echo(e)
@@ -49,10 +48,9 @@ def ingest(
49
48
  n: Name of the dataset
50
49
  """
51
50
  try:
52
- user = auth()
53
51
  # if p:
54
52
  # ingest_large_dataset_parallel(name, path, user, p, typer.echo)
55
- ingest_large_dataset(name, path, user, typer.echo)
53
+ ingest_large_dataset(name, path, typer.echo)
56
54
  typer.echo(f"Dataset {name} ingested")
57
55
  except Exception as e:
58
56
  typer.echo(e)
@@ -70,8 +68,7 @@ def update(
70
68
  path: Path to dataset to ingest
71
69
  """
72
70
  try:
73
- user = auth()
74
- update_dataset(name, path, user, typer.echo)
71
+ update_dataset(name, path, typer.echo)
75
72
  typer.echo(f"Dataset {name} updated")
76
73
  except Exception as e:
77
74
  typer.echo(e)
@@ -1,4 +1,4 @@
1
1
  from .ingest import ingest_dataset, ingest_large_dataset, ingest_q0, ingest_q1
2
2
  from .download import download_dataset
3
- from .retrieve import retrieve_datasets, retrieve_dataset
3
+ from .retrieve import retrieve_datasets, retrieve_dataset, list_datasets
4
4
  from .update import update_dataset
@@ -1,9 +1,11 @@
1
1
  from ..src.repos import APIRepo
2
- from ..src.usecases.datasets.DownloadDataset import DownloadDataset
2
+ from ..src.usecases.datasets import DownloadDataset
3
3
  from .retrieve import retrieve_dataset
4
+ from ..auth import with_auth
4
5
 
5
6
 
6
- def download_dataset(name, path, user, logger):
7
+ @with_auth
8
+ def download_dataset(name, path=None, logger=None, user=None):
7
9
  dataset = retrieve_dataset(name)
8
10
  dataset_id = dataset["id"]
9
11
  checksum = dataset["checksum"]
eotdl/datasets/ingest.py CHANGED
@@ -1,19 +1,10 @@
1
1
  from ..src.repos import APIRepo
2
- from ..src.usecases.datasets.IngestDataset import IngestDataset
3
- from ..src.usecases.datasets.IngestLargeDataset import IngestLargeDataset
2
+ from ..src.usecases.datasets import IngestDataset, IngestLargeDataset
3
+ from ..auth import with_auth
4
4
 
5
5
 
6
- def ingest_q0(dataset, file):
7
- print("hola")
8
- return
9
-
10
-
11
- def ingest_q1(dataset, stac_catalog):
12
- print("hola")
13
- return
14
-
15
-
16
- def ingest_dataset(name, description, path, user, logger):
6
+ @with_auth
7
+ def ingest_dataset(name, description, path, logger=None, user=None):
17
8
  api_repo = APIRepo()
18
9
  ingest = IngestDataset(
19
10
  api_repo,
@@ -23,9 +14,19 @@ def ingest_dataset(name, description, path, user, logger):
23
14
  return outputs.dataset
24
15
 
25
16
 
26
- def ingest_large_dataset(name, path, user, logger):
17
+ @with_auth
18
+ def ingest_large_dataset(name, path, logger=None, user=None):
27
19
  api_repo = APIRepo()
28
20
  ingest = IngestLargeDataset(api_repo, logger)
29
21
  inputs = ingest.Inputs(name=name, path=path, user=user)
30
22
  outputs = ingest(inputs)
31
23
  return outputs.dataset
24
+
25
+
26
+ def ingest_q0(dataset, path):
27
+ return ingest_large_dataset(dataset, path)
28
+
29
+
30
+ def ingest_q1(dataset, stac_catalog):
31
+ print("holas")
32
+ return
@@ -1,6 +1,9 @@
1
1
  from ..src.repos import APIRepo
2
- from ..src.usecases.datasets.RetrieveDatasets import RetrieveDatasets
3
- from ..src.usecases.datasets.RetrieveDataset import RetrieveDataset
2
+ from ..src.usecases.datasets import RetrieveDatasets, RetrieveDataset
3
+
4
+
5
+ def list_datasets():
6
+ return retrieve_datasets()
4
7
 
5
8
 
6
9
  def retrieve_datasets():
eotdl/datasets/update.py CHANGED
@@ -1,8 +1,10 @@
1
1
  from ..src.repos import APIRepo
2
- from ..src.usecases.datasets.UpdateDataset import UpdateDataset
2
+ from ..src.usecases.datasets import UpdateDataset
3
+ from ..auth import with_auth
3
4
 
4
5
 
5
- def update_dataset(name, path, user, logger):
6
+ @with_auth
7
+ def update_dataset(name, path, logger=None, user=None):
6
8
  api_repo = APIRepo()
7
9
  ingest = UpdateDataset(api_repo, logger)
8
10
  inputs = ingest.Inputs(name=name, path=path, user=user)
@@ -35,7 +35,7 @@ class APIRepo:
35
35
  url = self.url + "datasets/" + dataset_id + "/download"
36
36
  headers = {"Authorization": "Bearer " + id_token}
37
37
  if path is None:
38
- path = str(Path.home()) + "/.etodl/datasets"
38
+ path = str(Path.home()) + "/.eotdl/datasets"
39
39
  os.makedirs(path, exist_ok=True)
40
40
  with requests.get(url, headers=headers, stream=True) as r:
41
41
  r.raise_for_status()
@@ -46,6 +46,8 @@ class APIRepo:
46
46
  )
47
47
  filename = r.headers.get("content-disposition").split("filename=")[1][1:-1]
48
48
  path = f"{path}/{filename}"
49
+ if os.path.exists(path):
50
+ raise Exception("File already exists")
49
51
  with open(path, "wb") as f:
50
52
  for chunk in r.iter_content(block_size):
51
53
  progress_bar.update(len(chunk))
@@ -1,31 +1,36 @@
1
1
  from pathlib import Path
2
- import os
3
- import json
2
+ import os
3
+ import json
4
4
  import jwt
5
5
 
6
- class AuthRepo():
6
+
7
+ class AuthRepo:
7
8
  def __init__(self):
8
- self.algorithms = ['RS256']
9
+ self.algorithms = ["RS256"]
9
10
  self.home = str(Path.home())
10
- self.creds_path = self.home + '/.etodl/creds.json'
11
+ self.creds_path = self.home + "/.eotdl/creds.json"
11
12
 
12
13
  def save_creds(self, data):
13
- os.makedirs(self.home + '/.etodl', exist_ok=True)
14
- with open(self.creds_path, 'w') as f:
14
+ os.makedirs(self.home + "/.eotdl", exist_ok=True)
15
+ with open(self.creds_path, "w") as f:
15
16
  json.dump(data, f)
16
17
  return self.creds_path
17
-
18
+
18
19
  def load_creds(self):
19
20
  if os.path.exists(self.creds_path):
20
- with open(self.creds_path, 'r') as f:
21
+ with open(self.creds_path, "r") as f:
21
22
  creds = json.load(f)
22
23
  user = self.decode_token(creds)
23
- user['id_token'] = creds['id_token']
24
+ user["id_token"] = creds["id_token"]
24
25
  return user
25
26
  return None
26
-
27
+
27
28
  def decode_token(self, token_data):
28
- return jwt.decode(token_data['id_token'], algorithms=self.algorithms, options={"verify_signature": False})
29
-
29
+ return jwt.decode(
30
+ token_data["id_token"],
31
+ algorithms=self.algorithms,
32
+ options={"verify_signature": False},
33
+ )
34
+
30
35
  def logout(self):
31
36
  os.remove(self.creds_path)
@@ -0,0 +1,3 @@
1
+ from .Auth import Auth
2
+ from .IsLogged import IsLogged
3
+ from .Logout import Logout
@@ -5,7 +5,7 @@ from ....src.utils import calculate_checksum
5
5
  class DownloadDataset:
6
6
  def __init__(self, repo, logger):
7
7
  self.repo = repo
8
- self.logger = logger
8
+ self.logger = logger if logger else print
9
9
 
10
10
  class Inputs(BaseModel):
11
11
  dataset: str
@@ -4,7 +4,7 @@ from pydantic import BaseModel
4
4
  class IngestDataset:
5
5
  def __init__(self, repo, logger):
6
6
  self.repo = repo
7
- self.logger = logger
7
+ self.logger = logger if logger else print
8
8
 
9
9
  class Inputs(BaseModel):
10
10
  name: str
@@ -5,7 +5,7 @@ from ....src.utils import calculate_checksum
5
5
  class IngestLargeDataset:
6
6
  def __init__(self, repo, logger):
7
7
  self.repo = repo
8
- self.logger = logger
8
+ self.logger = logger if logger else print
9
9
 
10
10
  class Inputs(BaseModel):
11
11
  name: str
@@ -5,7 +5,7 @@ from ....src.utils import calculate_checksum
5
5
  class UpdateDataset:
6
6
  def __init__(self, repo, logger):
7
7
  self.repo = repo
8
- self.logger = logger
8
+ self.logger = logger if logger else print
9
9
 
10
10
  class Inputs(BaseModel):
11
11
  name: str
@@ -0,0 +1,6 @@
1
+ from .DownloadDataset import DownloadDataset
2
+ from .IngestDataset import IngestDataset
3
+ from .IngestLargeDataset import IngestLargeDataset
4
+ from .RetrieveDataset import RetrieveDataset
5
+ from .RetrieveDatasets import RetrieveDatasets
6
+ from .UpdateDataset import UpdateDataset
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eotdl
3
- Version: 2023.6.14.post8
3
+ Version: 2023.6.14.post10
4
4
  Summary: Earth Observation Training Data Lab
5
5
  License: MIT
6
6
  Author: EarthPulse
@@ -4,12 +4,12 @@ eotdl/access/parameters.py,sha256=g24CVwJR-KuHBgNyXj_Y6W2OoGSkKFN7IkidYDvPLws,36
4
4
  eotdl/access/sentinelhub/__init__.py,sha256=v3P2WjEQuA9bmh8RHE3zuADSL_CEukTRyzR66J3kQVg,252
5
5
  eotdl/access/sentinelhub/client.py,sha256=skL3EfVuBLSoOc8gbbsWuAe9UTDYSI1IdpqU8HsdNW4,7605
6
6
  eotdl/access/sentinelhub/utils.py,sha256=4xzAOoxA4A3EmBD1HX7IAbiXl9cMTfYabq0wGkFrx8A,6595
7
- eotdl/auth/__init__.py,sha256=PjlHb69cgXcrlyCkvNeEZEegj-DZsVXzuYb1N8MwVWY,55
8
- eotdl/auth/main.py,sha256=_6UUGhfJjwDetROT4bBSapuv4zmKlaawuSDNXHJgaW0,776
7
+ eotdl/auth/__init__.py,sha256=gN4x9suYveP1eZr5_7IisdTVy13B-Xnm_t6N_nwoI1o,66
8
+ eotdl/auth/main.py,sha256=q3-JcDbLJMEBSXa4Y7fofso4iK-b4QjL8QV0Ok7eqG8,857
9
9
  eotdl/cli.py,sha256=MQt1XWTrqPC-onQcAeo5Oq_pIgBQh7KdYkFPoZiJQi0,193
10
10
  eotdl/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  eotdl/commands/auth.py,sha256=_Kgud59Wp8Jc1Y-o8XZRXrtd_3QfRJ4d7H8HsCg0smg,937
12
- eotdl/commands/datasets.py,sha256=a5CLOqvMCygOaToy_GGnorn3ZhByp5d7x6Tk1usRA7U,1569
12
+ eotdl/commands/datasets.py,sha256=EVHJUJ0j3P4H6tF7sngNFgLwcG47upVHtunakrPkhbE,1485
13
13
  eotdl/curation/__init__.py,sha256=wdcnj-u8fwObyjF8LNebwYyUULEfp3m41X1TSjURO6w,270
14
14
  eotdl/curation/formatters.py,sha256=UllCEsWspqzoBOBy4iAz5oSh4AAMva88orFFmE5binA,2929
15
15
  eotdl/curation/metadata.py,sha256=m6mcCr7UI3Mgij3FbhQAHWetXyADJIQoL2JTUas8GoU,1552
@@ -19,37 +19,37 @@ eotdl/curation/stac/extensions.py,sha256=I8SRMn9lyw_0sNZ-FiJ7HYPEGozylgf58gVWBSA
19
19
  eotdl/curation/stac/parsers.py,sha256=KumL2ieBt0ATGgKoGyc-AJ99zSMeLD4-tI5MF9ruYPw,1380
20
20
  eotdl/curation/stac/stac.py,sha256=COFpXQAvVBpgNf7qVv3DfIalBzdnvyVuDiEDEGgnYsA,17796
21
21
  eotdl/curation/stac/utils.py,sha256=WxC1uRY3BJJh0GFgrU3IAV4-_vwMaUyeRYwUcySfj9k,1855
22
- eotdl/datasets/__init__.py,sha256=wdRufZVaMuL4ARUs9-YgExEDEtv-1jGXm-BRV53pQt8,211
23
- eotdl/datasets/download.py,sha256=KGJprSE2nZh79-EKwe9RjuFWLgKQdCIR9zdmGBxuYRY,529
24
- eotdl/datasets/ingest.py,sha256=eMfjQKf12-_uaXg6NyoQgdOr962Pusm5YF78e42ezSA,824
25
- eotdl/datasets/retrieve.py,sha256=VGUmCV5hPpTkGKovrALVFsA7hIghBkILFCiUEY3_Rn8,548
26
- eotdl/datasets/update.py,sha256=kVPBtcfNBx6BsBuO64IPFE-f4Tw3_uixOL7jrYNnKR0,330
22
+ eotdl/datasets/__init__.py,sha256=e_FZ1j6Qly-hLlCN4UrSdSfHjEID6YVHsDn20BUPps4,226
23
+ eotdl/datasets/download.py,sha256=b0vbA517fI95h1jA1pFGe-lBvesbpRRPHXhR6wQrPiI,568
24
+ eotdl/datasets/ingest.py,sha256=8656jxl-lMWYsEaI584iUAD451l-Jg8okN3X_7NU_Iw,846
25
+ eotdl/datasets/retrieve.py,sha256=sXQq5FEAAx48lf6GkaGg8zyMl4KnTRp8dU6JTUjF_RQ,534
26
+ eotdl/datasets/update.py,sha256=oePVcFnlVLEjMKy9Yls1so1lkRCbQBEmoIE6JRJ2gAA,366
27
27
  eotdl/hello.py,sha256=bkYLbDXy00l9-wcHDRZT9GUhsgJOHLp3N8yfYaGg6mY,74
28
28
  eotdl/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  eotdl/src/errors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  eotdl/src/errors/auth.py,sha256=PpnFU2DvnRo8xrM77wgskKi0tfEJ1Rhle4xv2RD1qpk,306
31
- eotdl/src/repos/APIRepo.py,sha256=jpSvDk0nXHpXWP2D-W9m0uJtgS26g3HwblJN_bvNkVE,9843
32
- eotdl/src/repos/AuthRepo.py,sha256=fUerbkPU709hQ3g3z-qJsg6AYJWksbiHiEP4PtNpioQ,955
31
+ eotdl/src/repos/APIRepo.py,sha256=1cDUf-_4g87OXNksYtABWLhbuUrRSiU75m-eBjuRSgM,9935
32
+ eotdl/src/repos/AuthRepo.py,sha256=5Gwj7D4MgZWdvGFgoWPQeI_OM7Gv4XWc9lkD2wMy1k4,987
33
33
  eotdl/src/repos/__init__.py,sha256=kJTtURg8RZ4GSwhFFyul-SX240r25wvLuwxIhyz9kmI,59
34
34
  eotdl/src/usecases/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  eotdl/src/usecases/auth/Auth.py,sha256=e36UNqjXSxrkM30lBmEtPd8FZr49Xt_uyTj9yieX7es,1587
36
36
  eotdl/src/usecases/auth/IsLogged.py,sha256=CTHKct0V1kCx54eQGElkzeDZoWN6CIppfDEFas6ToNI,332
37
37
  eotdl/src/usecases/auth/Logout.py,sha256=ZlCMnaSerqBr6XOCcV858qq8IMTAizx6dta-UB5qoVE,420
38
- eotdl/src/usecases/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- eotdl/src/usecases/datasets/DownloadDataset.py,sha256=c_tXZwmLRQN8qXX5le7Pnbe6oYafSSn1jasPkVt4HWc,767
40
- eotdl/src/usecases/datasets/IngestDataset.py,sha256=iXOwHj_Ng6Dmf9Py5KXonc5Z5mphsefAiN5r-dcB6g4,932
41
- eotdl/src/usecases/datasets/IngestLargeDataset.py,sha256=5_rOK3fh8gE8kybV02cM9VAG1xI-mCTWgykZ_HZqu8I,1407
38
+ eotdl/src/usecases/auth/__init__.py,sha256=w9zv66rZDKgwuzETCkvYefs2gcA1VEzvtQXfBt-KOSk,81
39
+ eotdl/src/usecases/datasets/DownloadDataset.py,sha256=tZ0jamae0HBU3T9jnum3Qh9jruvfRBSToW07-GjNj2A,788
40
+ eotdl/src/usecases/datasets/IngestDataset.py,sha256=d2H5nPXsEj-LhZpWGwNDSPs9uYNXRO2V07xsTFygQDc,953
41
+ eotdl/src/usecases/datasets/IngestLargeDataset.py,sha256=Q4sR2wyRyUsCwgFucKoNPc2SpbmX74IDXROmSwwyT4Q,1428
42
42
  eotdl/src/usecases/datasets/IngestLargeDatasetParallel.py,sha256=egcl54K_Oi0BUSJeIdoQSl8BczBQXY1kCf3SWiLuc6s,1595
43
43
  eotdl/src/usecases/datasets/RetrieveDataset.py,sha256=rmoSLllsPx3PCnIxLhR8yiibbk6xS1Pz9yvZ0RxhsHg,421
44
44
  eotdl/src/usecases/datasets/RetrieveDatasets.py,sha256=NMtmVA4Ma6TxJwGbyW2KPgAEN4RV8SWRzKVivqbt0Lo,427
45
- eotdl/src/usecases/datasets/UpdateDataset.py,sha256=E_YQuVMsbsfjEY7DkyfdUbbKdgzTMa70GB4Mui38CYM,944
46
- eotdl/src/usecases/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ eotdl/src/usecases/datasets/UpdateDataset.py,sha256=BD3qMOzh_bk5QAh_JB_cEA92bTilm5EN6f2sWf0QXx0,965
46
+ eotdl/src/usecases/datasets/__init__.py,sha256=bcUQ867J4YeQcT6nMod7yqyZ6fTYHcUBioXmMcspE80,270
47
47
  eotdl/src/utils.py,sha256=I_s5wKnyDmjzsKWlDSsnFVYnJn6YyJwlqf0rxHKe-Ac,479
48
48
  eotdl/tools/__init__.py,sha256=pyWj9kl-0p-KSUSZ7BV8BoSYxj7j-OfGKt9NE3qw_3Q,277
49
49
  eotdl/tools/sen12floods/__init__.py,sha256=J3McIaLi_Bp5-EIVfFWHwm0qYx7PtWydCrWwju8xFW0,215
50
50
  eotdl/tools/sen12floods/tools.py,sha256=rPOkwZw_CdecfREUPMrjYCu1jI2OBhk_8PHL2MNTdV8,8124
51
51
  eotdl/tools/stac.py,sha256=s-Js3wkqFIQwbWlr4hNTtkUgX_3Suf4A2eUUQEaE-30,636
52
- eotdl-2023.6.14.post8.dist-info/entry_points.txt,sha256=s6sfxUfRrSX2IP2UbrzTFTvRCtLgw3_OKcHlOKf_5F8,39
53
- eotdl-2023.6.14.post8.dist-info/WHEEL,sha256=gSF7fibx4crkLz_A-IKR6kcuq0jJ64KNCkG8_bcaEao,88
54
- eotdl-2023.6.14.post8.dist-info/METADATA,sha256=XKHxKGs13mak7qyzsBXXAXpMRwFJapkmfzVHP86YxLE,745
55
- eotdl-2023.6.14.post8.dist-info/RECORD,,
52
+ eotdl-2023.6.14.post10.dist-info/entry_points.txt,sha256=s6sfxUfRrSX2IP2UbrzTFTvRCtLgw3_OKcHlOKf_5F8,39
53
+ eotdl-2023.6.14.post10.dist-info/WHEEL,sha256=gSF7fibx4crkLz_A-IKR6kcuq0jJ64KNCkG8_bcaEao,88
54
+ eotdl-2023.6.14.post10.dist-info/METADATA,sha256=UJKGSc9SppEVrHJaEQEhDjlHVG2R2Lkin8nHgknkHrI,746
55
+ eotdl-2023.6.14.post10.dist-info/RECORD,,