esgpull 0.9.1__py3-none-any.whl → 0.9.3__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.
- esgpull/cli/__init__.py +2 -2
- esgpull/cli/index_nodes.py +94 -0
- esgpull/cli/plugins.py +1 -1
- esgpull/cli/search.py +22 -8
- esgpull/cli/update.py +1 -0
- esgpull/config.py +211 -295
- esgpull/constants.py +1 -0
- esgpull/context.py +69 -11
- esgpull/esgpull.py +0 -5
- esgpull/migrations/versions/0.9.2_update_tables.py +28 -0
- esgpull/migrations/versions/0.9.3_update_tables.py +28 -0
- esgpull/plugin.py +25 -21
- esgpull/processor.py +0 -4
- esgpull/tui.py +5 -5
- esgpull/utils.py +0 -17
- {esgpull-0.9.1.dist-info → esgpull-0.9.3.dist-info}/METADATA +3 -2
- {esgpull-0.9.1.dist-info → esgpull-0.9.3.dist-info}/RECORD +20 -19
- esgpull/auth.py +0 -181
- esgpull/cli/login.py +0 -56
- {esgpull-0.9.1.dist-info → esgpull-0.9.3.dist-info}/WHEEL +0 -0
- {esgpull-0.9.1.dist-info → esgpull-0.9.3.dist-info}/entry_points.txt +0 -0
- {esgpull-0.9.1.dist-info → esgpull-0.9.3.dist-info}/licenses/LICENSE +0 -0
esgpull/cli/__init__.py
CHANGED
|
@@ -8,7 +8,7 @@ from esgpull.cli.add import add
|
|
|
8
8
|
from esgpull.cli.config import config
|
|
9
9
|
from esgpull.cli.convert import convert
|
|
10
10
|
from esgpull.cli.download import download
|
|
11
|
-
from esgpull.cli.
|
|
11
|
+
from esgpull.cli.index_nodes import index_nodes
|
|
12
12
|
from esgpull.cli.plugins import plugins
|
|
13
13
|
from esgpull.cli.remove import remove
|
|
14
14
|
from esgpull.cli.retry import retry
|
|
@@ -40,7 +40,6 @@ SUBCOMMANDS: list[click.Command] = [
|
|
|
40
40
|
# get,
|
|
41
41
|
self,
|
|
42
42
|
# install,
|
|
43
|
-
login,
|
|
44
43
|
plugins,
|
|
45
44
|
remove,
|
|
46
45
|
retry,
|
|
@@ -51,6 +50,7 @@ SUBCOMMANDS: list[click.Command] = [
|
|
|
51
50
|
status,
|
|
52
51
|
# # stats,
|
|
53
52
|
update,
|
|
53
|
+
index_nodes,
|
|
54
54
|
]
|
|
55
55
|
|
|
56
56
|
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections import OrderedDict
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
from click.exceptions import Abort, Exit
|
|
7
|
+
|
|
8
|
+
from esgpull import Context
|
|
9
|
+
from esgpull.cli.decorators import groups, opts
|
|
10
|
+
from esgpull.cli.utils import init_esgpull, totable
|
|
11
|
+
from esgpull.models import Query
|
|
12
|
+
from esgpull.tui import Verbosity, logger
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def check_node(c: Context, node: str) -> bool:
|
|
16
|
+
try:
|
|
17
|
+
c.probe(index_node=node)
|
|
18
|
+
return True
|
|
19
|
+
except:
|
|
20
|
+
return False
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def find_nodes(c: Context, node: str) -> list[str]:
|
|
24
|
+
try:
|
|
25
|
+
hints = c.hints(
|
|
26
|
+
Query(), file=False, index_node=node, facets=["index_node"]
|
|
27
|
+
)
|
|
28
|
+
return list(hints[0]["index_node"])
|
|
29
|
+
except:
|
|
30
|
+
return []
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@click.command()
|
|
34
|
+
@groups.json_yaml
|
|
35
|
+
@opts.record
|
|
36
|
+
@opts.verbosity
|
|
37
|
+
def index_nodes(
|
|
38
|
+
## json_yaml
|
|
39
|
+
json: bool,
|
|
40
|
+
yaml: bool,
|
|
41
|
+
record: bool,
|
|
42
|
+
verbosity: Verbosity,
|
|
43
|
+
) -> None:
|
|
44
|
+
"""
|
|
45
|
+
Test index nodes for their current status
|
|
46
|
+
"""
|
|
47
|
+
esg = init_esgpull(
|
|
48
|
+
verbosity,
|
|
49
|
+
safe=False,
|
|
50
|
+
record=record,
|
|
51
|
+
)
|
|
52
|
+
with esg.ui.logging("scan", onraise=Abort):
|
|
53
|
+
node_status: dict[str, bool] = {}
|
|
54
|
+
nodes = [
|
|
55
|
+
"esgf-node.ipsl.upmc.fr",
|
|
56
|
+
"esgf-data.dkrz.de",
|
|
57
|
+
"esgf.ceda.ac.uk",
|
|
58
|
+
"esgf-node.ornl.gov/esgf-1-5-bridge",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
esg.config.api.http_timeout = 3
|
|
62
|
+
with esg.ui.spinner("Fetching index nodes status"):
|
|
63
|
+
while True:
|
|
64
|
+
if not nodes:
|
|
65
|
+
break
|
|
66
|
+
node = nodes.pop()
|
|
67
|
+
if node in node_status:
|
|
68
|
+
continue
|
|
69
|
+
logger.info(f"check: {node}")
|
|
70
|
+
node_status[node] = check_node(esg.context, node)
|
|
71
|
+
logger.info(f"{node}\tok: {node_status[node]}")
|
|
72
|
+
for node in find_nodes(esg.context, node):
|
|
73
|
+
if node not in node_status:
|
|
74
|
+
nodes.append(node)
|
|
75
|
+
logger.info(f"found index_node: {node}")
|
|
76
|
+
if json:
|
|
77
|
+
esg.ui.print(node_status, json=True)
|
|
78
|
+
elif yaml:
|
|
79
|
+
esg.ui.print(node_status, yaml=True)
|
|
80
|
+
else:
|
|
81
|
+
table = [
|
|
82
|
+
OrderedDict(
|
|
83
|
+
[
|
|
84
|
+
("node", node),
|
|
85
|
+
(
|
|
86
|
+
"status",
|
|
87
|
+
"[green]OK" if status else "[red]no response",
|
|
88
|
+
),
|
|
89
|
+
]
|
|
90
|
+
)
|
|
91
|
+
for node, status in node_status.items()
|
|
92
|
+
]
|
|
93
|
+
esg.ui.print(totable(table))
|
|
94
|
+
esg.ui.raise_maybe_record(Exit(0))
|
esgpull/cli/plugins.py
CHANGED
|
@@ -337,7 +337,7 @@ from datetime import datetime
|
|
|
337
337
|
from pathlib import Path
|
|
338
338
|
from logging import Logger
|
|
339
339
|
|
|
340
|
-
from esgpull.models import File, Query
|
|
340
|
+
from esgpull.models import Dataset, File, Query
|
|
341
341
|
from esgpull.plugin import Event, on
|
|
342
342
|
|
|
343
343
|
# Specify version compatibility (optional)
|
esgpull/cli/search.py
CHANGED
|
@@ -7,6 +7,7 @@ from click.exceptions import Abort, Exit
|
|
|
7
7
|
|
|
8
8
|
from esgpull.cli.decorators import args, groups, opts
|
|
9
9
|
from esgpull.cli.utils import filter_keys, init_esgpull, parse_query, totable
|
|
10
|
+
from esgpull.context import IndexNode
|
|
10
11
|
from esgpull.exceptions import PageIndexError
|
|
11
12
|
from esgpull.graph import Graph
|
|
12
13
|
from esgpull.models import Query
|
|
@@ -98,6 +99,7 @@ def search(
|
|
|
98
99
|
esg.ui.raise_maybe_record(Exit(0))
|
|
99
100
|
esg.graph.add(query, force=True)
|
|
100
101
|
query = esg.graph.expand(query.sha)
|
|
102
|
+
esg.context.probe()
|
|
101
103
|
hits = esg.context.hits(
|
|
102
104
|
query,
|
|
103
105
|
file=file,
|
|
@@ -135,14 +137,26 @@ def search(
|
|
|
135
137
|
esg.ui.raise_maybe_record(Exit(0))
|
|
136
138
|
if facets_hints:
|
|
137
139
|
not_distrib_query = query << Query(options=dict(distrib=False))
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
index = IndexNode(esg.config.api.index_node)
|
|
141
|
+
if index.is_bridge():
|
|
142
|
+
first_file_result = esg.context.search_as_queries(
|
|
143
|
+
not_distrib_query,
|
|
144
|
+
file=True,
|
|
145
|
+
max_hits=1,
|
|
146
|
+
date_from=date_from,
|
|
147
|
+
date_to=date_to,
|
|
148
|
+
)
|
|
149
|
+
first_file = first_file_result[0].selection.asdict()
|
|
150
|
+
esg.ui.print(list(first_file), json=True)
|
|
151
|
+
else:
|
|
152
|
+
facet_counts = esg.context.hints(
|
|
153
|
+
not_distrib_query,
|
|
154
|
+
file=file,
|
|
155
|
+
facets=["*"],
|
|
156
|
+
date_from=date_from,
|
|
157
|
+
date_to=date_to,
|
|
158
|
+
)
|
|
159
|
+
esg.ui.print(list(facet_counts[0]), json=True)
|
|
146
160
|
esg.ui.raise_maybe_record(Exit(0))
|
|
147
161
|
if hints is not None:
|
|
148
162
|
facet_counts = esg.context.hints(
|