Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes#355: [Pdr acc] CORS, Debug Mode, the first day issue on the calculation #358

Merged
merged 24 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pylint issues
  • Loading branch information
kdetry committed Oct 31, 2023
commit 3525b21023dd46089620cd8fcd45e3eb5557ff81
5 changes: 3 additions & 2 deletions pdr_backend/accuracy/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask import Flask, jsonify, request, abort
import threading
import json
from flask import Flask, jsonify, abort

from pdr_backend.util.predictoor_stats import get_endpoint_statistics
from pdr_backend.util.subgraph_predictions import (
get_all_predictions,
Expand Down Expand Up @@ -49,7 +50,7 @@ def serve_predictions_from_file():
data = json.load(f)
return jsonify(data)
except Exception as e:
abort(500, description="Error loading predictions data from file")
abort(500, description=str(e))


if __name__ == "__main__":
Expand Down
5 changes: 3 additions & 2 deletions pdr_backend/util/predictoor_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def get_pure_stats(all_predictions: List[Prediction]):
stats: dict[str, dict] = {"pair_timeframe": {}, "predictoor": {}}
stats: Dict[str, Dict] = {"pair_timeframe": {}, "predictoor": {}}
correct_predictions = 0

for prediction in all_predictions:
Expand Down Expand Up @@ -57,7 +57,8 @@ def get_pure_stats(all_predictions: List[Prediction]):


def get_endpoint_statistics(all_predictions: List[Prediction]) -> StatisticsResult:
# This is similar to the get_statistics function but returns the results instead of printing them.
# This is similar to the get_statistics function
# but returns the results instead of printing them.
total_predictions = len(all_predictions)
stats, correct_predictions = get_pure_stats(all_predictions)

Expand Down
2 changes: 2 additions & 0 deletions pdr_backend/util/subgraph_predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def get_subgraph_url(network: str) -> str:
"Invalid network. Acceptable values are 'mainnet' or 'testnet'."
)

# pylint: disable=line-too-long
return f"https://v4.subgraph.sapphire-{network}.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph"


Expand All @@ -46,6 +47,7 @@ def get_all_predictions(
# Convert filters to lowercase
filters = [f.lower() for f in filters]

# pylint: disable=line-too-long
if filter_mode == FilterMode.CONTRACT:
where_clause = f"where: {{slot_: {{predictContract_in: {json.dumps(filters)}, slot_gt: {start_ts}, slot_lt: {end_ts}}}}}"
elif filter_mode == FilterMode.PREDICTOOR:
Expand Down
Loading