cyberosa commited on
Commit
75bb2cf
·
1 Parent(s): 804c893

new daily data and new mech field for tools

Browse files
active_traders.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0f1a330f2a848851b0ccdcbfd02df84e1b0cd01cb0a9c19fa731f78f98d863ad
3
- size 81855
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d85374e556117a03039308754ec4187d8afc93a68a33b2afe856c745970bb105
3
+ size 83808
all_trades_profitability.parquet.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b6427dbd1315df12c34b6b3ec530911bf49775dd85ec8ffce8d6b481f346caaf
3
- size 8969394
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f95e9c4362ae7d94282fe31184a931f07ac64d9ebcf6b120a55b109a06b7ec8f
3
+ size 8757914
closed_market_metrics.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:749b0a4be0d2b7238d3665ec2c4452eff326dcc6466cee32a44c6a853c4ae5b2
3
- size 129119
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f16a737272d9e50721b01f829144fe8c5868209b40e29cb1a2d9ada2fed43114
3
+ size 129617
closed_markets_div.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b4a44ddfa26ef822e6014376e028af8793725aa03a2e0d70fcb50f3c6f9db854
3
- size 87049
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb9f5f47c5d3cdeb20a7a2e5925ceaae90c1b7402960889f2e2be01d1742887b
3
+ size 88059
daily_info.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:69a36fa8d368eb15ad1e917b52f419a63b35c3228ef24f3fc12b65817903bc05
3
- size 2124692
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4a2cf63954ccfebf9bf15019b6c669f7a7877ba39ab5a153c4a0e891d504e01
3
+ size 1846940
daily_mech_requests.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:dbb80628ea75af2b93b65326a8d02145d3262c3288fca33661a482a68083267d
3
- size 10354
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b26a59996fc1f4551f7eb699277bc20fb34a9b3e0288cfbd80d185157a654c8e
3
+ size 10433
error_by_markets.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:fb2ca33318018c7dd6e723dd7bc093e042710fad8091c47f4f1ffbe30bc2ab10
3
- size 11583
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8be709dee296b34c00ee9b910d9c387346a833f23da50ae3187a46207554ac3a
3
+ size 11880
invalid_trades.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c3791653969f9bc69c14458dc23192ca78b14b367f971338a91ebba3bbd443b3
3
- size 127404
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:147c82a40ceea1593936561f3c277b7b668e3e1e0c662d88613f46f30f7b8402
3
+ size 125231
retention_activity.parquet.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:aaffc3062ee8edce7d0d50e73141a783fc85ea15c92c3693bc4054b20511e320
3
- size 8528662
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8bd869ba65faeeb61b84c4236f3acd6ba172898f6fe13438f5944e87d5405dd1
3
+ size 8730982
scripts/get_mech_info.py CHANGED
@@ -23,6 +23,7 @@ from mech_request_utils import (
23
  get_ipfs_data,
24
  merge_json_files,
25
  )
 
26
 
