diff --git a/.azure/artifact-release-pipeline.yaml b/.azure/artifact-release-pipeline.yaml index 7c375812..47e9aacc 100644 --- a/.azure/artifact-release-pipeline.yaml +++ b/.azure/artifact-release-pipeline.yaml @@ -15,16 +15,17 @@ steps: displayName: 'Use Python $(python.version)' - script: | - python -m pip install --upgrade pip - pip install build - pip install wheel + python -m pip install --upgrade pip==23.0.1 + pip install wheel==0.38.4 --upgrade + pip install setuptools==66 --upgrade + pip install build==0.10.0 pip install twine pip install keyring pip install artifacts-keyring displayName: 'Install build dependencies' - script: | - python setup.py sdist bdist_wheel + python -m build displayName: 'Build PrimAITE sdist and wheel' - task: TwineAuthenticate@1 @@ -33,5 +34,5 @@ steps: artifactFeed: PrimAITE/PrimAITE - script: | - python -m twine upload --verbose -r PrimAITE --config-file $(PYPIRC_PATH) dist/* + python -m twine upload --verbose -r PrimAITE --config-file $(PYPIRC_PATH) dist/*.whl displayName: 'Artifact Upload' diff --git a/.azure/azure-build-deploy-docs-pipeline.yml b/.azure/azure-build-deploy-docs-pipeline.yml new file mode 100644 index 00000000..94980313 --- /dev/null +++ b/.azure/azure-build-deploy-docs-pipeline.yml @@ -0,0 +1,45 @@ +name: Azure Static Web Apps CI/CD + +pr: none +trigger: + branches: + include: + - dev + +jobs: +- job: build_and_deploy_job + displayName: Build and Deploy Job + condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI'))) + pool: + vmImage: ubuntu-latest + variables: + - group: Azure-Static-Web-Apps-nice-bay-0ad032c03-variable-group + steps: + - checkout: self + submodules: true + + - script: | + python -m pip install --upgrade pip==23.0.1 + pip install wheel==0.38.4 --upgrade + pip install setuptools==66 --upgrade + pip install build==0.10.0 + displayName: 'Install build dependencies' + + - script: | + pip install -e .[dev] + displayName: 'Install Yawning-Titan for docs autosummary' + + - script: | + cd docs + make html + cd .. + cd .. + displayName: 'Build Docs' + + - task: AzureStaticWebApp@0 + inputs: + azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_NICE_BAY_0AD032C03) + app_location: "/docs/_build/html" + api_location: "" + output_location: "/" + displayName: 'Deploy Docs to nice-bay-0ad032c03' diff --git a/.azure/azure-ci-build-pipeline.yaml b/.azure/azure-ci-build-pipeline.yaml new file mode 100644 index 00000000..663859a5 --- /dev/null +++ b/.azure/azure-ci-build-pipeline.yaml @@ -0,0 +1,52 @@ +trigger: +- main +- dev +- feature/* +- hotfix/* +- bugfix/* +- release/* + +pool: + vmImage: ubuntu-latest +strategy: + matrix: + Python38: + python.version: '3.8' + Python39: + python.version: '3.9' + Python310: + python.version: '3.10' + Python311: + python.version: '3.11' + +steps: +- task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + displayName: 'Use Python $(python.version)' + +- script: | + python -m pip install --upgrade pip==23.0.1 + pip install wheel==0.38.4 --upgrade + pip install setuptools==66 --upgrade + pip install build==0.10.0 + pip install pytest-azurepipelines + displayName: 'Install build dependencies' + +- script: | + python -m build + displayName: 'Build PrimAITE' + +- script: | + PRIMAITE_WHEEL=$(ls ./dist/primaite*.whl) + python -m pip install $PRIMAITE_WHEEL[dev] + displayName: 'Install PrimAITE' + +#- script: | +# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics +# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +# displayName: 'Lint with flake8' + +- script: | + pytest tests/ + displayName: 'Run unmarked tests' diff --git a/.gitignore b/.gitignore index 341fd528..ce42d9a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ # PrimAITE Package -PRIMAITE/outputs -PRIMAITE/outputs/* +src/primaite/outputs +src/primaite/outputs/* +src/primaite/logs +src/primaite/logs/* TestResults # Byte-compiled / optimized / DLL files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a08b17b8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + - repo: http://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + args: ['--maxkb=1000'] + - id: mixed-line-ending + - id: requirements-txt-fixer + - repo: http://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + - repo: http://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + args: [ "--profile", "black" ] + - repo: http://github.com/PyCQA/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + additional_dependencies: [ flake8-docstrings ] diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf1..d4bb2cbb 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,8 +5,8 @@ # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build +SOURCEDIR = . +BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: diff --git a/docs/source/conf.py b/docs/conf.py similarity index 50% rename from docs/source/conf.py rename to docs/conf.py index 0a2841c8..1df15ab1 100644 --- a/docs/source/conf.py +++ b/docs/conf.py @@ -5,24 +5,37 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +import os +import sys +import datetime +import furo +sys.path.insert(0, os.path.abspath("../")) -project = 'PrimAITE' -copyright = '2022, jashort' -author = 'jashort' -release = '0.1.0' + +# -- Project information ----------------------------------------------------- +year = datetime.datetime.now().year +project = "primaite" +copyright = f"Copyright (C) QinetiQ Training and Simulation Ltd 2021 - {year}" +author = "QinetiQ Training and Simulation Ltd" + +# The short Major.Minor.Build version +with open("../src/primaite/VERSION", "r") as file: + version = file.readline() +# The full version, including alpha/beta/rc tags +release = version # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -extensions = ['sphinx_rtd_theme'] +extensions = [] -templates_path = ['_templates'] -exclude_patterns = [] +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'sphinx_rtd_theme' -html_static_path = ['_static'] +html_theme = "furo" +html_static_path = ["_static"] diff --git a/docs/source/index.rst b/docs/index.rst similarity index 77% rename from docs/source/index.rst rename to docs/index.rst index 5e235bba..b92d493e 100644 --- a/docs/source/index.rst +++ b/docs/index.rst @@ -9,11 +9,11 @@ Welcome to PrimAITE's documentation What is PrimAITE? ------------------------ -PrimAITE (Primary-level AI Training Environment) is a simulation environment for training AI under the ARCD programme​. It incorporates the functionality required of a Primary-level environment, as specified in the Dstl ARCD Training Environment Matrix document:​ +PrimAITE (Primary-level AI Training Environment) is a simulation environment for training AI under the ARCD programme. It incorporates the functionality required of a Primary-level environment, as specified in the Dstl ARCD Training Environment Matrix document:​ -* The ability to model a relevant platform / system context; -* The ability to model key characteristics of a platform / system by representing connections, IP addresses, ports, traffic loading, operating systems, file system, services and processes; -* Operates at machine-speed to enable fast training cycles. +* The ability to model a relevant platform / system context; +* The ability to model key characteristics of a platform / system by representing connections, IP addresses, ports, traffic loading, operating systems, file system, services and processes; +* Operates at machine-speed to enable fast training cycles. PrimAITE aims to evolve into an ARCD environment that could be used as the follow-on from Reception level approaches (e.g. YAWNING TITAN), and help bridge the Sim-to-Real gap into Secondary level environments (e.g. IMAGINARY YAK)​. @@ -35,8 +35,8 @@ The best place to start is :ref:`about` :maxdepth: 8 :caption: Contents: - about - dependencies - config - session - results + source/about + source/dependencies + source/config + source/session + source/results diff --git a/docs/make.bat b/docs/make.bat index dc1312ab..954237b9 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -7,8 +7,8 @@ REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) -set SOURCEDIR=source -set BUILDDIR=build +set SOURCEDIR=. +set BUILDDIR=_build %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( diff --git a/pyproject.toml b/pyproject.toml index fa026ae5..23804231 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,6 +55,7 @@ dev = [ "pytest-cov==4.0.0", "pytest-flake8==1.1.1", "pip-licenses==4.3.0", + "pre-commit==2.20.0", "wheel==0.38.4", "build==0.10.0" ] diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..e618d7a5 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +testpaths = + tests diff --git a/src/VERSION b/src/primaite/VERSION similarity index 100% rename from src/VERSION rename to src/primaite/VERSION diff --git a/src/primaite/config/config_main.yaml b/src/primaite/config/config_main.yaml index 4c16750f..f0940c0d 100644 --- a/src/primaite/config/config_main.yaml +++ b/src/primaite/config/config_main.yaml @@ -7,7 +7,7 @@ # "GENERIC" agentIdentifier: STABLE_BASELINES3_A2C # Number of episodes to run per session -numEpisodes: 10000 +numEpisodes: 10 # Time delay between steps (for generic agents) timeDelay: 10 # Filename of the scenario / laydown diff --git a/src/primaite/Main.py b/src/primaite/main.py similarity index 100% rename from src/primaite/Main.py rename to src/primaite/main.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..63f825c2 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1 @@ +# Crown Copyright (C) Dstl 2022. DEFCON 703. Shared in confidence.