#3110 Getting-information-out-of-PrimAITE changes:
- New text that explains that this notebook uses UC2 - New text which informs users that sys_logs slow down training a lot - New code snippet for the .describe_method()
This commit is contained in:
@@ -27,7 +27,6 @@
|
|||||||
"# Imports\n",
|
"# Imports\n",
|
||||||
"import yaml\n",
|
"import yaml\n",
|
||||||
"from primaite import PRIMAITE_CONFIG\n",
|
"from primaite import PRIMAITE_CONFIG\n",
|
||||||
"\n",
|
|
||||||
"from primaite.config.load import data_manipulation_config_path\n",
|
"from primaite.config.load import data_manipulation_config_path\n",
|
||||||
"from primaite.session.environment import PrimaiteGymEnv\n",
|
"from primaite.session.environment import PrimaiteGymEnv\n",
|
||||||
"from primaite.simulator.network.hardware.nodes.host.computer import Computer\n",
|
"from primaite.simulator.network.hardware.nodes.host.computer import Computer\n",
|
||||||
@@ -39,7 +38,14 @@
|
|||||||
"with open(data_manipulation_config_path(), 'r') as f:\n",
|
"with open(data_manipulation_config_path(), 'r') as f:\n",
|
||||||
" cfg = yaml.safe_load(f)\n",
|
" cfg = yaml.safe_load(f)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"env = PrimaiteGymEnv(env_config=cfg)\n"
|
"env = PrimaiteGymEnv(env_config=cfg)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"This notebook opts to use the [data manipulation scenario](./Data-Manipulation-E2E-Demonstration.ipynb) (also known as UC2) network configuration but all of the methods demonstrated are config agnostic and can be used in any PrimAITE scenario."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -53,7 +59,9 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"The network can be visualised by running the code below."
|
"Some of the simpler networks can be visualised by using the `.draw()` method as show in the code snippet below. \n",
|
||||||
|
"\n",
|
||||||
|
"Larger networks will still render but users may prefer to create their own network diagrams via other tooling as shown in the [UC7 notebooks](./UC7-E2E-Demo.ipynb)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -75,7 +83,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"Any object created using the ``SimComponent`` class has a ``describe_state`` method which can show the state of the object.\n",
|
"Any object created using the ``SimComponent`` class has a ``describe_state`` method which can show the state of the object.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"An example of such an object is ``Computer`` which inherits from ``SimComponent``. In the default network configuration, ``client_1`` is a Computer object."
|
"An example of such an object is ``Computer`` which inherits from ``SimComponent``. As this notebook utilises the [UC2 network configuration]((./Data-Manipulation-E2E-Demonstration.ipynb)) we can initialise the **client_1** node and confirm that it's a ``Computer`` object."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -94,9 +102,9 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"### More specific describe_state\n",
|
"### More specific describe_state\n",
|
||||||
"\n",
|
"\n",
|
||||||
"As you can see, the output from the ``describe_state`` method for the ``Computer`` object includes the describe state for all its components. This can cause a large describe state output.\n",
|
"As you can see, the output from the ``describe_state`` method for the ``Computer`` object includes the describe state for all its component which causes a rather large output.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"As stated, the ``describe_state`` can be called on any object that inherits ``SimComponent``. This can allow you retrieve the state of a specific item."
|
"As stated, the ``describe_state`` can be called on any object that inherits ``SimComponent``. Meaning, we can narrow down our output by retrieving the state of a specific item. The code snippet below calls the `describe_state` method on **client_1**'s filesystem."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -112,11 +120,29 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"## System Logs\n",
|
"It's worth reiterating that the `describe_state()` method can be used on literally any object that inherits from ``SimComponent``. For example, even the system default **'admin'** user inherits ``.describe_state()``:"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"client_1.user_manager.admins.get(\"admin\").describe_state()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## System Logs \n",
|
||||||
"\n",
|
"\n",
|
||||||
"Objects that inherit from the ``Node`` class will inherit the ``sys_log`` attribute.\n",
|
"Objects that inherit from the ``Node`` class will inherit the ``sys_log`` attribute.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"This is to simulate the idea that items such as Computer, Routers, Servers, etc. have a logging system used to diagnose problems."
|
"This is to simulate the idea that items such as Computer, Routers, Servers, etc. have a logging system used to diagnose problems.\n",
|
||||||
|
"\n",
|
||||||
|
"Enabling this functionality will slow down training time due to the amount of sheer amount of logs created therefore it's recommended to disable these logs when training/evaluating agents."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -134,9 +160,6 @@
|
|||||||
"PRIMAITE_CONFIG[\"developer_mode\"][\"enabled\"] = True\n",
|
"PRIMAITE_CONFIG[\"developer_mode\"][\"enabled\"] = True\n",
|
||||||
"PRIMAITE_CONFIG[\"developer_mode\"][\"output_sys_logs\"] = True\n",
|
"PRIMAITE_CONFIG[\"developer_mode\"][\"output_sys_logs\"] = True\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"# Remake the environment\n",
|
"# Remake the environment\n",
|
||||||
"env = PrimaiteGymEnv(env_config=cfg)\n",
|
"env = PrimaiteGymEnv(env_config=cfg)\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -146,9 +169,6 @@
|
|||||||
"# show sys logs on terminal\n",
|
"# show sys logs on terminal\n",
|
||||||
"client_1.sys_log.show()\n",
|
"client_1.sys_log.show()\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"# restore config\n",
|
"# restore config\n",
|
||||||
"PRIMAITE_CONFIG[\"developer_mode\"][\"enabled\"] = was_enabled\n",
|
"PRIMAITE_CONFIG[\"developer_mode\"][\"enabled\"] = was_enabled\n",
|
||||||
"PRIMAITE_CONFIG[\"developer_mode\"][\"output_sys_logs\"] = was_syslogs_enabled"
|
"PRIMAITE_CONFIG[\"developer_mode\"][\"output_sys_logs\"] = was_syslogs_enabled"
|
||||||
|
|||||||
Reference in New Issue
Block a user