27
  SUBGRAPH_HEADERS = {
28
  "Accept": "application/json, multipart/mixed",
@@ -149,7 +150,7 @@ def update_all_trades_parquet(new_trades_df: pd.DataFrame) -> pd.DataFrame:
149
  return merge_df
150
 
151
 
152
- def update_tools_parquet(new_tools_filename: pd.DataFrame):
153
  try:
154
  old_tools_df = pd.read_parquet(TMP_DIR / "tools.parquet")
155
  except Exception as e:
@@ -162,6 +163,13 @@ def update_tools_parquet(new_tools_filename: pd.DataFrame):
162
  print(f"Error reading new trades parquet file {e}")
163
  return None
164
 
 
 
 
 
 
 
 
165
  # merge two dataframes
166
  merge_df = pd.concat([old_tools_df, new_tools_df], ignore_index=True)
167
 
@@ -265,7 +273,7 @@ def get_mech_info_last_60_days() -> dict[str, Any]:
265
 
266
 
267
  @measure_execution_time
268
- def get_mech_events_since_last_run(logger):
269
  """Function to download only the new events since the last execution."""
270
 
271
  # Read the latest date from stored data
@@ -297,39 +305,49 @@ def get_mech_events_since_last_run(logger):
297
  last_block_number = get_last_block_number()
298
 
299
  # mech requests
 
 
300
  requests_dict, duplicatedReqId, nr_errors = collect_all_mech_requests(
301
  from_block=last_run_block_number,
302
  to_block=last_block_number,
303
- filename="new_mech_requests.json",
 
304
  )
 
305
  print(f"NUMBER OF MECH REQUEST ERRORS={nr_errors}")
306
  # mech delivers
 
 
307
  delivers_dict, duplicatedIds, nr_errors = collect_all_mech_delivers(
308
  from_block=last_run_block_number,
309
  to_block=last_block_number,
310
- filename="new_mech_delivers.json",
 
311
  )
 
312
  print(f"NUMBER OF MECH DELIVER ERRORS={nr_errors}")
313
  if delivers_dict is None:
314
  return None
315
  # clean delivers
316
- clean_mech_delivers("new_mech_requests.json", "new_mech_delivers.json")
317
 
318
  # solve duplicated requestIds
319
- block_map = fix_duplicate_requestIds(
320
- "new_mech_requests.json", "new_mech_delivers.json"
321
- )
 
322
  # merge the two files into one source
323
  not_found = merge_requests_delivers(
324
- "new_mech_requests.json", "new_mech_delivers.json", "new_merged_requests.json"
325
  )
326
 
327
  # Add ipfs contents
328
- get_ipfs_data("new_merged_requests.json", "new_tools_info.json", logger)
329
  return latest_timestamp
330
 
331
 
332
  if __name__ == "__main__":
333
- get_mech_events_since_last_run()
 
334
  # result = get_mech_info_last_60_days()
335
  # print(result)
 
23
  get_ipfs_data,
24
  merge_json_files,
25
  )
26
+ import logging
27
 
28
  SUBGRAPH_HEADERS = {
29
  "Accept": "application/json, multipart/mixed",
 
150
  return merge_df
151
 
152
 
153
+ def update_tools_parquet(new_tools_filename: str):
154
  try:
155
  old_tools_df = pd.read_parquet(TMP_DIR / "tools.parquet")
156
  except Exception as e:
 
163
  print(f"Error reading new trades parquet file {e}")
164
  return None
165
 
166
+ # Add the missing column to old_tools_df with NaN values
167
+ if (
168
+ "mech_address" in new_tools_df.columns
169
+ and "mech_address" not in old_tools_df.columns
170
+ ):
171
+ old_tools_df["mech_address"] = None
172
+
173
  # merge two dataframes
174
  merge_df = pd.concat([old_tools_df, new_tools_df], ignore_index=True)
175
 
 
273
 
274
 
275
  @measure_execution_time
276
+ def get_mech_events_since_last_run(logger, mech_sandbox: bool = False):
277
  """Function to download only the new events since the last execution."""
278
 
279
  # Read the latest date from stored data
 
305
  last_block_number = get_last_block_number()
306
 
307
  # mech requests
308
+ req_output_file = "new_mech_requests.json"
309
+
310
  requests_dict, duplicatedReqId, nr_errors = collect_all_mech_requests(
311
  from_block=last_run_block_number,
312
  to_block=last_block_number,
313
+ filename=req_output_file,
314
+ mech_sandbox=mech_sandbox,
315
  )
316
+
317
  print(f"NUMBER OF MECH REQUEST ERRORS={nr_errors}")
318
  # mech delivers
319
+ deli_output_file = "new_mech_delivers.json"
320
+
321
  delivers_dict, duplicatedIds, nr_errors = collect_all_mech_delivers(
322
  from_block=last_run_block_number,
323
  to_block=last_block_number,
324
+ filename=deli_output_file,
325
+ mech_sandbox=mech_sandbox,
326
  )
327
+
328
  print(f"NUMBER OF MECH DELIVER ERRORS={nr_errors}")
329
  if delivers_dict is None:
330
  return None
331
  # clean delivers
332
+ clean_mech_delivers(req_output_file, deli_output_file)
333
 
334
  # solve duplicated requestIds
335
+ block_map = fix_duplicate_requestIds(req_output_file, deli_output_file)
336
+
337
+ merged_output_file = "new_merged_requests.json"
338
+ tools_output_file = "new_tools_info.json"
339
  # merge the two files into one source
340
  not_found = merge_requests_delivers(
341
+ req_output_file, deli_output_file, merged_output_file
342
  )
343
 
344
  # Add ipfs contents
345
+ get_ipfs_data(merged_output_file, tools_output_file, logger)
346
  return latest_timestamp
347
 
348
 
349
  if __name__ == "__main__":
350
+ logger = logging.getLogger(__name__)
351
+ get_mech_events_since_last_run(logger, mech_sandbox=True)
352
  # result = get_mech_info_last_60_days()
353
  # print(result)
scripts/mech_request_utils.py CHANGED
@@ -54,7 +54,9 @@ BLOCKS_CHUNK_SIZE = 10000
54
  TEXT_ALIGNMENT = 30
55
  MINIMUM_WRITE_FILE_DELAY_SECONDS = 20
56
  MECH_FROM_BLOCK_RANGE = 50000
57
-
 
 
58
  last_write_time = 0.0
59
 
60
  REQUESTS_QUERY_FILTER = """
@@ -70,6 +72,20 @@ query requests_query($sender_not_in: [Bytes!], $id_gt: Bytes, $blockNumber_gte:
70
  }
71
  }
72
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  DELIVERS_QUERY_NO_FILTER = """
75
  query delivers_query($id_gt: Bytes, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
@@ -83,8 +99,23 @@ query delivers_query($id_gt: Bytes, $blockNumber_gte: BigInt, $blockNumber_lte:
83
  transactionHash
84
  }
85
  }
 
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  """
 
88
  DELIVERS_QUERY = """
89
  query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
90
  delivers(where: {requestId: $requestId, blockNumber_gte: $blockNumber_gte, blockNumber_lte: $blockNumber_lte}, orderBy: blockNumber, first: 1000) {
@@ -98,6 +129,20 @@ query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_
98
  }
99
  }
