esgpull 0.6.3__py3-none-any.whl → 0.6.5__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.
@@ -0,0 +1,25 @@
1
+ """update tables
2
+
3
+ Revision ID: 0.6.4
4
+ Revises: 0.6.3
5
+ Create Date: 2024-07-09 11:04:30.762439
6
+
7
+ """
8
+
9
+ # revision identifiers, used by Alembic.
10
+ revision = "0.6.4"
11
+ down_revision = "0.6.3"
12
+ branch_labels = None
13
+ depends_on = None
14
+
15
+
16
+ def upgrade() -> None:
17
+ # ### commands auto generated by Alembic - please adjust! ###
18
+ pass
19
+ # ### end Alembic commands ###
20
+
21
+
22
+ def downgrade() -> None:
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ pass
25
+ # ### end Alembic commands ###
@@ -0,0 +1,25 @@
1
+ """update tables
2
+
3
+ Revision ID: 0.6.5
4
+ Revises: 0.6.4
5
+ Create Date: 2024-07-09 16:29:09.389585
6
+
7
+ """
8
+
9
+ # revision identifiers, used by Alembic.
10
+ revision = "0.6.5"
11
+ down_revision = "0.6.4"
12
+ branch_labels = None
13
+ depends_on = None
14
+
15
+
16
+ def upgrade() -> None:
17
+ # ### commands auto generated by Alembic - please adjust! ###
18
+ pass
19
+ # ### end Alembic commands ###
20
+
21
+
22
+ def downgrade() -> None:
23
+ # ### commands auto generated by Alembic - please adjust! ###
24
+ pass
25
+ # ### end Alembic commands ###
esgpull/processor.py CHANGED
@@ -41,7 +41,6 @@ class Task:
41
41
  def __init__(
42
42
  self,
43
43
  config: Config,
44
- auth: Auth,
45
44
  fs: Filesystem,
46
45
  # *,
47
46
  # url: str | None = None,
@@ -49,7 +48,6 @@ class Task:
49
48
  start_callbacks: list[Callback] | None = None,
50
49
  ) -> None:
51
50
  self.config = config
52
- self.auth = auth
53
51
  self.fs = fs
54
52
  self.ctx = DownloadCtx(file)
55
53
  if not self.config.download.disable_checksum:
@@ -61,16 +59,6 @@ class Task:
61
59
  # else:
62
60
  # raise ValueError("no arguments")
63
61
  self.downloader = Simple()
64
- msg: str | None = None
65
- if not default_ssl_context_loaded:
66
- msg = load_default_ssl_context()
67
- self.ssl_context: ssl.SSLContext | bool
68
- if self.config.download.disable_ssl:
69
- self.ssl_context = False
70
- else:
71
- if msg is not None:
72
- logger.info(msg)
73
- self.ssl_context = default_ssl_context
74
62
  if start_callbacks is None:
75
63
  self.start_callbacks = []
76
64
  else:
@@ -93,20 +81,13 @@ class Task:
93
81
  # raise ValueError(f"{url} is not valid")
94
82
 
95
83
  async def stream(
96
- self, semaphore: asyncio.Semaphore
84
+ self,
85
+ semaphore: asyncio.Semaphore,
86
+ client: AsyncClient,
97
87
  ) -> AsyncIterator[Result]:
98
88
  ctx = self.ctx
99
89
  try:
100
- async with (
101
- semaphore,
102
- self.fs.open(ctx.file) as file_obj,
103
- AsyncClient(
104
- follow_redirects=True,
105
- cert=self.auth.cert,
106
- verify=self.ssl_context,
107
- timeout=self.config.download.http_timeout,
108
- ) as client,
109
- ):
90
+ async with semaphore, self.fs.open(ctx.file) as file_obj:
110
91
  for callback in self.start_callbacks:
111
92
  callback()
