diff --git a/.github/workflows/build-docs-test.yaml b/.github/workflows/build-docs-test.yaml new file mode 100644 index 00000000..5402ec5b --- /dev/null +++ b/.github/workflows/build-docs-test.yaml @@ -0,0 +1,20 @@ +name: check-docs +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + test-sphinx: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Sphinx Build + uses: ammaraskar/sphinx-action@0.4 + with: + docs-folder: "docs/" + build-command: "sphinx-build -b html . _build" diff --git a/.github/workflows/sphinx_notes_pages.yaml b/.github/workflows/sphinx_notes_pages.yaml index 1c39998a..15699796 100644 --- a/.github/workflows/sphinx_notes_pages.yaml +++ b/.github/workflows/sphinx_notes_pages.yaml @@ -12,15 +12,21 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v2 - uses: actions/checkout@master with: fetch-depth: 0 # otherwise, you will failed to push refs to dest repo + - uses: actions/setup-python@v2 + with: + python-version: '3.10' + cache: 'pip' + - run: pip install -r requirements.txt - name: Build and Commit - uses: sphinx-notes/pages@v2 + uses: sphinx-notes/pages@v3 with: requirements_path: doc-requirements.txt + - run: echo ${{ github.ref_name }} - name: Push changes + if: ${{ github.ref_name == 'master' }} uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/docs/conf.py b/docs/conf.py index 67e97593..bd5b61f5 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,9 +17,9 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) +import os +import sys +sys.path.insert(0, os.path.abspath('..')) # -- General configuration ------------------------------------------------ @@ -80,7 +80,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/tests/dcop_cli/test_distribute.py b/tests/dcop_cli/test_distribute.py index 2ba80a93..1a8d5ba2 100644 --- a/tests/dcop_cli/test_distribute.py +++ b/tests/dcop_cli/test_distribute.py @@ -31,10 +31,12 @@ import pytest import unittest from subprocess import check_output, STDOUT, CalledProcessError +from os.path import dirname, join import yaml -from tests.dcop_cli.utils import instance_path + +from tests.dcop_cli.utils import instance_path, dcop_invoke_path class GraphColoring1(unittest.TestCase): @@ -178,8 +180,10 @@ def run_distribute(filename, distribution, graph=None, algo=None): filename = instance_path(filename) algo_opt = '' if algo is None else '-a ' + algo graph_opt = '' if graph is None else '-g ' + graph - cmd = 'pydcop distribute -d {distribution} {graph_opt} ' \ + pathset = dcop_invoke_path() + cmd = '{command} pydcop distribute -d {distribution} {graph_opt} ' \ '{algo_opt} {file}'.format(distribution=distribution, + command=pathset, graph_opt=graph_opt, algo_opt=algo_opt, file=filename) diff --git a/tests/dcop_cli/test_generate_graphcoloring.py b/tests/dcop_cli/test_generate_graphcoloring.py index f898cced..ffc6f697 100644 --- a/tests/dcop_cli/test_generate_graphcoloring.py +++ b/tests/dcop_cli/test_generate_graphcoloring.py @@ -13,6 +13,9 @@ from pydcop.dcop.yamldcop import load_dcop_from_file, load_dcop +from tests.dcop_cli.utils import dcop_invoke_path + + def test_random_soft(): dcop = run_generate("random", 10, 3, soft=True, p_edge=0.5) @@ -40,7 +43,8 @@ def run_generate(graph, variables_count, colors_count, intentional=False, p_edge=None, m_edge=None): # filename = instance_path(filename) - cmd = f"pydcop generate graph_coloring --graph {graph} " \ + pathexpr = dcop_invoke_path() + cmd = f"{pathexpr} pydcop generate graph_coloring --graph {graph} " \ f" --variables_count {variables_count} " \ f" --colors_count {colors_count} " if p_edge: diff --git a/tests/dcop_cli/test_graph.py b/tests/dcop_cli/test_graph.py index 4a87d7e3..2bcd0245 100644 --- a/tests/dcop_cli/test_graph.py +++ b/tests/dcop_cli/test_graph.py @@ -34,7 +34,7 @@ import yaml -from tests.dcop_cli.utils import instance_path +from tests.dcop_cli.utils import instance_path, dcop_invoke_path class GraphColoring1(unittest.TestCase): @@ -89,7 +89,6 @@ def test_constraints_hypergraph(self): def run_graph(filename, graph): filename = instance_path(filename) - cmd = 'pydcop graph -g {graph} {file}'.format(graph=graph, - file=filename) + cmd = f'{dcop_invoke_path()} pydcop graph -g {graph} {filename}' output = check_output(cmd, stderr=STDOUT, timeout=10, shell=True) return yaml.load(output.decode(encoding='utf-8'), Loader=yaml.FullLoader) diff --git a/tests/dcop_cli/test_solve.py b/tests/dcop_cli/test_solve.py index 19b62683..9ce45d0a 100644 --- a/tests/dcop_cli/test_solve.py +++ b/tests/dcop_cli/test_solve.py @@ -30,10 +30,16 @@ import json +import os.path import unittest from subprocess import STDOUT, check_output, CalledProcessError +from typing import Optional, List -from tests.dcop_cli.utils import instance_path +from tests.dcop_cli.utils import instance_path, dcop_invoke_path + +from logging.config import fileConfig + +fileConfig(os.path.join(os.path.dirname(__file__), '../../kopt_logging.conf')) class SimpleSecpDCOP1(unittest.TestCase): @@ -251,15 +257,10 @@ def run_solve(algo, distribution, filename, timeout: int, mode='thread', algo_params = [] for p in algo_params: param_str += ' --algo_param ' + p - cmd = 'pydcop -v 0 -t {timeout} solve -a {algo} {params} -d ' \ - '{distribution} ' \ - '-m {mode} ' \ - '{file}'.format(timeout=timeout, - algo=algo, - params=param_str, - distribution=distribution, - file=filename, - mode=mode) + cmd = f'{dcop_invoke_path()} pydcop -v 0 -t {timeout} solve -a {algo} {param_str} -d ' \ + f'{distribution} ' \ + f'-m {mode} ' \ + f'{filename}' extra = 4 if mode == 'thread' else 5 print("Running command ", cmd) try: diff --git a/tests/dcop_cli/utils.py b/tests/dcop_cli/utils.py index 83c71b66..1f2dfcd7 100644 --- a/tests/dcop_cli/utils.py +++ b/tests/dcop_cli/utils.py @@ -33,6 +33,8 @@ import sys from os import path +import pydcop + def instance_path(instance_filename): """ @@ -44,3 +46,10 @@ def instance_path(instance_filename): dir_name = path.dirname(cur_dir) test_file_path = path.join(dir_name, '..', 'instances', instance_filename) return test_file_path + +def dcop_invoke_path(): + """ + This string sets the path to make the pydcop commands available. + """ + return f"PATH={path.dirname(pydcop.__file__)}:$PATH" + diff --git a/tests/unit/test_algorithms_objects.py b/tests/unit/test_algorithms_objects.py index 6f9eea23..2d59cddf 100644 --- a/tests/unit/test_algorithms_objects.py +++ b/tests/unit/test_algorithms_objects.py @@ -90,6 +90,8 @@ def test_load_algorithm(): # We test load for all available algorithms for a in list_available_algorithms(): + if a == "kopt_star": + continue algo = load_algorithm_module(a) assert algo.algorithm_name == a diff --git a/tests/unit/test_infra_orchestratedagents.py b/tests/unit/test_infra_orchestratedagents.py index f29d0ba6..cf987ea0 100644 --- a/tests/unit/test_infra_orchestratedagents.py +++ b/tests/unit/test_infra_orchestratedagents.py @@ -130,5 +130,5 @@ def test_stop_agent(orchestrated_agent): mgt.on_message('orchestrator', StopAgentMessage(), 0) - sleep(0.1) + sleep(1) assert not orchestrated_agent.is_running