100
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
  MISSING_DELIVERS_QUERY = """
103
  query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
@@ -114,12 +159,37 @@ query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_
114
  """
115
 
116
 
117
- def collect_all_mech_requests(from_block: int, to_block: int, filename: str) -> Tuple:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  print(f"Fetching all mech requests from {from_block} to {to_block}")
120
  mech_requests = {}
121
  duplicated_reqIds = []
122
- mech_subgraph_url = MECH_SUBGRAPH_URL.substitute(subgraph_api_key=SUBGRAPH_API_KEY)
 
 
 
 
 
 
 
123
  transport = RequestsHTTPTransport(url=mech_subgraph_url)
124
  client = Client(transport=transport, fetch_schema_from_transport=True)
125
 
@@ -133,7 +203,7 @@ def collect_all_mech_requests(from_block: int, to_block: int, filename: str) ->
133
  "blockNumber_lte": str(to_block), # str
134
  }
135
  try:
136
- response = fetch_with_retry(client, REQUESTS_QUERY_FILTER, variables)
137
 
138
  items = response.get("requests", [])
139
 
@@ -174,13 +244,23 @@ def fetch_with_retry(client, query, variables, max_retries=5):
174
  time.sleep(wait_time)
175
 
176
 
177
- def collect_all_mech_delivers(from_block: int, to_block: int, filename: str) -> Tuple:
 
 
178
 
179
  print(f"Fetching all mech delivers from {from_block} to {to_block}")
180
 
181
  mech_delivers = {}
182
  duplicated_requestIds = []
183
- mech_subgraph_url = MECH_SUBGRAPH_URL.substitute(subgraph_api_key=SUBGRAPH_API_KEY)
 
 
 
 
 
 
 
 
184
  transport = RequestsHTTPTransport(url=mech_subgraph_url)
185
  client = Client(transport=transport, fetch_schema_from_transport=True)
186
  to_block = (
@@ -195,7 +275,7 @@ def collect_all_mech_delivers(from_block: int, to_block: int, filename: str) ->
195
  "blockNumber_lte": str(to_block), # str
196
  }
