Skip to content

Commit

Permalink
[QI2-663] Make devcontainer work with ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
oschusler committed Oct 27, 2023
1 parent b2c0b15 commit 9cb2dc0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 33 deletions.
18 changes: 12 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 -

Expand All @@ -24,18 +35,13 @@ USER root
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
ssh \
sudo \
ca-certificates \
curl \
gnupg \
lsb-release \
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/
Expand Down
46 changes: 21 additions & 25 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
// 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",
// "build": {
// "dockerfile": "Dockerfile",
// "context": "..",
// "target": "vscode",
// "args": {
// "USER": "vscode"
// }
// },
"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"
}
15 changes: 15 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion examples/qaoa.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def f(theta):
return f


async def execute(qi) -> None:
def execute(qi) -> None:
"""Run the entire qaoa alogrithm.
Args:
Expand Down
4 changes: 3 additions & 1 deletion quantuminspire/util/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9cb2dc0

Please sign in to comment.