Commit Graph

541 Commits

Author SHA1 Message Date
Chris McCarthy
b46057841d #1706 - Refactored a bunch of if statements in base.py to improve readability 2023-08-09 20:31:42 +01:00
Chris McCarthy
a840159460 #1706 - Fixed the "smart" merging of SimComponent that PyCharm performed. Integrated the Filesystem class into the Node. Added prettytable to deps in pyproject.toml 2023-08-08 20:30:37 +01:00
Chris McCarthy
9fbc3c91f7 #1706 - Finished up the Node and Switch MVP. Added full extensive documentation on what's happening at each step. 2023-08-08 20:22:18 +01:00
Chris McCarthy
4e4c2b501a Merge remote-tracking branch 'devops/dev' into feature/1706_node_class_and_node_type_subclasses
# Conflicts:
#	tests/unit_tests/_primaite/_simulator/test_core.py
2023-08-08 20:05:11 +01:00
Czar Echavez
5f097b7c1b Merged PR 157: File System Class setup
## Summary
Skeleton of the FileSystem for the simulation. Does not have all the requirements for the FileSystem yet, since we need to start somewhere

## Test process
Created unit tests for:
- [FileSystem](https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/157?_a=files&path=/tests/unit_tests/_primaite/_simulator/_file_system/test_file_system.py)
- [FileSystemFolder](https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/157?_a=files&path=/tests/unit_tests/_primaite/_simulator/_file_system/test_file_system_folder.py)
- [FileSystemFile](https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/157?_a=files&path=/tests/unit_tests/_primaite/_simulator/_file_system/test_file_system_file.py)

## Design document
https://dev.azure.com/ma-dev-uk/PrimAITE/_wiki/wikis/PrimAITE.wiki/151/FileSystem

## Checklist
- [x] This PR is linked to a **work item**
- [x] I have performed **self-review** of the code
- [x] I have written **tests** for any new functionality added with this PR
- [ ] I have updated the **documentation** if this PR changes or adds functionality
- [x] I have written/updated **design docs** if this PR implements new functionality.
- [x] I have run **pre-commit** checks for code style

Related work items: #1714
2023-08-08 09:29:46 +00:00
Czar Echavez
2f27e02877 #1714: fix precommit 2023-08-08 09:53:32 +01:00
Czar Echavez
c2b783c858 Apply suggestions from code review 2023-08-08 08:17:40 +00:00
Czar Echavez
f854404ba0 #1714: added file system to changelog 2023-08-08 08:41:50 +01:00
Czar Echavez
c8ee409b3b #1714: run precommit 2023-08-08 08:29:51 +01:00
Chris McCarthy
139d739732 #1706 - Tidies up the sysLog ARPCache, and ICMP classes and integrated them into the Node. Tidied up the base implementation of SoftwareManager and SessionManager. Tidies up the public API for Services and Applications. Added the SwitchPort and Switch classes. Added a basic test in test_frame_transmission.py that tests sending a frame from one node to another across a multi-switch network. 2023-08-07 19:33:52 +01:00
Czar Echavez
700950b856 Apply suggestions from code review 2023-08-07 15:38:15 +00:00
Czar Echavez
a4c193cd34 #1714: apply recommended changes with removing get methods and using the properties directly 2023-08-07 16:20:55 +01:00
Czar Echavez
554619e4b4 #1714: conver file and folder lists to dicts + fixing and adding a few more tests 2023-08-07 14:49:59 +01:00
Czar Echavez
b58a3a3e24 #1714: FileSystemItem is no longer an abstract base class + Added enums and enum sizes + stream lined FileSystemFile init 2023-08-07 11:52:54 +01:00
Czar Echavez
d57c2a936e #1714: remove duplicate method 2023-08-07 10:10:05 +01:00
Czar Echavez
028211d288 #1714: update to use objects instead of uuids + tests 2023-08-07 09:34:59 +01:00
Czar Echavez
46c70ac084 #1714: refactor private attributes and made them public + serialisation tests 2023-08-03 22:20:14 +01:00
Chris McCarthy
04f1cb0dc6 #1706 - Got the code services, application, and process base classes stubbed out. Need them now so that I can leverage them for core node services required. 2023-08-03 21:30:13 +01:00
Chris McCarthy
cac4779244 #1706 - Started adding the core node software required by all nodes. Made some tweaks to the Frame to have send and receive timestamp. 2023-08-03 14:37:55 +01:00
Czar Echavez
b08683fcd3 #1714: fix tests 2023-08-03 12:42:16 +01:00
Czar Echavez
483fa7d841 Merge branch 'dev' into feature/1714-file-system-file-system-folder-and-file-system-file-class-skeletons 2023-08-03 12:15:08 +01:00
Czar Echavez
a0356a7fbc #1714: updated file system classes 2023-08-03 12:14:11 +01:00
Chris McCarthy
209f934abd #1706 - Added some extra logging 2023-08-02 22:01:15 +01:00
Chris McCarthy
897dbdf10c #1706 - Got the core Node class build and working with ARP and the ability to ping another node. Added some basic tests in. Next job is to create the Node subclasses. Then move ARP and ICMP into a service that is used by all nodes. 2023-08-02 21:54:21 +01:00
Christopher McCarthy
3660e27c15 Merged PR 156: Model a minimal implementation of a network Frame
## Summary
- Added the primaite/simulator/network/transmission sub-package with modules for each layer. They come together to build a minimal but fairly realistic network Frame.
- A custom PrimaiteHeader has been included to hold primaite specific metadata required in transmission for reward function and RL agent downstream.
- Added some basic tests that check the proper configuration of Frames with matching headers for protocols.
- Updated the frame typehints in NIC and Link classes.
- Added documentation for the transport layer down to data link layer