197
  try:
198
- response = fetch_with_retry(client, DELIVERS_QUERY_NO_FILTER, variables)
199
  items = response.get("delivers", [])
200
 
201
  if not items:
@@ -225,13 +305,23 @@ def collect_all_mech_delivers(from_block: int, to_block: int, filename: str) ->
225
  return mech_delivers, duplicated_requestIds, nr_errors
226
 
227
 
228
- def collect_missing_delivers(request_id: int, block_number: int) -> Dict[str, Any]:
 
 
229
  to_block = (
230
  block_number + MECH_FROM_BLOCK_RANGE
231
  ) # there is a delay between deliver and request
232
  print(f"Fetching all missing delivers from {block_number} to {to_block}")
233
  mech_delivers = {}
234
- mech_subgraph_url = MECH_SUBGRAPH_URL.substitute(subgraph_api_key=SUBGRAPH_API_KEY)
 
 
 
 
 
 
 
 
235
  transport = RequestsHTTPTransport(url=mech_subgraph_url)
236
  client = Client(transport=transport, fetch_schema_from_transport=True)
237
 
@@ -241,7 +331,7 @@ def collect_missing_delivers(request_id: int, block_number: int) -> Dict[str, An
241
  "blockNumber_lte": str(to_block), # str
242
  }
243
  try:
244
- response = fetch_with_retry(client, MISSING_DELIVERS_QUERY, variables)
245
  items = response.get("delivers", [])
246
  # If the user sends requests with the same values (tool, prompt, nonce) it
247
  # will generate the same requestId. Therefore, multiple items can be retrieved
 
54
  TEXT_ALIGNMENT = 30
55
  MINIMUM_WRITE_FILE_DELAY_SECONDS = 20
56
  MECH_FROM_BLOCK_RANGE = 50000
57
+ MECH_SANDBOX_SUBGRAPH = (
58
+ "https://api.studio.thegraph.com/query/81754/mech-sandbox/version/latest"
59
+ )
60
  last_write_time = 0.0
61
 
62
  REQUESTS_QUERY_FILTER = """
 
72
  }
73
  }
74
  """
75
+ REQUESTS_BY_MECH_QUERY_FILTER = """
76
+ query requests_query($sender_not_in: [Bytes!], $id_gt: Bytes, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
77
+ requests(where: {sender_not_in: $sender_not_in, id_gt: $id_gt, blockNumber_gte: $blockNumber_gte, blockNumber_lte: $blockNumber_lte}, orderBy: id, first: 1000) {
78
+ blockNumber
79
+ blockTimestamp
80
+ id
81
+ ipfsHash
82
+ requestId
83
+ sender
84
+ mech
85
+ transactionHash
86
+ }
87
+ }
88
+ """
89
 
90
  DELIVERS_QUERY_NO_FILTER = """
91
  query delivers_query($id_gt: Bytes, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
 
99
  transactionHash
100
  }
101
  }
102
+ """
103
 
104
+ DELIVERS_BY_MECH_QUERY_NO_FILTER = """
105
+ query delivers_query($id_gt: Bytes, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
106
+ delivers(where: {id_gt: $id_gt, blockNumber_gte: $blockNumber_gte, blockNumber_lte: $blockNumber_lte}, orderBy: id, first: 1000) {
107
+ blockNumber
108
+ blockTimestamp
109
+ id
110
+ ipfsHash
111
+ requestId
112
+ sender
113
+ mech
114
+ transactionHash
115
+ }
116
+ }
117
  """
118
+
119
  DELIVERS_QUERY = """
120
  query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
121
  delivers(where: {requestId: $requestId, blockNumber_gte: $blockNumber_gte, blockNumber_lte: $blockNumber_lte}, orderBy: blockNumber, first: 1000) {
 
129
  }
130
  }
131
  """
132
+ DELIVERS_BY_MECH_QUERY = """
133
+ query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
134
+ delivers(where: {requestId: $requestId, blockNumber_gte: $blockNumber_gte, blockNumber_lte: $blockNumber_lte}, orderBy: blockNumber, first: 1000) {
135
+ blockNumber
136
+ blockTimestamp
137
+ id
138
+ ipfsHash
139
+ requestId
140
+ sender
141
+ mech
142
+ transactionHash
143
+ }
144
+ }
145
+ """
146
 
