sharpie.webserver.experiment.models

Functions

default_environment_filepaths()

default_keyboard_inputs()

default_policy_filepaths()

Classes

Agent(*args, **kwargs)

The union of policies and participants, i.e. an entity that perceives information from its environment, makes decisions based on those perceptions and internal goals, and acts to influence the environment’s future state.

ConnectionCheckerConfig(*args, **kwargs)

Singleton config for connection quality checks.

Environment(*args, **kwargs)

A simulated Markov decision process (MDP) adhering to the Gymnasium API with a tensor actions and rewards to support multi-agent and multi-objective settings.

Experiment(*args, **kwargs)

A configured study combining zero, one or more RL agent(s), a single environment, one or more participants.

Policy(*args, **kwargs)

The instance of an RL policy, i.e. a particular stochastic or deterministic mapping of states to actions.

sharpie.webserver.experiment.models.default_policy_filepaths()
sharpie.webserver.experiment.models.default_keyboard_inputs()
sharpie.webserver.experiment.models.default_environment_filepaths()
class sharpie.webserver.experiment.models.Policy(*args, **kwargs)

The instance of an RL policy, i.e. a particular stochastic or deterministic mapping of states to actions.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • name (CharField) – Name

  • description (TextField) – Description

  • filepaths (JSONField) – List of files needed by the policy. Those should be located under the top runner folder. You can also specify files under subfolders like <folder>/<filename>.py. <a href=”/experiment/download/policy_template” target=”_blank”>Download policy template</a>, your policy file should define a variable called “policy” that implements the logic of the policy.

  • checkpoint_interval (IntegerField) – Checkpoint interval. Checkpoint interval (in steps) at which the policy is saved. Can also be 0 (never) or -2 (at the end of each episode).

  • metadata (JSONField) – Metadata

Reverse relationships:

Parameters:

agent (Reverse ForeignKey from Agent) – All agents of this policy (related name of policy)

name

Type: CharField

Name

description

Type: TextField

Description

filepaths

Type: JSONField

List of files needed by the policy. Those should be located under the top runner folder. You can also specify files under subfolders like <folder>/<filename>.py. <a href=”/experiment/download/policy_template” target=”_blank”>Download policy template</a>, your policy file should define a variable called “policy” that implements the logic of the policy.

checkpoint_interval

Type: IntegerField

Checkpoint interval. Checkpoint interval (in steps) at which the policy is saved. Can also be 0 (never) or -2 (at the end of each episode).

metadata

Type: JSONField

Metadata

clean()

Validate the policy model: 1. All files in filepaths can be found in the system 2. There is one file stored in the filepaths dict with key “policy” 3. That script defines a policy variable

exception DoesNotExist
exception MultipleObjectsReturned
agent_set

Type: Reverse ForeignKey from Agent

All agents of this policy (related name of policy)

id

Type: BigAutoField

Primary key: ID

objects = <django.db.models.Manager object>
class sharpie.webserver.experiment.models.Agent(*args, **kwargs)

The union of policies and participants, i.e. an entity that perceives information from its environment, makes decisions based on those perceptions and internal goals, and acts to influence the environment’s future state.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • role (CharField) – Role in the environment (will be used as an ID)

  • name (CharField) – Name that will be displayed

  • description (TextField) – Description

  • participant (BooleanField) – Can the participant act?

  • keyboard_inputs (JSONField) – Inputs captured from the participant, with mapping

  • keyboard_input_display (JSONField) – Display config for each key: {key: {“symbol”: “←”, “label”: “Left”}}. Optional. Maps key names to display config. E.g. {“Enter”: {“symbol”: “↵”, “label”: “Enter”}}. Keys not listed use the key name.

  • multiple_keyboard_inputs (BooleanField) – Allow multiple inputs from users

  • inputs_type (CharField) – How will the inputs be used in the environment?

  • textual_inputs (BooleanField) – Allow textual inputs from users

  • metadata (JSONField) – Metadata

Relationship fields:

Parameters:

policy (ForeignKey to Policy) – Policy (related name: agent)

Reverse relationships:

Parameters:

experiment (Reverse ManyToManyField from Experiment) – All experiment of this agent (related name of agents)

role

Type: CharField

Role in the environment (will be used as an ID)

name

Type: CharField

Name that will be displayed

description

Type: TextField

Description

policy

Type: ForeignKey to Policy

Policy (related name: agent)

participant

Type: BooleanField

Can the participant act?

keyboard_inputs

Type: JSONField

Inputs captured from the participant, with mapping

keyboard_input_display

Type: JSONField

Display config for each key: {key: {“symbol”: “←”, “label”: “Left”}}. Optional. Maps key names to display config. E.g. {“Enter”: {“symbol”: “↵”, “label”: “Enter”}}. Keys not listed use the key name.

multiple_keyboard_inputs

Type: BooleanField

Allow multiple inputs from users

inputs_type

Type: CharField

How will the inputs be used in the environment?

Choices:

  • actions

  • reward

  • other

textual_inputs

Type: BooleanField

Allow textual inputs from users

metadata

Type: JSONField

Metadata

clean()

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

get_keyboard_input_display_map()

Returns display config for each key in keyboard_inputs (except default). Uses keyboard_input_display when set, else key name (Space for ‘ ‘).

exception DoesNotExist
exception MultipleObjectsReturned
experiment

Type: Reverse ManyToManyField from Experiment