## Test process
Unit tests check the frame has been configured correctly with the right headers for the right protocol.

## Checklist
- [X] This PR is linked to a **work item**
- [X] I have performed **self-review** of the code
- [X] I have written **tests** for any new functionality added with this PR
- [X] I have updated the **documentation** if this PR changes or adds functionality
- [X] I have written/updated **design docs** if this PR implements new functionality.
- [X] I have run **pre-commit** checks for code style

Related work items: #1724
2023-08-02 14:25:58 +00:00
Chris McCarthy
95f5515d69 #1724 - Added documentation for the transport layer down to data link layer 2023-08-02 12:12:08 +01:00
Chris McCarthy
9d17a9b0d3 #1724 - Added the primaite/simulator/network/transmission sub-package with modules for each layer. They come together to build a minimal but fairly realistic network Frame. A custom PrimaiteHeader has been included to hold primaite specific metadata required in transmission for reward function and RL agent downstream. Added some basic tests that check the proper configuration of Frames with matching headers for protocols. Updated the frame typehints in NIC and Link classes. 2023-08-01 22:25:00 +01:00
Czar Echavez
841aafd259 Merge branch 'dev' into feature/1714-file-system-file-system-folder-and-file-system-file-class-skeletons 2023-08-01 16:20:08 +01:00
Czar Echavez
ea8c65a17e #1714: set up files 2023-08-01 16:18:49 +01:00
Christopher McCarthy
f41fc241b7 Merged PR 152: Model Link and NIC
## Summary
- #1715 #1715 - Added Link class in physical_layer.py.- Also added NIC class in physical_layer.py for
#1672. Added attributes and public API functions.
- Added test_physical_layer.py with some basic tests ready to house the tests once logic has been implemented.
- Made use of the pydantic model_post_init function for proper ipv4 configuration checking.
- Added NetworkError to exceptions.py.
- Added timestep int as a param to the apply_timestep function in core.py. Also added a reset_component_for_episode function.
- Updated docs with details of Link and NIC.

## Test process
- Added basic unit tests for instantiation that look at proper config and error raising.
- Added an integration test for linking NICs to Link.

## Checklist
- [ ] This PR is linked to a **work item**
- [ ] I have performed **self-review** of the code
- [ ] I have written **tests** for any new functionality added with this PR
- [ ] I have updated the **documentation** if this PR changes or adds functionality
- [ ] I have run **pre-commit** checks for code style

Related work items: #1672, #1715
2023-08-01 12:31:42 +00:00
Chris McCarthy
0f33b837aa #1715 - Fixed up pr code suggestion flake8 issues 2023-08-01 12:45:36 +01:00
Christopher McCarthy
5ee3eff0e9 Apply suggestions from code review 2023-08-01 11:14:36 +00:00
Christopher McCarthy
2769b1bfb1 Apply suggestions from code review 2023-08-01 11:04:16 +00:00
Chris McCarthy
8785089a1c #1715 - Moved IPv4Address conversions to the NIC init. Mak wake_on_lan not optional. Ignored ANN002 and ANN003 in .flake8 so we don't get silly 'ANN002 Missing type annotation for *args' and 'ANN003 Missing type annotation for **kwargs' flake8 failures 2023-08-01 10:32:16 +01:00
Chris McCarthy
557caeaac4 #1715 - Added suppress-none-returning and suppress-dummy-args to .flake8 as flake8-annotations can get very annoying 2023-08-01 08:19:28 +01:00
Chris McCarthy
c05cb62aa9 Merge branch 'dev' into feature/1715_model_link 2023-08-01 08:12:39 +01:00
Marek Wolan
0f0c61642c Merged PR 151: Check type hints with pre-commit
## Summary
Added `flake8-annotations` to the pre-commit hooks. This ensures that we all write type hints for all new code.