147
  MISSING_DELIVERS_QUERY = """
148
  query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
 
159
  """
160
 
161
 
162
+ MISSING_BY_MECH_DELIVERS_QUERY = """
163
+ query delivers_query($requestId: BigInt, $blockNumber_gte: BigInt, $blockNumber_lte: BigInt) {
164
+ delivers(where: {requestId: $requestId, blockNumber_gte: $blockNumber_gte, blockNumber_lte: $blockNumber_lte}, orderBy: blockNumber, first: 1000) {
165
+ blockNumber
166
+ blockTimestamp
167
+ id
168
+ ipfsHash
169
+ requestId
170
+ sender
171
+ mech
172
+ transactionHash
173
+ }
174
+ }
175
+ """
176
+
177
+
178
+ def collect_all_mech_requests(
179
+ from_block: int, to_block: int, filename: str, mech_sandbox: bool = False
180
+ ) -> Tuple:
181
 
182
  print(f"Fetching all mech requests from {from_block} to {to_block}")
183
  mech_requests = {}
184
  duplicated_reqIds = []
185
+ if mech_sandbox:
186
+ mech_subgraph_url = MECH_SANDBOX_SUBGRAPH
187
+ request_query = REQUESTS_BY_MECH_QUERY_FILTER
188
+ else:
189
+ mech_subgraph_url = MECH_SUBGRAPH_URL.substitute(
190
+ subgraph_api_key=SUBGRAPH_API_KEY
191
+ )
192
+ request_query = REQUESTS_QUERY_FILTER
193
  transport = RequestsHTTPTransport(url=mech_subgraph_url)
194
  client = Client(transport=transport, fetch_schema_from_transport=True)
195
 
 
203
  "blockNumber_lte": str(to_block), # str
204
  }
205
  try:
206
+ response = fetch_with_retry(client, request_query, variables)
207
 
208
  items = response.get("requests", [])
209
 
 
244
  time.sleep(wait_time)
245
 
246
 
247
+ def collect_all_mech_delivers(
248
+ from_block: int, to_block: int, filename: str, mech_sandbox: bool = False
249
+ ) -> Tuple:
250
 
251
  print(f"Fetching all mech delivers from {from_block} to {to_block}")
252
 
253
  mech_delivers = {}
254
  duplicated_requestIds = []
255
+ if mech_sandbox:
256
+ mech_subgraph_url = MECH_SANDBOX_SUBGRAPH
257
+ deliver_query = DELIVERS_BY_MECH_QUERY_NO_FILTER
258
+ else:
259
+ mech_subgraph_url = MECH_SUBGRAPH_URL.substitute(
260
+ subgraph_api_key=SUBGRAPH_API_KEY
261
+ )
262
+ deliver_query = DELIVERS_QUERY_NO_FILTER
263
+
264
  transport = RequestsHTTPTransport(url=mech_subgraph_url)
265
  client = Client(transport=transport, fetch_schema_from_transport=True)
266
  to_block = (
 
275
  "blockNumber_lte": str(to_block), # str
276
  }
277
  try:
278
+ response = fetch_with_retry(client, deliver_query, variables)
279
  items = response.get("delivers", [])
280
 
281
  if not items:
 
305
  return mech_delivers, duplicated_requestIds, nr_errors
306
 
307
 
308
+ def collect_missing_delivers(
309
+ request_id: int, block_number: int, mech_sandbox: bool = False
310
+ ) -> Dict[str, Any]:
311
  to_block = (
312
  block_number + MECH_FROM_BLOCK_RANGE
313
  ) # there is a delay between deliver and request
314
  print(f"Fetching all missing delivers from {block_number} to {to_block}")
315
  mech_delivers = {}
