aisysprojserver package
Submodules
aisysprojserver.act module
- class aisysprojserver.act.ActConfig(parallel_runs: bool = True)
Bases:
object- parallel_runs: bool = True
- class aisysprojserver.act.ActManager(env_id: str, request: RequestV1)
Bases:
object- get_act_response() ResponseV1
- get_action_result(action: ActionV1, run_data: RunData) ActionResult | None
- get_agent_data_model(session) AgentDataModel
- get_run_model_and_history(action: ActionV1 | AbandonAction, session) tuple[RunModel, list[tuple[Any, Any]]] | None
- process_action(action: ActionV1 | AbandonAction)
- pydantic model aisysprojserver.act.ActionRequestV0
Bases:
BaseModelShow JSON schema
{ "title": "ActionRequestV0", "type": "object", "properties": { "run": { "title": "Run", "type": "string" }, "percept": { "title": "Percept" } }, "required": [ "run", "percept" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field percept: Any [Required]
- field run: Annotated[str, AfterValidator(func=_validate_old_runid)] [Required]
- Constraints:
func = <function _validate_old_runid at 0x7faca21c1510>
- pydantic model aisysprojserver.act.ActionRequestV1
Bases:
BaseModelShow JSON schema
{ "title": "ActionRequestV1", "type": "object", "properties": { "percept": { "title": "Percept" }, "run": { "title": "Run", "type": "string" }, "act_no": { "title": "Act No", "type": "integer" } }, "required": [ "percept", "run", "act_no" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field act_no: int [Required]
- field percept: Any [Required]
- field run: str [Required]
- pydantic model aisysprojserver.act.ActionV0
Bases:
BaseModelShow JSON schema
{ "title": "ActionV0", "type": "object", "properties": { "run": { "title": "Run", "type": "string" }, "action": { "title": "Action" } }, "required": [ "run", "action" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field action: Any [Required]
- field run: Annotated[str, AfterValidator(func=_validate_old_runid)] [Required]
- Constraints:
func = <function _validate_old_runid at 0x7faca21c1510>
- pydantic model aisysprojserver.act.ActionV1
Bases:
BaseModelShow JSON schema
{ "title": "ActionV1", "type": "object", "properties": { "action": { "title": "Action" }, "run": { "title": "Run", "type": "string" }, "act_no": { "title": "Act No", "type": "integer" } }, "required": [ "action", "run", "act_no" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field act_no: int [Required]
- field action: Any [Required]
- field run: str [Required]
- pydantic model aisysprojserver.act.Message
Bases:
BaseModelShow JSON schema
{ "title": "Message", "type": "object", "properties": { "run": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Run" }, "content": { "title": "Content", "type": "string" }, "type": { "$ref": "#/$defs/MessageType" } }, "$defs": { "MessageType": { "enum": [ "error", "warning", "info" ], "title": "MessageType", "type": "string" } }, "required": [ "content", "type" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field content: str [Required]
- field run: str | None = None
- field type: MessageType [Required]
- class aisysprojserver.act.MessageType(value)
Bases:
str,EnumAn enumeration.
- error = 'error'
- info = 'info'
- warning = 'warning'
- pydantic model aisysprojserver.act.RequestV0
Bases:
BaseModelShow JSON schema
{ "title": "RequestV0", "type": "object", "properties": { "agent": { "title": "Agent", "type": "string" }, "pwd": { "title": "Pwd", "type": "string" }, "actions": { "items": { "$ref": "#/$defs/ActionV0" }, "title": "Actions", "type": "array" }, "single_request": { "default": false, "title": "Single Request", "type": "boolean" } }, "$defs": { "ActionV0": { "properties": { "run": { "title": "Run", "type": "string" }, "action": { "title": "Action" } }, "required": [ "run", "action" ], "title": "ActionV0", "type": "object" } }, "required": [ "agent", "pwd" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field agent: str [Required]
- field pwd: str [Required]
- field single_request: bool = False
- pydantic model aisysprojserver.act.RequestV1
Bases:
BaseModelShow JSON schema
{ "title": "RequestV1", "type": "object", "properties": { "agent": { "title": "Agent", "type": "string" }, "pwd": { "title": "Pwd", "type": "string" }, "actions": { "items": { "$ref": "#/$defs/ActionV1" }, "title": "Actions", "type": "array" }, "parallel_runs": { "default": true, "title": "Parallel Runs", "type": "boolean" }, "to_abandon": { "items": { "type": "string" }, "title": "To Abandon", "type": "array" }, "client": { "default": "", "title": "Client", "type": "string" } }, "$defs": { "ActionV1": { "properties": { "action": { "title": "Action" }, "run": { "title": "Run", "type": "string" }, "act_no": { "title": "Act No", "type": "integer" } }, "required": [ "action", "run", "act_no" ], "title": "ActionV1", "type": "object" } }, "required": [ "agent", "pwd" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field agent: str [Required]
- field client: str = ''
- field parallel_runs: bool = True
- field pwd: str [Required]
- field to_abandon: list[str] [Optional]
- pydantic model aisysprojserver.act.ResponseV0
Bases:
BaseModelShow JSON schema
{ "title": "ResponseV0", "type": "object", "properties": { "errors": { "items": { "type": "string" }, "title": "Errors", "type": "array" }, "messages": { "items": { "type": "string" }, "title": "Messages", "type": "array" }, "action_requests": { "items": { "$ref": "#/$defs/ActionRequestV0" }, "title": "Action Requests", "type": "array" } }, "$defs": { "ActionRequestV0": { "properties": { "run": { "title": "Run", "type": "string" }, "percept": { "title": "Percept" } }, "required": [ "run", "percept" ], "title": "ActionRequestV0", "type": "object" } } }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field action_requests: list[ActionRequestV0] [Optional]
- field errors: list[str] [Optional]
- field messages: list[str] [Optional]
- pydantic model aisysprojserver.act.ResponseV1
Bases:
BaseModelShow JSON schema
{ "title": "ResponseV1", "type": "object", "properties": { "action_requests": { "items": { "$ref": "#/$defs/ActionRequestV1" }, "title": "Action Requests", "type": "array" }, "active_runs": { "items": { "type": "string" }, "title": "Active Runs", "type": "array" }, "messages": { "items": { "$ref": "#/$defs/Message" }, "title": "Messages", "type": "array" }, "finished_runs": { "title": "Finished Runs", "type": "object" } }, "$defs": { "ActionRequestV1": { "properties": { "percept": { "title": "Percept" }, "run": { "title": "Run", "type": "string" }, "act_no": { "title": "Act No", "type": "integer" } }, "required": [ "percept", "run", "act_no" ], "title": "ActionRequestV1", "type": "object" }, "Message": { "properties": { "run": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Run" }, "content": { "title": "Content", "type": "string" }, "type": { "$ref": "#/$defs/MessageType" } }, "required": [ "content", "type" ], "title": "Message", "type": "object" }, "MessageType": { "enum": [ "error", "warning", "info" ], "title": "MessageType", "type": "string" } } }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field action_requests: list[ActionRequestV1] [Optional]
- field active_runs: list[str] [Optional]
- field finished_runs: dict[str, Any] [Optional]
- to_v0() ResponseV0
- aisysprojserver.act.act(env_id: str)
aisysprojserver.active_env module
- class aisysprojserver.active_env.ActiveEnvironment(identifier: str)
Bases:
ModelMixin[ActiveEnvironmentModel]- property display_name: str
- property env_class_refstr: str
- get_env_instance() GenericEnvironment
- classmethod new(identifier: str, env_class: str, display_name: str, display_group: str, config: str, overwrite: bool = False) ActiveEnvironment
- property recent_runs_key: str
- aisysprojserver.active_env.get_all_active_envs() list[ActiveEnvironment]
aisysprojserver.active_env_management module
- pydantic model aisysprojserver.active_env_management.MakeEnvRequest
Bases:
BaseModelShow JSON schema
{ "title": "MakeEnvRequest", "type": "object", "properties": { "env_class": { "title": "Env Class", "type": "string" }, "display_name": { "title": "Display Name", "type": "string" }, "config": { "title": "Config" }, "display_group": { "default": "", "title": "Display Group", "type": "string" }, "overwrite": { "default": false, "title": "Overwrite", "type": "boolean" } }, "required": [ "env_class", "display_name", "config" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field config: Any [Required]
- field display_group: str = ''
- field display_name: str [Required]
- field env_class: str [Required]
- field overwrite: bool = False
- aisysprojserver.active_env_management.makeenv(env: str)
aisysprojserver.admin module
- aisysprojserver.admin.deleteunusedagents(env_id: str)
- aisysprojserver.admin.diskusage()
- aisysprojserver.admin.errors()
- aisysprojserver.admin.get_env_results(active_env: ActiveEnvironment)
- aisysprojserver.admin.getenvs()
- aisysprojserver.admin.removenonrecentruns()
- aisysprojserver.admin.results()
- aisysprojserver.admin.results_env(env_id: str)
aisysprojserver.agent_account module
- class aisysprojserver.agent_account.AgentAccount(environment: str, agentname: str, is_client: bool = False)
Bases:
ModelMixin[AgentAccountModel]- block()
- delete()
- classmethod from_request(environment: str, agent: str | None = None) AgentAccount
- is_active() bool
- is_authenticated() bool
- require_active()
- require_authenticated()
- signup(overwrite: bool = False) str
The caller must have verified that the environment and agentname are valid. Returns the password.
- unblock()
- class aisysprojserver.agent_account.AgentStatus(value)
Bases:
IntEnumAn enumeration.
- ACTIVE = 1
- LOCKED = 0
- exception aisysprojserver.agent_account.NoSuchAgentError
Bases:
Exception
- aisysprojserver.agent_account.get_all_agentaccounts_for_env(env_id: str) list[AgentAccount]
aisysprojserver.agent_account_management module
- aisysprojserver.agent_account_management.blockagent(env: str, agent: str)
- aisysprojserver.agent_account_management.makeagent(env: str, agent: str)
- aisysprojserver.agent_account_management.unblockagent(env: str, agent: str)
aisysprojserver.agent_data module
- class aisysprojserver.agent_data.AgentData(identifier)
Bases:
ModelMixin[AgentDataModel]- delete(session=None)
- delete_nonrecent_runs(session=None)
- property display_name: str
- identifier: str
- to_agent_data_summary() AgentDataSummary
aisysprojserver.app module
- aisysprojserver.app.exception_handler(exception)
- aisysprojserver.app.main()
aisysprojserver.authentication module
Functionality for password hashing and checking.
Design decisions:
The way a password is stored is indicated by a prefix. That makes it possible to change the scheme later on if desired.
We do not allow users to set a password (the server sets high-entropy passwords). That way we don’t have to use slow hashing algorithms like bcrypt.
- aisysprojserver.authentication.default_pwd_hash(password: str) str
- aisysprojserver.authentication.generate_admin_password()
- aisysprojserver.authentication.get_admin_hashes() list[str]
- aisysprojserver.authentication.require_admin_auth()
- aisysprojserver.authentication.require_password_match(password: str, stored_hash: str)
aisysprojserver.config module
- class aisysprojserver.config.Config
Bases:
object- ADMIN_AUTH = None
- CACHE_DEFAULT_TIMEOUT = 5
- CACHE_TYPE = 'SimpleCache'
- CONFIG_NAME: str = 'test'
- property DATABASE_URI: str
- property LOG_FILE: Path
- MAX_CONTENT_LENGTH: int = 1000000
- MIN_LOG_LEVEL = 20
- OTLP_ENDPOINT: str | None = None
- PERSISTENT: Path = PosixPath('/tmp')
- property PLUGINS_DIR: Path
- PROMETHEUS_PORT: int | None = 9464
- register(app: Flask)
- class aisysprojserver.config.TestConfig
Bases:
Config- ADMIN_AUTH = 'sha256:f7a03f48c0e2aa2d5e55ca186c20032ddbf53b7f5f93fce387d65c3f83433e8d'
aisysprojserver.env_interface module
- class aisysprojserver.env_interface.AbbreviatedRunData(run_id: 'int', outcome: 'Optional[Any]', agent_name: 'str')
Bases:
object- agent_name: str
- outcome: Any | None
- run_id: int
- class aisysprojserver.env_interface.ActionHistoryEntry(action: 'Any', extra_info: 'Any')
Bases:
object- action: Any
- extra_info: Any
- class aisysprojserver.env_interface.ActionResult(new_state: 'Optional[Any]' = None, message: 'Optional[str]' = None, action_extra_info: 'Any' = None, outcome: 'Optional[Any]' = None)
Bases:
object- action_extra_info: Any = None
- classmethod error(message: str) ActionResult
- message: str | None = None
- new_state: Any | None = None
- outcome: Any | None = None
- class aisysprojserver.env_interface.AgentDataSummary(agent_name: 'str', agent_rating: 'float', current_agent_rating: 'float', recent_runs: 'list[AbbreviatedRunData]', total_number_of_runs: 'int', fully_evaluated: 'bool')
Bases:
object- agent_name: str
- agent_rating: float
- current_agent_rating: float
- fully_evaluated: bool
- recent_runs: list[AbbreviatedRunData]
- total_number_of_runs: int
- class aisysprojserver.env_interface.EnvData(agents: 'list[AgentDataSummary]', recent_runs: 'list[AbbreviatedRunData]')
Bases:
object- agents: list[AgentDataSummary]
- recent_runs: list[AbbreviatedRunData]
- class aisysprojserver.env_interface.EnvInfo(display_name: 'str', identifier: 'str')
Bases:
object- display_name: str
- identifier: str
- class aisysprojserver.env_interface.GenericEnvironment(env_info: EnvInfo, config_json: Any)
Bases:
ABC- abstract act(action: Any, run_data: RunData) ActionResult
- abstract get_action_request(run_data: RunData) ActionRequest
- abstract new_run() Any
- settings: EnvSettings = <aisysprojserver.env_settings.EnvSettings object>
- view_agent(agent_data: AgentDataSummary) str
aisysprojserver.env_mixins module
- class aisysprojserver.env_mixins.SimpleViewAgent
Bases:
object- settings: EnvSettings
- view_agent(agent_data: AgentDataSummary) str
- class aisysprojserver.env_mixins.SimpleViewEnv
Bases:
object- settings: EnvSettings
aisysprojserver.env_settings module
The environment settings tells the server how to work with the environment.
Note that only the relevant subset of settings is actually used.
- class aisysprojserver.env_settings.EnvSettings
Bases:
object- CAN_ABANDON_RUNS: bool = False
- DESCRIPTION: str = ''
- INITIAL_RATING: float = 0.0
- MIN_RUNS_FOR_FULLY_EVALUATED: int = 50
- NUMBER_OF_ACTION_REQUESTS: int = 5
- RATING_OBJECTIVE: str = 'max'
- RATING_STRATEGY: str = 'average'
- STORE_ACTION_HISTORY: bool = True
aisysprojserver.group module
- class aisysprojserver.group.Group(identifier: str)
Bases:
ModelMixin[GroupModel]- add_env(env: ActiveEnvironment)
- delete()
- property description: str
- property display_name: str
- get_envs() list[ActiveEnvironment]
aisysprojserver.group_management module
- pydantic model aisysprojserver.group_management.MakeGroupRequest
Bases:
BaseModelShow JSON schema
{ "title": "MakeGroupRequest", "type": "object", "properties": { "title": { "title": "Title", "type": "string" }, "description": { "title": "Description", "type": "string" }, "overwrite": { "default": false, "title": "Overwrite", "type": "boolean" } }, "required": [ "title", "description" ] }
- Config:
frozen: bool = True
extra: str = ignore
populate_by_name: bool = True
- Fields:
- field description: str [Required]
- field overwrite: bool = False
- field title: str [Required]
- aisysprojserver.group_management.addenv(group: str, env: str)
- aisysprojserver.group_management.addsubgroup(group: str, subgroup: str)
- aisysprojserver.group_management.deletegroup(group: str)
- aisysprojserver.group_management.makegroup(group: str)
aisysprojserver.models module
Database models for the AI system project server
Note that this has grown organically without any expertise in database design, using only the most basic features. It is not a good example of how to structure a database model.
- class aisysprojserver.models.ActiveEnvironmentModel(**kwargs)
Bases:
Base- config
- displaygroup
- displayname
- env_class
- identifier
- signup
- status
- class aisysprojserver.models.AgentAccountModel(**kwargs)
Bases:
Base- environment
- identifier
- password
- status
- class aisysprojserver.models.AgentDataModel(**kwargs)
Bases:
Base- best_rating
- current_rating
- environment
- fully_evaluated
- identifier
- recent_results
- recently_finished_runs
- total_runs
- class aisysprojserver.models.GroupModel(**kwargs)
Bases:
Base- description_html
- displayname
- identifier
- class aisysprojserver.models.KeyValAccess(session)
Bases:
object
- class aisysprojserver.models.ModelMixin(model_class: type[_M])
Bases:
Generic[_M]Mixin for classes that are linked to a model
- exists() bool
- identifier: str | int
aisysprojserver.plugins module
- exception aisysprojserver.plugins.BadPluginError
Bases:
Exception
- class aisysprojserver.plugins.Plugin(package_name: str)
Bases:
object- property init_module
- is_valid: bool = True
- package_name: str
- unimport()
- property version: str | None
- class aisysprojserver.plugins.PluginManager
Bases:
object- classmethod get(reference: str)
reference can be ‘module.submodule’ or ‘module.submodule:attribute’
- classmethod is_initialized() bool
- classmethod load_from_zipfile(zf: ZipFile) str
- plugins_dir: Path | None = None
- classmethod reload_all_plugins()
- classmethod set_plugins_dir(plugins_dir: Path)
- aisysprojserver.plugins.upload()
aisysprojserver.run module
aisysprojserver.telemetry module
- class aisysprojserver.telemetry.MonitoredBlueprint(name: str, import_name: str, static_folder: str | ~os.PathLike[str] | None = None, static_url_path: str | None = None, template_folder: str | ~os.PathLike[str] | None = None, url_prefix: str | None = None, subdomain: str | None = None, url_defaults: dict[str, ~typing.Any] | None = None, root_path: str | None = None, cli_group: str | None = <object object>)
Bases:
Blueprint- route(rule, **options)
Decorate a view function to register it with the given URL rule and options. Calls
add_url_rule(), which has more details about the implementation.@app.route("/") def index(): return "Hello, World!"
See url-route-registrations.
The endpoint name for the route defaults to the name of the view function if the
endpointparameter isn’t passed.The
methodsparameter defaults to["GET"].HEADandOPTIONSare added automatically.- Parameters:
rule – The URL rule string.
options – Extra options passed to the
Ruleobject.
- aisysprojserver.telemetry.get_pid() int
- aisysprojserver.telemetry.measure_action_processing(env_class_refstr: str)
- aisysprojserver.telemetry.measure_run_creation_duration(env_class_refstr: str)
- aisysprojserver.telemetry.report_action(env_id: str, protocol_version: str, number_of_actions: int = 1, client: str | None = None)
aisysprojserver.util module
- aisysprojserver.util.json_dump(thing) str
- aisysprojserver.util.json_load(string: str) Any
- aisysprojserver.util.parse_request(model: type[_T], request) _T
aisysprojserver.website module
- aisysprojserver.website.agent_page(env: str, agent: str)
- aisysprojserver.website.env_page(env: str)
- aisysprojserver.website.frontpage()
- aisysprojserver.website.plugins_page()
- aisysprojserver.website.run_page(env: str, runid: str)