Giter VIP home page Giter VIP logo

trendingtechnology / qiskitbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from infiniteregrets/qiskitbot

0.0 2.0 0.0 965 KB

Discord Bot that leverages the idea of nested containers using podman, runs untrusted user input, executes Quantum Circuits, allows users to refer to the Qiskit Documentation, and provides the ability to search questions on the Quantum Computing StackExchange.

License: MIT License

Dockerfile 4.07% Python 95.41% Shell 0.52%

qiskitbot's Introduction

QiskitBot

A discord bot that allows you to execute Quantum Circuits, look up the IBMQ Qiskit's Documentation, and search questions on the Quantum Computing StackExchange


๐Ÿ’• Qiskit Community

This project is not affiliated with IBM in any way. But I would like to thank Brian Ingmanson (Education Community Manager at IBM) for being so encouraging and supportive towards this little project!

Installation

  • Podman Version

Using docker-compose:

docker-compose up --build 

Manually from the Dockerfile

docker build -t qiskitbot . 
docker run --privileged -i -t qiskitbot 

On MacOs with deploy.sh

zsh deploy.sh
  • Docker Python SDK version
python3 -B . 

Make sure you have Docker installed and running on your machine.

Disclaimer

Builds might fail on your machine. This is still under testing and there is a lot that needs to be fixed with the way the code is structured. Once everything is smooth, I will add docstrings and comments wherever neccessary. This was just a hobby project, but I do plan on extending it further.

Versions

There are two versions that I have been working on. One that uses the Docker Python SDK and one that launches containers using Podman inside a container controlled by Docker. The Docker Python SDK version is much faster when it comes to rendering simple circuits, so that is what you should be probably looking at.

Architecture of the sandbox (running untrusted code) [Podman]

Goal

Spawn a container per user inside a container launched by docker, providing an isolated environment to run untrusted code. Save the state of the user using CRIU (checkpoint and restore).

Checkpointing and restoring is easy with Podman:

podman container checkpoint <container_id>
podman container restore <container_id>

As of now this feature is unimplemented, but methods for checkpoint and restore are available in cogs/circuit.py

Nested Containers

One of the main objectives of this project was to experiment with the idea of having containers inside of containers. Instead of mounting the unix socket and the spawning containers (the tradional way):

docker run -v /var/run/docker.sock:/var/run/docker.sock ...

I used podman inside of docker, which is a daemonless container engine used for developing, managing, and running OCI Containers. Podman is used with tools like Buildah and Skopeo, which not only makes managing images and containers easy but in my opinion much more powerful than docker!

Initial Idea - Using NsJail With Podman

To use podman inside a container launched by docker with nsjail you need to use the --privileged flag while running your container. Running a container without this flag works just fine, but the problem arises, when using this flag, as the capabilities of podman and docker don't match. This means you can't run privileged podman containers inside of a docker container as required by NsJail. "CAP_PERFMON","CAP_BPF", "CAP_CHECKPOINT_RESTORE" are not supported by docker. See issue #10282 on containers/podman Eventually after a lot of experimentation, I dropped this idea. (refer to the Dockerfile in the root directory)

Usage

<@Qiskit>asciicircuit \`\`\` <codeblock> \`\`\`

<@Qiskit>mplcircuit \`\`\` <codeblock> \`\`\`

<@Qiskit>docs <searchitem> 

<@Qiskit>mplplot  \`\`\` <codeblock> \`\`\`

<@Qiskit>query <search criteria>

qiskitbot's People

Contributors

infiniteregrets avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.