316
+
317
+ if mech_sandbox:
318
+ mech_subgraph_url = MECH_SANDBOX_SUBGRAPH
319
+ missing_query = MISSING_BY_MECH_DELIVERS_QUERY
320
+ else:
321
+ mech_subgraph_url = MECH_SUBGRAPH_URL.substitute(
322
+ subgraph_api_key=SUBGRAPH_API_KEY
323
+ )
324
+ missing_query = MISSING_DELIVERS_QUERY
325
  transport = RequestsHTTPTransport(url=mech_subgraph_url)
326
  client = Client(transport=transport, fetch_schema_from_transport=True)
327
 
 
331
  "blockNumber_lte": str(to_block), # str
332
  }
333
  try:
334
+ response = fetch_with_retry(client, missing_query, variables)
335
  items = response.get("delivers", [])
336
  # If the user sends requests with the same values (tool, prompt, nonce) it
337
  # will generate the same requestId. Therefore, multiple items can be retrieved
scripts/pull_data.py CHANGED
@@ -96,7 +96,7 @@ def only_new_weekly_analysis():
96
  # Mech events ETL
97
  logging.info("Generating the mech json files")
98
  # get only new data
99
- latest_timestamp = get_mech_events_since_last_run(logger)
100
  if latest_timestamp == None:
101
  print("Error while getting the mech events")
102
  return
@@ -135,7 +135,7 @@ def only_new_weekly_analysis():
135
 
136
  save_historical_data()
137
  try:
138
- clean_old_data_from_parquet_files("2025-01-23")
139
  except Exception as e:
140
  print("Error cleaning the oldest information from parquet files")
141
  print(f"reason = {e}")
@@ -169,8 +169,8 @@ def restoring_trades_data(from_date: str, to_date: str):
169
 
170
 
171
  if __name__ == "__main__":
172
- # only_new_weekly_analysis()
173
- save_historical_data()
174
  # try:
175
  # clean_old_data_from_parquet_files("2025-01-23")
176
  # except Exception as e:
 
96
  # Mech events ETL
97
  logging.info("Generating the mech json files")
98
  # get only new data
99
+ latest_timestamp = get_mech_events_since_last_run(logger, mech_sandbox=True)
100
  if latest_timestamp == None:
101
  print("Error while getting the mech events")
102
  return
 
135
 
136
  save_historical_data()
137
  try:
138
+ clean_old_data_from_parquet_files("2025-01-26")
139
  except Exception as e:
140
  print("Error cleaning the oldest information from parquet files")
141
  print(f"reason = {e}")
 
169
 
170
 
171
  if __name__ == "__main__":
172
+ only_new_weekly_analysis()
173
+ # save_historical_data()
174
  # try:
175
  # clean_old_data_from_parquet_files("2025-01-23")
176
  # except Exception as e:
scripts/tools.py CHANGED
@@ -208,7 +208,7 @@ def parse_json_events(json_events: dict, keys_to_traverse: List[int]) -> pd.Data
208
  output["error"] = error_value
209
  output["error_message"] = error_message_value
210
  output["prompt_response"] = json_input["deliver"]["ipfsContents"]["prompt"]
211
- output["mech_address"] = json_input["deliver"]["sender"]
212
  p_yes_value, p_no_value, confidence_value, info_utility_value = (
213
  get_prediction_values(prediction_params)
214
  )
@@ -317,4 +317,7 @@ def generate_tools_file(input_filename: str, output_filename: str):
317
 
318
  if __name__ == "__main__":
319
 
320
- generate_tools_file()
 
 
 
 
208
  output["error"] = error_value
209
  output["error_message"] = error_message_value
210
  output["prompt_response"] = json_input["deliver"]["ipfsContents"]["prompt"]
211
+ output["mech_address"] = json_input["deliver"]["mech"]
212
  p_yes_value, p_no_value, confidence_value, info_utility_value = (
213
  get_prediction_values(prediction_params)
214
  )
 
317
 
318
  if __name__ == "__main__":
319
 
320
+ generate_tools_file(
321
+ input_filename="mechsandbox_tools_info.json",
322
+ output_filename="mechsandbox_tools.parquet",
323
+ )
service_map.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:77b4d92c14485e09f270c2538742ac508f345abdd225be796a213b212213c1ab
3
- size 193777
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:49a190affe8e9179edd8c80fb249b91c608853f2ef1df83735d3b25d1cac92e6
3
+ size 200308
tools_accuracy.csv CHANGED
@@ -1,13 +1,13 @@
1
  tool,tool_accuracy,total_requests,min,max
