diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4a66a55..154107c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,10 +6,21 @@ ENV DEBIAN_FRONTEND noninteractive # Set up user ARG USER=vagrant ENV PATH /home/${USER}/.local/bin:$PATH -RUN groupadd -r ${USER} && useradd -m -r -s /bin/bash -g ${USER} ${USER} +RUN groupadd -r ${USER} && \ + useradd -m -r -s /bin/bash -g ${USER} ${USER} + +RUN apt-get update -y && \ + apt-get install -y --no-install-recommends \ + sudo && \ + apt-get clean && \ + echo -n "${USER}:${USER}" | chpasswd && \ + echo "${USER} ALL = NOPASSWD: ALL" > /etc/sudoers.d/${USER} && \ + chmod 440 /etc/sudoers.d/${USER} USER ${USER} +RUN pip install --upgrade pip wheel setuptools tox + # Install poetry RUN curl -sSL https://install.python-poetry.org | python3 - @@ -24,7 +35,6 @@ USER root RUN apt-get update -y && \ apt-get install -y --no-install-recommends \ ssh \ - sudo \ ca-certificates \ curl \ gnupg \ @@ -32,10 +42,6 @@ RUN apt-get update -y && \ openssh-client && \ apt-get clean -RUN echo -n "${USER}:${USER}" | chpasswd && \ - echo "${USER} ALL = NOPASSWD: ALL" > /etc/sudoers.d/${USER} && \ - chmod 440 /etc/sudoers.d/${USER} - RUN sed -i -e 's/Defaults.*requiretty/#&/' /etc/sudoers && \ sed -i -e 's/\(UsePAM \)yes/\1 no/' /etc/ssh/sshd_config && \ mkdir -p /var/run/sshd /home/${USER}/.ssh/ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 14327de..6713923 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,33 +1,21 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/python-3 { - "name": "Python 3.10", - "build": { - "dockerfile": "Dockerfile", - "context": "..", - "target": "vscode", - "args": { - "USER": "vscode" + "name": "QI2 SDK", + "dockerComposeFile": [ + "./docker-compose.yaml" + ], + "service": "qi2sdk", + "workspaceFolder": "/workspace", + "shutdownAction": "stopCompose", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance" + ] } }, - "settings": { - "python.defaultInterpreterPath": "/usr/local/bin/python", - "python.linting.enabled": true, - "python.linting.pylintEnabled": true, - "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", - "python.formatting.blackPath": "/usr/local/py-utils/bin/black", - "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", - "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", - "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", - "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", - "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", - "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", - "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" - }, // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance" - ], "remoteUser": "vscode" } \ No newline at end of file diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml new file mode 100644 index 0000000..f86f95c --- /dev/null +++ b/.devcontainer/docker-compose.yaml @@ -0,0 +1,15 @@ +version: '3.8' + +services: + qi2sdk: + build: + context: . + dockerfile: Dockerfile + target: vscode + args: + USER: vscode + platform: linux/amd64 + command: /bin/sh -c "while sleep 1000; do :; done" + volumes: + - ..:/workspace:cached + user: vscode diff --git a/examples/qaoa.py b/examples/qaoa.py index 1c1d48e..af33211 100644 --- a/examples/qaoa.py +++ b/examples/qaoa.py @@ -133,7 +133,7 @@ def f(theta): return f -async def execute(qi) -> None: +def execute(qi) -> None: """Run the entire qaoa alogrithm. Args: diff --git a/quantuminspire/util/configuration.py b/quantuminspire/util/configuration.py index 418c6bd..ad37683 100644 --- a/quantuminspire/util/configuration.py +++ b/quantuminspire/util/configuration.py @@ -16,7 +16,9 @@ def ensure_config_file_exists(file_path: Path, file_encoding: Optional[str]) -> """ if not file_path.exists(): file_path.parent.mkdir(parents=True, exist_ok=True) - file_path.open("w", encoding=file_encoding).write("{}") + file_path.open("w", encoding=file_encoding).write( + '{"auths": {"https://staging.qi2.quantum-inspire.com": {"user_id": 1}}}' + ) def json_config_settings(settings: BaseSettings) -> Any: diff --git a/tests/util/test_configuration.py b/tests/util/test_configuration.py index 93e9c1e..4e1d6d8 100644 --- a/tests/util/test_configuration.py +++ b/tests/util/test_configuration.py @@ -12,7 +12,9 @@ def test_force_file_into_existence_file_does_not_exist(self) -> None: configuration.ensure_config_file_exists(path, "utf-8") path.parent.mkdir.assert_called_once_with(parents=True, exist_ok=True) path.open.assert_called_once_with("w", encoding="utf-8") - open_mock.write.assert_called_once_with("{}") + open_mock.write.assert_called_once_with( + '{"auths": {"https://staging.qi2.quantum-inspire.com": {"user_id": 1}}}' + ) def test_force_file_into_existence_file_exists(self) -> None: path = MagicMock()