Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/build-docs-test.yaml
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 8 additions & 2 deletions .github/workflows/sphinx_notes_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions tests/dcop_cli/test_distribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion tests/dcop_cli/test_generate_graphcoloring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions tests/dcop_cli/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
21 changes: 11 additions & 10 deletions tests/dcop_cli/test_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions tests/dcop_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import sys
from os import path

import pydcop


def instance_path(instance_filename):
"""
Expand All @@ -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"

2 changes: 2 additions & 0 deletions tests/unit/test_algorithms_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_infra_orchestratedagents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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