2
- claude-prediction-offline,63.23015175787642,58053,2025-01-23 00:02:25,2025-03-22 22:25:30
3
- claude-prediction-online,64.43582942256683,34307,2025-01-23 00:01:15,2025-03-23 01:42:25
4
- prediction-offline,53.15215124765413,158257,2025-01-23 00:00:20,2025-03-23 17:36:15
5
- prediction-offline-sme,53.21729365524986,8905,2025-01-23 00:14:45,2025-03-22 23:56:25
6
- prediction-online,44.550063371356146,4734,2025-01-23 08:01:20,2025-03-23 16:24:35
7
- prediction-online-sme,43.840451817860924,2833,2025-01-23 08:07:45,2025-03-22 18:15:50
8
- prediction-request-rag,46.47519582245431,383,2025-01-23 12:21:05,2025-03-21 19:28:50
9
- prediction-request-rag-claude,48.732394366197184,355,2025-01-23 12:07:25,2025-03-19 15:45:45
10
- prediction-request-reasoning,49.19531698100476,59278,2025-01-23 09:22:35,2025-03-22 18:27:30
11
- prediction-request-reasoning-claude,68.01242236024845,322,2025-01-23 09:59:40,2025-03-20 13:33:50
12
- prediction-url-cot-claude,54.12147505422994,922,2025-01-23 09:31:20,2025-03-21 23:32:05
13
- superforcaster,57.14131955656011,9291,2025-01-23 00:16:20,2025-03-23 19:24:40
 
1
  tool,tool_accuracy,total_requests,min,max
2
+ claude-prediction-offline,63.046214390810306,56411,2025-01-26 00:04:55,2025-03-25 23:13:55
3
+ claude-prediction-online,64.30493815960567,33069,2025-01-26 00:00:05,2025-03-26 01:19:40
4
+ prediction-offline,53.52954942970462,162372,2025-01-26 00:00:40,2025-03-26 23:44:05
5
+ prediction-offline-sme,49.66247518199868,7555,2025-01-26 00:18:20,2025-03-25 18:52:45
6
+ prediction-online,44.43744752308984,4764,2025-01-26 08:19:45,2025-03-26 10:04:25
7
+ prediction-online-sme,42.7536231884058,2898,2025-01-26 08:21:10,2025-03-26 11:04:25
8
+ prediction-request-rag,45.96774193548387,372,2025-01-26 12:30:50,2025-03-25 18:09:15
9
+ prediction-request-rag-claude,49.56011730205279,341,2025-01-26 09:14:15,2025-03-24 17:36:30
10
+ prediction-request-reasoning,48.855616051623315,59508,2025-01-26 07:59:40,2025-03-26 17:14:00
11
+ prediction-request-reasoning-claude,70.60606060606061,330,2025-01-26 12:09:10,2025-03-25 14:52:45
12
+ prediction-url-cot-claude,53.493699885452465,873,2025-01-26 01:08:05,2025-03-25 22:11:55
13
+ superforcaster,56.70432743551481,9382,2025-01-26 01:17:25,2025-03-25 23:12:40
unknown_traders.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:aa637b640db3a761e192450351c2cee555863412f76cad3c4b6abfeff9c4db8d
3
- size 1006605
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25eca09b15491791210e54fb952673c6d3c60658fd45a568ceddd5939f392904
3
+ size 1062580
weekly_mech_calls.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:48f406494a32375fc732c7d100a49f407b3bffa950bbb5e5546c2b7a87fc27a7
3
- size 57176
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a66cc54ce2c5522727e63439c1be576c68b3283c5580439a693316107c95ceb
3
+ size 58183
winning_df.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2b70b10b47219e31b47a623db398bf83837a68f6b2d8bd1750e96fbabec8aec8
3
- size 11059
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:662aaefbf51f881b8afd84d8523cb2fd39f8212f57570be5e38ee656666a8e50
3
+ size 11398