There's also a minor unrelated addition to the pre-commit template.

## Test process
I tried adding a function with a parameter but no typehint. Git did not allow me to commit this.

## Checklist
- [x] This PR is linked to a **work item**
- [x] I have performed **self-review** of the code
- [x] I have written **tests** for any new functionality added with this PR
- [x] I have updated the **documentation** if this PR changes or adds functionality
- [x] I have run **pre-commit** checks for code style

Related work items: #1721
2023-07-31 19:34:48 +00:00
Chris McCarthy
e4b6f266e8 #1715 - Added timestep int as a param to the apply_timestep function in core.py. Also added a reset_component_for_episode function. Updated docs with details of Link and NIC. 2023-07-31 20:05:36 +01:00
Marek Wolan
3324a8caae Apply suggestions from code review 2023-07-31 18:54:29 +00:00
Marek Wolan
c1bb6d8b7f Update the PR template 2023-07-31 17:09:38 +01:00
Marek Wolan
9cf5bfa1b2 Fix typehint issues 2023-07-31 17:07:56 +01:00
Marek Wolan
0a079832e9 Add self,cls to flake8-ann ignore list 2023-07-31 17:00:28 +01:00
Chris McCarthy
0532db960a #1715 - Added more tests. MAde use of the pydantic model_post_init function for proper ipv4 cofiguration checking. Added NetworkError to exceptions.py. 2023-07-31 16:55:45 +01:00
Marek Wolan
c4adc2f543 add flake8-annotations to pre-commits 2023-07-31 16:47:13 +01:00
Chris McCarthy
59394c3642 #1715 - Added Link class in physical_layer.py. Also added NIC class in physical_layer.py for #1672. Added attributes and public API functions. test_physical_layer.py ready to house the tests once logic has been implemented. 2023-07-31 15:55:22 +01:00
Marek Wolan
020682f546 Merged PR 149: Base class for Simulation Components
## Summary
This introduces a base class for all simulation components. The idea behind this is to formalise the way in which data is extracted from the simulator and the way actions are applied to the different aspects of the simulator.

The intention is that any class that simulates something will inherit from SimComponent (which inherits from pydantic BaseModel).

Actions enter the simulator as a list of strings that is intended to be peeled back as you go down the layers of the simulation. For example we could have an action of `["network", "nodes", "node3", "network_interface_card", "disable"]` This list is passed to the `apply_action()` function of the overall simulation controller. The simulation controller looks at the first word on the list, `network` and uses this to select a method that can apply the function. It passes the remainder of the list as an argument to that function. In this case it will be `["nodes", "node3", "network_interface_card", "disable"]`.

To the reviewers, please validate that you're happy with the implicit design choices I've made while implementing this. Especially the contract passing actions down the components tree.

(also I changed some mentions of agent to agent_abc in the docs as it was complaining and refusing to build.)

## Test process
I have written basic unit tests to check that the custom functionality added to SimComponent doesn't interfere with basic pydantic functionality.
I also started doc pages that explains these concepts to potential developers, although once there are subclasses of this core class, it will be easier to populate the docs with concrete examples.

## Checklist
- [x] This PR is linked to a **work item**
- [x] I have performed **self-review** of the code
- [x] I have written **tests** for any new functionality added with this PR
- [x] I have updated the **documentation** if this PR changes or adds functionality
- [x] I have run **pre-commit** checks for code style
- [x] I have **type hinted** all the code I changed.

Related work items: #1709
2023-07-31 12:43:07 +00:00
Marek Wolan
954026d3e0 Comment out RLLib support 2023-07-31 12:13:52 +01:00
Marek Wolan
a486780fba Add timestep function 2023-07-31 11:39:33 +01:00
Marek Wolan
fa2cdf853c Drop Ray 2023-07-31 11:27:16 +01:00
Marek Wolan
8e2ef1b695 Apply suggestions from code review 2023-07-31 10:25:29 +00:00