cyberosa commited on
Commit
aed26cb
·
1 Parent(s): 9daf208

updating files

Browse files
Files changed (2) hide show
  1. latest_result_DAA_QS.parquet +2 -2
  2. scripts/daa.py +33 -20
latest_result_DAA_QS.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0e2e2d7549920281a3912bd08b526a3c8dd5fc122e5f00bb470ff0d0cbfffda1
3
- size 5404
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2c756e265448cf0a398c622efa0c15fcb67fc6022259250767bcec8d513fda8
3
+ size 5431
scripts/daa.py CHANGED
@@ -101,18 +101,18 @@ def get_service_id_from_trader_address(trader_address: str, service_map: dict):
101
  return None
102
 
103
 
104
- def prepare_predict_agents_dataset():
105
  # Read the service map pickle file
106
  with open(ROOT_DIR / "service_map.pkl", "rb") as f:
107
  service_map = pickle.load(f)
108
  content = []
109
- # Find all the safe addresses in the service map whose agent_id is equal to 25
110
  for key, value in service_map.items():
111
  print(f"value = {value}")
112
  if "agent_id" not in value:
113
  print(f"agent_id not found in value {value}")
114
  continue
115
- if value["agent_id"] == 25:
116
  agent_dict = {}
117
  # label the predict agents into two categories: pearl and quickstart
118
  owner_address = value["owner_address"]
@@ -123,10 +123,10 @@ def prepare_predict_agents_dataset():
123
  )
124
  content.append(agent_dict)
125
  # build the dataframe from the list of dictionaries
126
- predict_agents = pd.DataFrame(content)
127
- print(f"Number of unique predict agents = {len(predict_agents)}")
128
  # save the dataset as a csv file
129
- predict_agents.to_csv(ROOT_DIR / "olas_trader_agents.csv", index=False)
130
 
131
 
132
  def setup_dune_python_client():
@@ -145,29 +145,40 @@ def setup_dune_python_client():
145
  return dune_client
146
 
147
 
148
- def load_olas_agents_dataset_in_dune(dune_client: DuneClient):
149
  """Function to load the olas dataset in dune"""
150
 
151
  # Prepare the olas dataset
152
- # prepare_predict_agents_dataset()
153
  try:
154
- with open(ROOT_DIR / "olas_trader_agents.csv", "r") as open_file:
155
  data = open_file.read()
156
 
157
  # Upload the CSV data
158
  print("loading the dataset in dune")
159
- dune_client.create_table(
160
- table_name="olas_trader_agents",
161
- description="Olas trader agents found in Pearl and Quickstart markets",
162
- schema=[
163
- {"name": "date", "type": "timestamp"},
164
- {"name": "dgs10", "type": "double", "nullable": True},
165
- ],
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  is_private=False,
167
- namespace="cyberosa",
168
  )
169
-
170
- print(f"Dataset uploaded successfully!")
171
 
172
  except FileNotFoundError:
173
  print(f"Error: CSV file not found at {ROOT_DIR / "olas_trader_agents.csv"}")
@@ -245,4 +256,6 @@ def prepare_daa_data():
245
 
246
  if __name__ == "__main__":
247
  prepare_daa_data()
248
- # prepare_predict_agents_dataset()
 
 
 
101
  return None
102
 
103
 
104
+ def prepare_predict_services_dataset():
105
  # Read the service map pickle file
106
  with open(ROOT_DIR / "service_map.pkl", "rb") as f:
107
  service_map = pickle.load(f)
108
  content = []
109
+ # Find all the safe addresses in the service map whose agent_id is equal to 25 or 14
110
  for key, value in service_map.items():
111
  print(f"value = {value}")
112
  if "agent_id" not in value:
113
  print(f"agent_id not found in value {value}")
114
  continue
115
+ if value["agent_id"] == 25 or value["agent_id"] == 14:
116
  agent_dict = {}
117
  # label the predict agents into two categories: pearl and quickstart
118
  owner_address = value["owner_address"]
 
123
  )
124
  content.append(agent_dict)
125
  # build the dataframe from the list of dictionaries
126
+ predict_services = pd.DataFrame(content)
127
+ print(f"Number of unique predict agents = {len(predict_services)}")
128
  # save the dataset as a csv file
129
+ predict_services.to_csv(ROOT_DIR / "predict_services.csv", index=False)
130
 
131
 
132
  def setup_dune_python_client():
 
145
  return dune_client
146
 
147
 
148
+ def load_predict_services_file(dune_client: DuneClient):
149
  """Function to load the olas dataset in dune"""
150
 
151
  # Prepare the olas dataset
152
+ # prepare_predict_services_dataset()
153
  try:
154
+ with open(ROOT_DIR / "predict_services.csv", "r") as open_file:
155
  data = open_file.read()
156
 
157
  # Upload the CSV data
158
  print("loading the dataset in dune")
159
+ # dune_client.create_table(
160
+ # table_name="olas_trader_agents",
161
+ # description="Olas trader agents found in Pearl and Quickstart markets",
162
+ # schema=[
163
+ # {"name": "date", "type": "timestamp"},
164
+ # {"name": "dgs10", "type": "double", "nullable": True},
165
+ # ],
166
+ # is_private=False,
167
+ # namespace="cyberosa",
168
+ # )
169
+ # use the dune client to upload the dataset predict_services.csv
170
+ dune_client.upload_csv(
171
+ table_name="predict_services",
172
+ data=data,
173
+ description="Olas predict services found at the service registry",
174
+ # schema=[
175
+ # {"name": "safe_address", "type": "text"},
176
+ # {"name": "service_id", "type": "text"},
177
+ # {"name": "market_creator", "type": "text"},
178
+ # ],
179
  is_private=False,
 
180
  )
181
+ print(f"CSV file uploaded successfully!")
 
182
 
183
  except FileNotFoundError:
184
  print(f"Error: CSV file not found at {ROOT_DIR / "olas_trader_agents.csv"}")
 
256
 
257
  if __name__ == "__main__":
258
  prepare_daa_data()
259
+ # prepare_predict_services_dataset()
260
+ # dune = setup_dune_python_client()
261
+ # load_predict_services_file(dune_client=dune)