112
93
  stream = self.downloader.stream(
@@ -117,6 +98,7 @@ class Task:
117
98
  async for ctx in stream:
118
99
  if ctx.chunk is not None:
119
100
  await file_obj.write(ctx.chunk)
101
+ ctx.chunk = None
120
102
  if ctx.error:
121
103
  err = DownloadSizeError(ctx.completed, ctx.file.size)
122
104
  yield Err(ctx, err)
@@ -129,7 +111,8 @@ class Task:
129
111
  HTTPError,
130
112
  DownloadSizeError,
131
113
  GeneratorExit,
132
- ssl.SSLError
114
+ ssl.SSLError,
115
+ FileNotFoundError,
133
116
  # KeyboardInterrupt,
134
117
  ) as err:
135
118
  yield Err(ctx, err)
@@ -145,13 +128,23 @@ class Processor:
145
128
  start_callbacks: dict[str, list[Callback]],
146
129
  ) -> None:
147
130
  self.config = config
131
+ self.auth = auth
148
132
  self.fs = fs
149
133
  self.files = list(filter(self.should_download, files))
150
134
  self.tasks = []
135
+ msg: str | None = None
136
+ if not default_ssl_context_loaded:
137
+ msg = load_default_ssl_context()
138
+ self.ssl_context: ssl.SSLContext | bool
139
+ if self.config.download.disable_ssl:
140
+ self.ssl_context = False
141
+ else:
142
+ if msg is not None:
143
+ logger.info(msg)
144
+ self.ssl_context = default_ssl_context
151
145
  for file in files:
