dao-scripts 1.4.5__py3-none-any.whl → 1.5.0__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.
- dao_analyzer/cache_scripts/_version.py +2 -2
- dao_analyzer/cache_scripts/common/thegraph.py +40 -3
- dao_analyzer/cache_scripts/utils/uploadDataWarehouse.py +1 -0
- {dao_scripts-1.4.5.dist-info → dao_scripts-1.5.0.dist-info}/METADATA +1 -1
- {dao_scripts-1.4.5.dist-info → dao_scripts-1.5.0.dist-info}/RECORD +11 -11
- /dao_scripts-1.4.5-py3.12-nspkg.pth → /dao_scripts-1.5.0-py3.12-nspkg.pth +0 -0
- {dao_scripts-1.4.5.dist-info → dao_scripts-1.5.0.dist-info}/LICENSE +0 -0
- {dao_scripts-1.4.5.dist-info → dao_scripts-1.5.0.dist-info}/WHEEL +0 -0
- {dao_scripts-1.4.5.dist-info → dao_scripts-1.5.0.dist-info}/entry_points.txt +0 -0
- {dao_scripts-1.4.5.dist-info → dao_scripts-1.5.0.dist-info}/namespace_packages.txt +0 -0
- {dao_scripts-1.4.5.dist-info → dao_scripts-1.5.0.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,7 @@ from typing import Optional, Callable, Any
|
|
2
2
|
from abc import ABC, abstractmethod
|
3
3
|
|
4
4
|
from gql.dsl import DSLField
|
5
|
+
from graphql.language import visit, Visitor
|
5
6
|
|
6
7
|
import pandas as pd
|
7
8
|
|
@@ -32,6 +33,34 @@ def partial_query(q: Callable[..., DSLField], w: dict[str, Any]) -> Callable[...
|
|
32
33
|
return q(**add_where(kwargs, **w))
|
33
34
|
return wrapper
|
34
35
|
|
36
|
+
class ColumnsVisitor(Visitor):
|
37
|
+
def __init__(self):
|
38
|
+
super().__init__()
|
39
|
+
self.columns = []
|
40
|
+
self._bases = []
|
41
|
+
|
42
|
+
def enter_field(self, node, *args):
|
43
|
+
self._bases.append(node)
|
44
|
+
|
45
|
+
def leave_field(self, node, *args):
|
46
|
+
self._bases.pop()
|
47
|
+
|
48
|
+
def leave_selection_set(self, node, *_args):
|
49
|
+
base = ".".join([x.name.value for x in self._bases])
|
50
|
+
for s in node.selections:
|
51
|
+
# Skip non-leaf nodes
|
52
|
+
if s.selection_set:
|
53
|
+
continue
|
54
|
+
name = s.name.value
|
55
|
+
fullname = ".".join([base, name]) if base else name
|
56
|
+
self.columns.append(fullname)
|
57
|
+
|
58
|
+
def get_columns_from_query(q: DSLField) -> list[str]:
|
59
|
+
c = ColumnsVisitor()
|
60
|
+
# We use selection_set directly to avoid putting the name of the query
|
61
|
+
# i.e: returning id instead of moloches.id
|
62
|
+
visit(q.ast_field.selection_set, c)
|
63
|
+
return c.columns
|
35
64
|
|
36
65
|
class TheGraphCollector(NetworkCollector, UpdatableCollector, ABC):
|
37
66
|
def __init__(
|
@@ -83,7 +112,12 @@ class TheGraphCollector(NetworkCollector, UpdatableCollector, ABC):
|
|
83
112
|
return df
|
84
113
|
|
85
114
|
def transform_to_df(self, data: list[dict[str, Any]], skip_post: bool=False) -> pd.DataFrame:
|
86
|
-
|
115
|
+
if data:
|
116
|
+
df = pd.DataFrame.from_dict(pd.json_normalize(data))
|
117
|
+
else:
|
118
|
+
df = pd.DataFrame(columns=get_columns_from_query(self.query()))
|
119
|
+
|
120
|
+
assert set(df.columns) == set(get_columns_from_query(self.query()))
|
87
121
|
|
88
122
|
# For compatibility reasons we change from . to snake case
|
89
123
|
def dotsToSnakeCase(str: str) -> str:
|
@@ -147,7 +181,7 @@ class TheGraphCollector(NetworkCollector, UpdatableCollector, ABC):
|
|
147
181
|
|
148
182
|
return no_errors
|
149
183
|
|
150
|
-
def check_subgraph_health(self) -> bool:
|
184
|
+
def check_subgraph_health(self, check_deployment: bool = True) -> bool:
|
151
185
|
ds = self.schema
|
152
186
|
q = ds.Query._meta().select(
|
153
187
|
ds._Meta_.deployment,
|
@@ -165,8 +199,10 @@ class TheGraphCollector(NetworkCollector, UpdatableCollector, ABC):
|
|
165
199
|
self.logger.error('Subgraph has indexing errors')
|
166
200
|
return False
|
167
201
|
|
168
|
-
# TODO: Save the block info to use it later in run
|
169
202
|
self._indexer_block = Block(r['block'])
|
203
|
+
|
204
|
+
if not check_deployment:
|
205
|
+
return True
|
170
206
|
|
171
207
|
return self.check_deployment_health(r['deployment'])
|
172
208
|
|
@@ -188,6 +224,7 @@ class TheGraphCollector(NetworkCollector, UpdatableCollector, ABC):
|
|
188
224
|
|
189
225
|
def run(self, force=False, block: Optional[Block] = None, prev_block: Optional[Block] = None):
|
190
226
|
self.logger.info(f"Running The Graph collector with block: {block}, prev_block: {prev_block}")
|
227
|
+
assert self.check_subgraph_health(check_deployment=False) # Just update the _indexer_block
|
191
228
|
if block and self._indexer_block:
|
192
229
|
assert self._indexer_block >= block, f"Block number {block} is not indexed yet ({self._indexer_block})"
|
193
230
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
dao_scripts-1.
|
1
|
+
dao_scripts-1.5.0-py3.12-nspkg.pth,sha256=_0DzrHlnOxaQL5l1mMdHT1BtXZwXuB6MitMF5phpOhk,497
|
2
2
|
dao_analyzer/cache_scripts/__init__.py,sha256=Urg-J2hvyzGcgE2Z-ba71XpcHi1YlPZgex86OFSd_0A,116
|
3
3
|
dao_analyzer/cache_scripts/__main__.py,sha256=aNVhgUXjB4rzTefrX3d6dKeLOX3G_Ezs82pI8QCpwx0,61
|
4
|
-
dao_analyzer/cache_scripts/_version.py,sha256=
|
4
|
+
dao_analyzer/cache_scripts/_version.py,sha256=OYzqgMEgfFG0au4hzbEdgYI-c7Hxo3wdBtrpEjK1RoY,411
|
5
5
|
dao_analyzer/cache_scripts/argparser.py,sha256=uOBVdRxmgR8H0dZMu2AQyvro6WvkZFKUrf7vJ6Mvw48,3574
|
6
6
|
dao_analyzer/cache_scripts/config.py,sha256=6Ooh-SpTtNCHcl2sE637-XMCCCNZBmATJRyD_eguWr0,2180
|
7
7
|
dao_analyzer/cache_scripts/endpoints.json,sha256=JLkXgE7P7ZXpAsorIq0jCVCoPoK4_YeyfTgCmtPdo14,1278
|
@@ -16,17 +16,17 @@ dao_analyzer/cache_scripts/common/api_requester.py,sha256=objbyqKVVEfNFmffds3BC2
|
|
16
16
|
dao_analyzer/cache_scripts/common/blockscout.py,sha256=8-Xz7yhG8jtZsWBA2Ik3T3xqzDB0Bw89-EI8vcIB8Yk,5041
|
17
17
|
dao_analyzer/cache_scripts/common/common.py,sha256=Vj_UHqcCQRiKBwCV1skVTZoDl-eGOtclI8ps28BrD6A,10910
|
18
18
|
dao_analyzer/cache_scripts/common/cryptocompare.py,sha256=jaHdJ-X_AXEUdVRMVtyK6xwHNJdhTs2Ps44QMD0iuIY,2203
|
19
|
-
dao_analyzer/cache_scripts/common/thegraph.py,sha256=
|
19
|
+
dao_analyzer/cache_scripts/common/thegraph.py,sha256=XoGh7WbLkRiGyQQ-f70xh9vqU-9FenIBGjBhmap1PFo,8159
|
20
20
|
dao_analyzer/cache_scripts/daohaus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
dao_analyzer/cache_scripts/daohaus/runner.py,sha256=nQ7YN_Fbfx0KsHkq47hShwTS82jbo285x60Z-31vj8M,7549
|
22
22
|
dao_analyzer/cache_scripts/daostack/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
23
|
dao_analyzer/cache_scripts/daostack/runner.py,sha256=emjzhZzGMTRGHKljll_lX-uMsGwaIsZBSi4jV1Lsh8Y,10144
|
24
24
|
dao_analyzer/cache_scripts/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
|
-
dao_analyzer/cache_scripts/utils/uploadDataWarehouse.py,sha256=
|
26
|
-
dao_scripts-1.
|
27
|
-
dao_scripts-1.
|
28
|
-
dao_scripts-1.
|
29
|
-
dao_scripts-1.
|
30
|
-
dao_scripts-1.
|
31
|
-
dao_scripts-1.
|
32
|
-
dao_scripts-1.
|
25
|
+
dao_analyzer/cache_scripts/utils/uploadDataWarehouse.py,sha256=dBI_XKCWqblhCh-w0-ewoP82zHZBLxAH8SH44y8nxoU,4698
|
26
|
+
dao_scripts-1.5.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
27
|
+
dao_scripts-1.5.0.dist-info/METADATA,sha256=Wkg6MlLUhusCvLT-y7buIUb8a0Qg19_YB1_WvNJVsy0,8193
|
28
|
+
dao_scripts-1.5.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
29
|
+
dao_scripts-1.5.0.dist-info/entry_points.txt,sha256=dHhgA8pcQ2YbIlMuqPPSh7fiQkfHE8ioFPUcbBvXWDc,207
|
30
|
+
dao_scripts-1.5.0.dist-info/namespace_packages.txt,sha256=gbsNupMgtHQXOyBinbeLMo06f278s8My_9N-CrZh3Bk,13
|
31
|
+
dao_scripts-1.5.0.dist-info/top_level.txt,sha256=gbsNupMgtHQXOyBinbeLMo06f278s8My_9N-CrZh3Bk,13
|
32
|
+
dao_scripts-1.5.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|