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

Remove special handling of empty dataframes #120

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
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
33 changes: 17 additions & 16 deletions src/fetch/orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
from sqlalchemy import create_engine
from sqlalchemy.engine import Engine

from src.logger import set_log
from src.models.block_range import BlockRange
from src.utils import open_query

log = set_log(__name__)

MAX_PROCESSING_DELAY = 10


Expand Down Expand Up @@ -96,14 +99,13 @@ def get_order_rewards(cls, block_range: BlockRange) -> DataFrame:
)

# Solvers do not appear in both environments!
assert set(prod.solver).isdisjoint(set(barn.solver)), "solver overlap!"
if not prod.empty and not barn.empty:
return pd.concat([prod, barn])
if not prod.empty:
return prod.copy()
if not barn.empty:
return barn.copy()
return pd.DataFrame()
if set(prod.solver).isdisjoint(set(barn.solver)):
log.warning(
f"solver overlap in {block_range}: solvers "
f"{set(prod.solver).intersection(set(barn.solver))} part of both prod and barn"
)

return pd.concat([prod, barn])

@classmethod
def get_batch_rewards(cls, block_range: BlockRange) -> DataFrame:
Expand Down Expand Up @@ -143,14 +145,13 @@ def get_batch_rewards(cls, block_range: BlockRange) -> DataFrame:
)

# Solvers do not appear in both environments!
assert set(prod.solver).isdisjoint(set(barn.solver)), "solver overlap!"
if not prod.empty and not barn.empty:
return pd.concat([prod, barn])
if not prod.empty:
return prod.copy()
if not barn.empty:
return barn.copy()
return pd.DataFrame()
if set(prod.solver).isdisjoint(set(barn.solver)):
log.warning(
f"solver overlap in {block_range}: solvers "
f"{set(prod.solver).intersection(set(barn.solver))} part of both prod and barn"
)

return pd.concat([prod, barn])

@classmethod
def get_app_hashes(cls) -> DataFrame:
Expand Down
Loading