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

Implement a benchmarking mode #252

Merged
merged 23 commits into from
May 9, 2024
Merged

Implement a benchmarking mode #252

merged 23 commits into from
May 9, 2024

Conversation

Adamantios
Copy link
Collaborator

No description provided.

@Adamantios Adamantios added the enhancement New feature or request label Apr 24, 2024
@Adamantios
Copy link
Collaborator Author

In order to run the mocked trader's version the following environment variables need to be set:

  • BENCHMARKING_MODE_ENABLED -> true
  • BENCHMARKING_MODE_DATASET_FILENAME -> the value has to be the filename of the input dataset, which must be present under the STORE_PATH folder of the agent.

Other variables can also be set - you may find them under the benchmarking_mode - in order to change the behaviour of the mocked agent.

Optionally, you may also set the RESET_PAUSE_DURATION to a smaller amount so that the mocked version runs faster.

All these environment variables can be set in the quickstart script to simplify the running process.

@Adamantios Adamantios changed the title [WIP]: Implement a benchmarking mode Implement a benchmarking mode May 9, 2024
@Adamantios Adamantios marked this pull request as ready for review May 9, 2024 14:56
@Adamantios Adamantios requested a review from 0xArdi May 9, 2024 14:57
@Adamantios Adamantios merged commit 018d02f into main May 9, 2024
6 checks passed
@Adamantios Adamantios deleted the feat/benchmarking-mode branch May 9, 2024 15:16
Copy link
Collaborator

@cyberosa cyberosa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done.

args:
enabled: ${bool:false}
native_balance: ${int:10000000000000000000}
collateral_balance: ${int:10000000000000000000}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why int instead of float? I heard that the bet amounts can be very low and may include decimals

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are in WEI.

return

add_headers = False
results_path = self.params.store_path / self.benchmarking_mode.results_filename
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you prefer to have a separate folder called "benchmarking_results" in order not to be mixed with other data you have in that store folder...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would require changes in the quickstart. Let's keep it simple for now.

)
results_text = tuple(str(res) for res in results)
row = ",".join(results_text) + NEW_LINE
results_file.write(row)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is the results_file.close()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary, as a context manager is used.

@@ -204,9 +204,17 @@ def _prepare_safe_tx(self) -> Generator[None, None, Optional[str]]:

def async_act(self) -> Generator:
"""Do the action."""
agent = self.context.agent_address
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont you prefer to call the variable agent_address?

if mode.part_prefix_mode:
fields[prediction_attribute] = row[field_part + mech_tool]
else:
fields[prediction_attribute] = row[mech_tool + field_part]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this alternative? I thought the input files should be consistent with the format of the column names...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was developed before agreeing on the column names etc. It provides flexibility so that we do not need to perform code changes if the input format changes.

@@ -75,9 +75,13 @@ def async_act(self) -> Generator:
"""Do the action."""
with self.context.benchmark_tool.measure(self.behaviour_id).local():
payload_content = None
mocking_mode: Optional[bool] = self.benchmarking_mode.enabled
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the mocking_mode only active for the benchmarking_mode? Then why not giving the same name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️

(DecisionReceiveRound, DONE): BetPlacementRound
(DecisionReceiveRound, MECH_RESPONSE_ERROR): BlacklistingRound
(DecisionReceiveRound, NO_MAJORITY): DecisionReceiveRound
(DecisionReceiveRound, ROUND_TIMEOUT): DecisionReceiveRound
(DecisionReceiveRound, TIE): BlacklistingRound
(DecisionReceiveRound, UNPROFITABLE): BlacklistingRound
(DecisionRequestRound, DONE): FinishedDecisionRequestRound
(DecisionRequestRound, NONE): ImpossibleRound
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the NONE transition is not possible anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was never possible, check the comment:

# this is here because of `autonomy analyse fsm-specs` falsely reporting it as missing from the transition
Event.NONE: ImpossibleRound,

"confidence_field_part", kwargs, str
)
# this is the mode for the p and confidence parts
# if the flag is `True`, then the field parts are used as prefixes, otherwise as suffixes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep only one format, because I need to process this files also for the evaluation part and I prefer to be consistent with column names.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it does not depend on the code here though, it depends on the input data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants