chipiron.scripts package

Subpackages

Submodules

chipiron.scripts.chipiron_args module

class chipiron.scripts.chipiron_args.ImplementationArgs(use_board_modification: bool = False, use_rust_boards: bool = False)[source]

Bases: object

use_board_modification: bool = False
use_rust_boards: bool = False

chipiron.scripts.factory module

factory for scripts module

chipiron.scripts.factory.create_script(script_type: ScriptType, extra_args: dict[str, Any] | None = None, config_file_name: str | None = None, should_parse_command_line_arguments: bool = True) IScript[source]

Creates the corresponding script

Parameters:
  • should_parse_command_line_arguments – whether the script should parse the command line. Default is True.

  • some (But might be set to False if called from a higher level script that wants the current script to stick to) –

  • extra_args. (defaults argument or if the higher level script wants to set them thought the) –

  • script_type – name of the script to create

  • extra_args – arguments provided to the script from the outside. In some cases they originate from a gui or command line. It can also be any dict specified to this function

Return type:

object

chipiron.scripts.get_script module

chipiron.scripts.get_script.get_script_type_from_script_class_name(script_type: ScriptType) Any[source]

Retrieves the script class name based on the given script type.

Parameters:

script_type (ScriptType) – The script type.

Returns:

The script class name.

Return type:

Any

Raises:

Exception – If the script type is not found.

chipiron.scripts.iscript module

This module defines the IScript interface, which serves as the interface for scripts in the application.

class chipiron.scripts.iscript.IScript(base_script: Script[Any])[source]

Bases: Protocol

The interface for scripts in the application.

run() None[source]

Runs the script.

Returns:

None

terminate() None[source]

Finishes the script. Performs profiling or timing.

Returns:

None

chipiron.scripts.main_chipiron module

Launching the main chipiron

chipiron.scripts.main_chipiron.get_script_and_args(raw_command_line_arguments: list[str]) tuple[chipiron.scripts.script_type.ScriptType, dict[str, Any] | None, str | None][source]
Parameters:

raw_command_line_arguments – the list of arguments of the scripts given by command line

Returns:

A string for the name of script and a dictionary of parameters

chipiron.scripts.main_chipiron.main() None[source]

The main function

chipiron.scripts.script module

This module contains the Script class which is responsible for launching scripts. It handles computing execution time, profiling, and parsing arguments.

class chipiron.scripts.script.HasBaseScriptArgs(*args, **kwargs)[source]

Bases: Protocol

Protocol of generic ScriptArgs that contains the BaseScriptArgs

base_script_args: BaseScriptArgs
class chipiron.scripts.script.Script(parser: Parsley, extra_args: dict[str, Any] | None = None, config_file_name: str | None = None)[source]

Bases: Generic

The core Script class to launch scripts. Takes care of computing execution time, profiling, and parsing arguments.

base_experiment_output_folder: str | PathLike[str] = 'chipiron/scripts/'
config_file_name: str | None
default_experiment_output_folder: str | PathLike[str] = 'chipiron/scripts/default_output_folder'
experiment_script_type_output_folder: str | PathLike[str] | None = None
gui_args: dict[str, Any] | None
initiate(experiment_output_folder: str | None = None) T_Dataclass[source]

Initiates the script by parsing arguments and converting them into a standardized dataclass.

Parameters:
  • args_dataclass_name – The type of the dataclass to convert the arguments into.

  • experiment_output_folder – The base folder for experiment output. If None, uses the default value.

Returns:

The converted arguments as a dataclass.

parser: Parsley
profile: Profile | None
run() None[source]

Runs the script.

start_time: float
terminate() None[source]

Finishes the script by printing execution time and profiling information (if enabled).

chipiron.scripts.script_args module

class chipiron.scripts.script_args.BaseScriptArgs(profiling: bool = False, testing: bool = False, universal_behavior: bool = False, experiment_output_folder: str | PathLike[str] | None = None, relative_script_instance_experiment_output_folder: str | PathLike[str] | None = None, seed: int = 0)[source]

Bases: object

Dataclass representing the arguments for the Script class.

experiment_output_folder: str | PathLike[str] | None = None
profiling: bool = False
relative_script_instance_experiment_output_folder: str | PathLike[str] | None = None
seed: int = 0
testing: bool = False
universal_behavior: bool = False

chipiron.scripts.script_type module

This module defines the ScriptType enum and provides a mapping between script types and their corresponding script classes.

class chipiron.scripts.script_type.ScriptType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

Enum class representing different types of scripts.

BaseTreeExploration = 'base_tree_exploration'
League = 'league'
LearnNN = 'learn_nn'
LearnNNFromScratch = 'learn_nn_from_scratch'
OneMatch = 'one_match'
ReplayMatch = 'replay_match'
TreeVisualization = 'tree_visualization'

Module contents

Init file for scripts module

class chipiron.scripts.IScript(base_script: Script[Any])[source]

Bases: Protocol

The interface for scripts in the application.

run() None[source]

Runs the script.

Returns:

None

terminate() None[source]

Finishes the script. Performs profiling or timing.

Returns:

None

class chipiron.scripts.Script(parser: Parsley, extra_args: dict[str, Any] | None = None, config_file_name: str | None = None)[source]

Bases: Generic

The core Script class to launch scripts. Takes care of computing execution time, profiling, and parsing arguments.

args: IsDataclass | None
base_experiment_output_folder: str | PathLike[str] = 'chipiron/scripts/'
config_file_name: str | None
default_experiment_output_folder: str | PathLike[str] = 'chipiron/scripts/default_output_folder'
experiment_script_type_output_folder: str | PathLike[str] | None = None
gui_args: dict[str, Any] | None
initiate(experiment_output_folder: str | None = None) T_Dataclass[source]

Initiates the script by parsing arguments and converting them into a standardized dataclass.

Parameters:
  • args_dataclass_name – The type of the dataclass to convert the arguments into.

  • experiment_output_folder – The base folder for experiment output. If None, uses the default value.

Returns:

The converted arguments as a dataclass.

parser: Parsley
profile: Profile | None
run() None[source]

Runs the script.

start_time: float
terminate() None[source]

Finishes the script by printing execution time and profiling information (if enabled).

class chipiron.scripts.ScriptType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

Enum class representing different types of scripts.

BaseTreeExploration = 'base_tree_exploration'
League = 'league'
LearnNN = 'learn_nn'
LearnNNFromScratch = 'learn_nn_from_scratch'
OneMatch = 'one_match'
ReplayMatch = 'replay_match'
TreeVisualization = 'tree_visualization'