152
146
  task = Task(
153
147
  config=config,
154
- auth=auth,
155
148
  fs=fs,
156
149
  file=file,
157
150
  start_callbacks=start_callbacks[file.sha],
@@ -166,7 +159,13 @@ class Processor:
166
159
 
167
160
  async def process(self) -> AsyncIterator[Result]:
168
161
  semaphore = asyncio.Semaphore(self.config.download.max_concurrent)
169
- streams = [task.stream(semaphore) for task in self.tasks]
170
- async with merge(*streams).stream() as stream:
171
- async for result in stream:
172
- yield result
162
+ async with AsyncClient(
163
+ follow_redirects=True,
164
+ cert=self.auth.cert,
165
+ verify=self.ssl_context,
166
+ timeout=self.config.download.http_timeout,
167
+ ) as client:
168
+ streams = [task.stream(semaphore, client) for task in self.tasks]
169
+ async with merge(*streams).stream() as stream:
170
+ async for result in stream:
171
+ yield result
esgpull/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.6.3"
1
+ __version__ = "0.6.5"
@@ -1,36 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: esgpull
3
- Version: 0.6.3
3
+ Version: 0.6.5
4
4
  Summary: ESGF data discovery, download, replication tool
5
5
  Author-Email: Sven Rodriguez <srodriguez@ipsl.fr>
6
- License: BSD 3-Clause License
7
-
8
- Copyright (c) 2023, Institut Pierre-Simon Laplace (IPSL) and contributors
9
-
10
- Redistribution and use in source and binary forms, with or without
11
- modification, are permitted provided that the following conditions are met:
12
-
13
- 1. Redistributions of source code must retain the above copyright notice, this
14
- list of conditions and the following disclaimer.
15
-
16
- 2. Redistributions in binary form must reproduce the above copyright notice,
17
- this list of conditions and the following disclaimer in the documentation
18
- and/or other materials provided with the distribution.
19
-
20
- 3. Neither the name of the copyright holder nor the names of its
21
- contributors may be used to endorse or promote products derived from
22
- this software without specific prior written permission.
23
-
24
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6
+ License: BSD-3-Clause
7
+ Classifier: License :: OSI Approved :: BSD License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
34
12
  Project-URL: Repository, https://github.com/ESGF/esgf-download
35
13
  Project-URL: Documentation, https://esgf.github.io/esgf-download/
36
14
  Requires-Python: >=3.10
@@ -1,7 +1,7 @@
1
- esgpull-0.6.3.dist-info/METADATA,sha256=8hz93j4mPbtVd1MXfDNuQKs98fJAHoJVeIfSa1-pqgI,4473
2
- esgpull-0.6.3.dist-info/WHEEL,sha256=vnE8JVcI2Wz7GRKorsPArnBdnW2SWKWGow5gu5tHlRU,90
3
- esgpull-0.6.3.dist-info/entry_points.txt,sha256=nfKsESeZyCiVD6dDCTCturf-vRnI-6GCuwqv9jxXCq8,46
4
- esgpull-0.6.3.dist-info/licenses/LICENSE,sha256=lUqGPGWDHHxjkUDuYgjLLY2XQXXn_EHU7fnrQWHGugc,1540
1
+ esgpull-0.6.5.dist-info/METADATA,sha256=vycdqEO7yU4ZlM-A_Db2By-LyaHl-QcqtGD3tnOd1Tc,2982
2
+ esgpull-0.6.5.dist-info/WHEEL,sha256=mbxFTmdEUhG7evcdMkR3aBt9SWcoFBJ4CDwnfguNegA,90
3
+ esgpull-0.6.5.dist-info/entry_points.txt,sha256=nfKsESeZyCiVD6dDCTCturf-vRnI-6GCuwqv9jxXCq8,46
4
+ esgpull-0.6.5.dist-info/licenses/LICENSE,sha256=lUqGPGWDHHxjkUDuYgjLLY2XQXXn_EHU7fnrQWHGugc,1540
5
5
  esgpull/__init__.py,sha256=XItFDIMNmFUNNcKtUgXdfmGwUIWt4AAv0a4mZkfj5P8,240
6
6
  esgpull/auth.py,sha256=QZ-l1ySLMP0fvuwYHRLv9FZYp1gqfju_eGaTMDByUxw,5205
7
7
  esgpull/cli/__init__.py,sha256=boqxa_ku266IcZ6GY-7fVA2T9GLku1e01TXe3aqZmR4,1630
@@ -14,7 +14,6 @@ esgpull/cli/download.py,sha256=3_Fm8JJYBWKs63oQ1OLaHJCv9ccbeY2gIW8SDasaYNE,2356
14
14
  esgpull/cli/facet.py,sha256=V1u-DxNkhswwSt0qpXvuHrCI_tE8jAJGEe6_fMhYbaM,584
15
15
  esgpull/cli/get.py,sha256=2WXL01Ri0P_2Rf1xrp9bnsrrxir6whxkAC0SnohjFpg,678
16
16
  esgpull/cli/install.py,sha256=fd8nKwIFvOivgn_gOGn7XIk1BB9LXnhQB47KuIIy5AU,2880
17
- esgpull/cli/link.py,sha256=hZ3p3AySsOUIsiA7lIdxEctw3A7ocCJgbjWcNx2dRVU,3372
18
17
  esgpull/cli/login.py,sha256=FZ63SsB4fCDixwf7gMUR697Dk89W1OvpgeadKE4IqEU,2153
19
18
  esgpull/cli/remove.py,sha256=p26hPhsgAgmAF4IsvjAI3jtzlIUq3k8Rxb0GTKYoEQM,2517
20
19
  esgpull/cli/retry.py,sha256=UVpAjW_N7l6RTJ-T5qXojwcXPzzjT7sDKb_wBdvavrg,1310
@@ -58,6 +57,8 @@ esgpull/migrations/versions/0.6.0_update_tables.py,sha256=10Ioi84QwEWIB9Mqz-ItEG
58
57
  esgpull/migrations/versions/0.6.1_update_tables.py,sha256=L4mkKlZUz4ftINwNeVNsPhk32QYMeoTie4B-GXVeKXw,493
59
58
  esgpull/migrations/versions/0.6.2_update_tables.py,sha256=LFUVgDhxSll9FpvNFm-idD5t-SI3R30IO7cTzvShLVI,493
60
59
  esgpull/migrations/versions/0.6.3_update_tables.py,sha256=ut4M0b90OWVB9pKSGTJ4Bl5cucXFJzRD4-WA_ego0WY,493
60
+ esgpull/migrations/versions/0.6.4_update_tables.py,sha256=PFALlSAjCFOqqoQgjq2TF0HjGc22fVdStMK2NNNa3Yk,493
61
+ esgpull/migrations/versions/0.6.5_update_tables.py,sha256=NYO8vnS4h_g4Co4M1CJibB2WYLqmVAy6ZaApFk-do3c,493
61
62
  esgpull/models/__init__.py,sha256=rfa1yGLVDahFrnhq_8TPGzr7_oeBOFKNVD9EF0slUtY,725
62
63
  esgpull/models/base.py,sha256=3nbR2lYMHWfovWz4EiAJ2bIvKpMadRvYZDdMRQDvN7M,1237
63
64
  esgpull/models/dataset.py,sha256=1fOIVYIWKK5BivqvBpjfxrNpy9VfUHZng9Yc6ipPK1Q,905
@@ -70,11 +71,10 @@ esgpull/models/sql.py,sha256=T2whCvz_MFb0tY5Ij5xcFlZ4TxrS0JT1rRU_gd2qVsg,7041
70
71
  esgpull/models/synda_file.py,sha256=6o5unPhzVJGnbpA2MxcS0r-hrBwocHYVnLrqjSGtmuk,2387
71
72
  esgpull/models/tag.py,sha256=5CQDB9rAeCqog63ec9LPFN46HOFNkHPy-maY4gkBQ3E,461
72
73
  esgpull/models/utils.py,sha256=exwlIlIKYjhhfUE82w1kU_HeSQOSY97PTvpkhW0udMA,1631
73
- esgpull/presets.py,sha256=hMFY2QfcLY9icuer5SK_M7Oqbj_GSEGCYQiwhNhFqLA,336
74
- esgpull/processor.py,sha256=je2GS8eokqskpQx_qRh62BDr7lg8QfpjfM0jW9uJDDU,5444
74
+ esgpull/processor.py,sha256=noenWExukON2P4klMN8Vt1ALzApmvc5gpsFqd7J5g78,5446
75
75
  esgpull/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  esgpull/result.py,sha256=f64l9gPFpFWgctmHVYrNWJvuXXB1sxpxXzJEIssLXxc,1020
77
77
  esgpull/tui.py,sha256=MG3VULh8uTrRspw_kFuhunmHqscO9Xd7PS7MG9WyvMY,10395
78
78
  esgpull/utils.py,sha256=eKipKCqj15dzCAqs1o7x5O1XClWPmDEM-qSvNwGZmXY,1233
79
- esgpull/version.py,sha256=zYiFHqR7JwbvdK9dvKrh-RTNfUqjHUwC4CTcFAPVYLc,22
80
- esgpull-0.6.3.dist-info/RECORD,,
79
+ esgpull/version.py,sha256=KDgkBrBsBSUzbLgrOZ89YsNN06fU4j5bmcuEwo6q5pg,22
80
+ esgpull-0.6.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.3.0)
2
+ Generator: pdm-backend (2.3.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
esgpull/cli/link.py DELETED
@@ -1,105 +0,0 @@
1
- # from __future__ import annotations
2
-
3
- # import click
4
- # from click.exceptions import Abort, Exit
5
-
6
- # from esgpull import Esgpull
7
- # from esgpull.cli.decorators import args, opts
8
- # from esgpull.cli.utils import get_queries, valid_name_tag
9
- # from esgpull.graph import Graph
10
- # from esgpull.tui import Verbosity
11
-
12
-
13
- # @click.command()
14
- # @args.query_id
15
- # @opts.tag
16
- # @opts.children
17
- # @opts.verbosity
18
- # def link(
19
- # query_id: str | None,
20
- # tag: str | None,
21
- # children: bool,
22
- # verbosity: Verbosity,
23
- # ) -> None:
24
- # """
25
- # Link known files to query/tag.
26
- # Offline mode to avoid searching esgf ?
27
- # """
28
- # esg = Esgpull(verbosity=verbosity)
29
- # with esg.ui.logging("remove", onraise=Abort):
30
- # if query_id is None and tag is None:
31
- # raise click.UsageError("No query or tag provided.")
32
- # if not valid_name_tag(esg.graph, esg.ui, query_id, tag):
33
- # raise Exit(1)
34
- # queries = get_queries(
35
- # esg.graph,
36
- # query_id,
37
- # tag,
38
- # children=children,
39
- # )
40
- # nb = len(queries)
41
- # ies = "ies" if nb > 1 else "y"
42
- # graph = Graph(None)
43
- # graph.add(*queries)
44
- # esg.ui.print(graph)
45
- # msg = f"Remove {nb} quer{ies}?"
46
- # if not esg.ui.ask(msg, default=True):
47
- # raise Abort
48
- # for query in queries:
49
- # if not children and esg.graph.get_children(query.sha):
50
- # esg.ui.print(
51
- # ":stop_sign: Some queries block "
52
- # f"removal of {query.rich_name}."
53
- # )
54
- # if esg.ui.ask("Show blocking queries?", default=False):
55
- # esg.ui.print(esg.graph.subgraph(query, children=True))
56
- # raise Exit(1)
57
- # esg.db.delete(*queries)
58
- # esg.ui.print(":+1:")
59
-
60
-
61
- # @click.command()
62
- # @args.query_id
63
- # @opts.tag
64
- # @opts.children
65
- # @opts.verbosity
66
- # def unlink(
67
- # query_id: str | None,
68
- # tag: str | None,
69
- # children: bool,
70
- # verbosity: Verbosity,
71
- # ) -> None:
72
- # """
73
- # Unlink files that were associated to query/tag
74
- # """
75
- # esg = Esgpull(verbosity=verbosity)
76
- # with esg.ui.logging("remove", onraise=Abort):
77
- # if query_id is None and tag is None:
78
- # raise click.UsageError("No query or tag provided.")
79
- # if not valid_name_tag(esg.graph, esg.ui, query_id, tag):
80
- # raise Exit(1)
81
- # queries = get_queries(
82
- # esg.graph,
83
- # query_id,
84
- # tag,
85
- # children=children,
86
- # )
87
- # nb = len(queries)
88
- # ies = "ies" if nb > 1 else "y"
89
- # graph = Graph(None)
90
- # graph.add(*queries)
91
- # esg.ui.print(graph)
92
- # msg = f"Remove {nb} quer{ies}?"
93
- # if not esg.ui.ask(msg, default=True):
94
- # raise Abort
95
- # for query in queries:
96
- # if not children and esg.graph.get_children(query.sha):
97
- # esg.ui.print(
98
- # ":stop_sign: Some queries block "
99
- # f"removal of {query.rich_name}."
100
- # )
101
- # if esg.ui.ask("Show blocking queries?", default=False):
102
- # esg.ui.print(esg.graph.subgraph(query, children=True))
103
- # raise Exit(1)
104
- # esg.db.delete(*queries)
105
- # esg.ui.print(":+1:")
esgpull/presets.py DELETED
@@ -1,13 +0,0 @@
1
- # from esgpull.models import Query
2
-
3
-
4
- # IPCC_SCENARIOS = Query(
5
- # select=dict(
6
- # query=(
7
- # "experiment:(rcp26 rcp45 rcp60 rcp85) OR "
8
- # "experiment_id:(ssp119 ssp126 ssp245 ssp370 ssp460 ssp585)"
9
- # )
10
- # )
11
- # )
12
-
13
- # TEMPERATURE = Query(select=dict(variable=["tas", "tos", "tasmin", "tasmax"]))