All experiment of this agent (related name of agents)

get_inputs_type_display(*, field=<django.db.models.CharField: inputs_type>)

Shows the label of the inputs_type. See get_FOO_display() for more information.

id

Type: BigAutoField

Primary key: ID

objects = <django.db.models.Manager object>
policy_id

Internal field, use policy instead.

class sharpie.webserver.experiment.models.Environment(*args, **kwargs)

A simulated Markov decision process (MDP) adhering to the Gymnasium API with a tensor actions and rewards to support multi-agent and multi-objective settings.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • name (CharField) – Name

  • description (TextField) – Description

  • filepaths (JSONField) – List of files needed by the environment. Those should be located under the top runner folder. You can also specify files under subfolders like <folder>/<filename>.py. <a href=”/experiment/download/environment_template” target=”_blank”>Download environment template</a>, your environment file should define a variable called “environment” that implements the logic of the environment.

  • metadata (JSONField) – Metadata

Reverse relationships:

Parameters:

experiment (Reverse ForeignKey from Experiment) – All experiments of this environment (related name of environment)

name

Type: CharField

Name

description

Type: TextField

Description

filepaths

Type: JSONField

List of files needed by the environment. Those should be located under the top runner folder. You can also specify files under subfolders like <folder>/<filename>.py. <a href=”/experiment/download/environment_template” target=”_blank”>Download environment template</a>, your environment file should define a variable called “environment” that implements the logic of the environment.

metadata

Type: JSONField

Metadata

clean()

Validate the environment model: 1. All files in filepaths can be found in the system 2. There is one file stored in the filepaths dict with key “environment” 3. That script defines an environment variable

exception DoesNotExist
exception MultipleObjectsReturned
experiment_set

Type: Reverse ForeignKey from Experiment

All experiments of this environment (related name of environment)

id

Type: BigAutoField

Primary key: ID

objects = <django.db.models.Manager object>
class sharpie.webserver.experiment.models.Experiment(*args, **kwargs)

A configured study combining zero, one or more RL agent(s), a single environment, one or more participants.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • name (CharField) – Name

  • link (CharField) – Link to the experiment. Unique identifier (slug) for the experiment URL

  • conda_environment (CharField) – Name of a Conda environment already installed on the runner

  • short_description (TextField) – To be displayed on the home page

  • long_description (TextField) – To be displayed on the experiment page

  • enabled (BooleanField) – Enabled

  • redirect_url (URLField) – Redirect url. If provided, participants will be redirected to this URL after completing the experiment.

  • number_of_episodes (IntegerField) – Number of episodes to complete

  • target_fps (FloatField) – Target FPS for the experiment. If you enable wait for inputs, the FPS will be determined by the participants’ inputs and this setting will be used as a forced pause after receiving inputs.

  • wait_for_inputs (BooleanField) – Wait for participants’ input before moving to the next step

Relationship fields:

Parameters:
  • environment (ForeignKey to Environment) – Environment (related name: experiment)

  • agents (ManyToManyField to Agent) – Agents (related name: experiment)

Reverse relationships:

Parameters:

sessions (Reverse ForeignKey from Session) – All sessions of this experiment (related name of experiment)

name

Type: CharField

Name

Type: CharField

Link to the experiment. Unique identifier (slug) for the experiment URL

conda_environment

Type: CharField

Name of a Conda environment already installed on the runner

short_description

Type: TextField

To be displayed on the home page

long_description

Type: TextField

To be displayed on the experiment page

enabled

Type: BooleanField

Enabled

redirect_url

Type: URLField

Redirect url. If provided, participants will be redirected to this URL after completing the experiment.

environment

Type: ForeignKey to Environment

Environment (related name: experiment)

agents

Type: ManyToManyField to Agent

Agents (related name: experiment)

number_of_episodes

Type: IntegerField

Number of episodes to complete

target_fps

Type: FloatField

Target FPS for the experiment. If you enable wait for inputs, the FPS will be determined by the participants’ inputs and this setting will be used as a forced pause after receiving inputs.

wait_for_inputs

Type: BooleanField

Wait for participants’ input before moving to the next step

save(*args, **kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

exception DoesNotExist
exception MultipleObjectsReturned
environment_id

Internal field, use environment instead.

id

Type: BigAutoField

Primary key: ID

objects = <django.db.models.Manager object>
sessions

Type: Reverse ForeignKey from Session

All sessions of this experiment (related name of experiment)

class sharpie.webserver.experiment.models.ConnectionCheckerConfig(*args, **kwargs)

Singleton config for connection quality checks. Edit in admin.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • bandwidth_threshold (FloatField) – Bandwidth threshold. Minimum acceptable bandwidth (Mbps)

  • latency_threshold (IntegerField) – Latency threshold. Maximum acceptable latency (ms)

  • test_image_size (IntegerField) – Test image size. Test image size for bandwidth test (bytes)

bandwidth_threshold

Type: FloatField

Bandwidth threshold. Minimum acceptable bandwidth (Mbps)

latency_threshold

Type: IntegerField

Latency threshold. Maximum acceptable latency (ms)

test_image_size

Type: IntegerField

Test image size. Test image size for bandwidth test (bytes)

save(*args, **kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

delete(*args, **kwargs)
exception DoesNotExist
exception MultipleObjectsReturned
id

Type: BigAutoField

Primary key: ID

objects = <django.db.models.Manager object>