Skip to content
Draft
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
8 changes: 5 additions & 3 deletions .github/actions/prepare_container_test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ runs:
with:
python-version: 3.7

- name: Install pipenv
- name: Install dependencies
shell: bash
run: pip install pipenv
working-directory: ./scripts
run: |
pip install -U pip
pip install pytest
pip install ./packages/client/libclient-py

- name: Set up Docker buildx
id: buildx
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/test-server-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ jobs:
- uses: ./.github/actions/prepare_container_test

- name: Run container test
run: |
pipenv sync
pipenv install --skip-lock ../../packages/client/libclient-py
pipenv run pytest ./tests/test_up.py -s -v -log-cli-level=DEBUG
run: pytest ./tests/test_up.py -s -v -log-cli-level=DEBUG
working-directory: ./scripts/container_test

medium_test_container_restart:
Expand Down Expand Up @@ -284,10 +281,7 @@ jobs:
- uses: ./.github/actions/prepare_container_test

- name: Run container test
run: |
pipenv sync
pipenv install --skip-lock ../../packages/client/libclient-py
pipenv run pytest ./tests/test_restart_request.py::test_success_${{ matrix.test_name }}_with_restart -s -v -log-cli-level=DEBUG
run: pytest ./tests/test_restart_request.py::test_success_${{ matrix.test_name }}_with_restart -s -v -log-cli-level=DEBUG
working-directory: ./scripts/container_test

medium_test_container_down:
Expand Down Expand Up @@ -321,10 +315,7 @@ jobs:
- uses: ./.github/actions/prepare_container_test

- name: Run container test
run: |
pipenv sync
pipenv install --skip-lock ../../packages/client/libclient-py
pipenv run pytest ./tests/test_down_request.py::test_failed_${{ matrix.test_name }}_with_down -s -v -log-cli-level=DEBUG
run: pytest ./tests/test_down_request.py::test_failed_${{ matrix.test_name }}_with_down -s -v -log-cli-level=DEBUG
working-directory: ./scripts/container_test

medium_test_container:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ __pycache__
**/db/*/**
!**/db/**/.gitkeep

scripts/.env
scripts/.env

docs/**/_build/**
docs/**/_generated/**
34 changes: 34 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.7"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/libclient-py/source/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- method: pip
path: ./packages/client/libclient-py
extra_requirements:
- document
34 changes: 34 additions & 0 deletions docs/libclient-py/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = _build
APIDIR = ../../packages/client/libclient-py/quickmpc

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: autobuild
autobuild:
sphinx-autobuild $(SOURCEDIR) $(BUILDDIR)/html

.PHONY: autogen
autogen:
sphinx-autogen source/**/*.rst

.PHONY: clean
clean:
rm -rf $(BUILDDIR)/*
rm -rf $(SOURCEDIR)/reference/_generated/
35 changes: 35 additions & 0 deletions docs/libclient-py/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
45 changes: 45 additions & 0 deletions docs/libclient-py/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import quickmpc # noqa

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'quickmpc-libclient-py'
copyright = '2023, Acompany Co., Ltd.'
author = 'Acompany Co., Ltd.'
version = quickmpc.__version__
release = quickmpc.__version__

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'sphinx.ext.autodoc', # docstringから自動で取り込めるように
"sphinx.ext.autosummary", # summaryのリストを生成する
'sphinx.ext.napoleon', # numpy styleを取り込めるように
'sphinx_rtd_theme', # pageのテーマ
]

templates_path = ['_templates']
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']


# -- Extension configuration -------------------------------------------------
autosummary_generate = True
autodoc_typehints = "description"
autodoc_default_options = {
"members": True,
"inherited-members": True,
"exclude-members": "with_traceback",
}
28 changes: 28 additions & 0 deletions docs/libclient-py/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. quickmpc-libclient-py documentation master file, created by
sphinx-quickstart on Mon Jul 24 19:08:23 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

quickmpc-libclient-py's documentation
=====================================

.. _QuickMPC: https://github.com/acompany-develop/QuickMPC

quickmpc-libclient-py はMPC(Multi Party Computation)を行う `QuickMPC`_ を簡単に操作するためのPythonライブラリです.
pandas likeなinterfaceでMPCについて知らないユーザでも簡単に秘匿計算を行うことができます.

.. toctree::
:maxdepth: 1
:caption: Contents:

installation
quickstart
reference/index


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
10 changes: 10 additions & 0 deletions docs/libclient-py/source/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _installation:

Installation
============
quickmpc requires Python 3.7 or later to run. You can install quickmpc using pip:

.. code-block:: bash

$ pip install quickmpc

72 changes: 72 additions & 0 deletions docs/libclient-py/source/quickstart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
.. _quickstart:

.. _quickmpc-libclient-py: https://github.com/acompany-develop/QuickMPC/tree/main/packages/client/libclient-py
.. _pandas: https://pandas.pydata.org/

Quickstart
==========
本ページでは `quickmpc-libclient-py`_ を用いたMPC(Multi Party Computation)の始め方を説明します.
まだquickmpc-libclient-pyをinstallしていない方は :ref:`Installation <installation>` を参考にinstallをしてください.

csvデータの操作
---------------
quickmpc-libclient-pyは `pandas`_ likeなinterfaceを提供します.
例えばcsvファイルの読み取りはpandasと同じように :py:func:`read_csv関数 <quickmpc.pandas.read_csv>` により実現できます.
また, 返り値はpandas.DataFrameになっており,pandasと同じように加工することができます.

.. code-block:: python3

import quickmpc.pandas as qpd

df = qpd.read_csv("data.csv", index_col="ID")
df = df.applymap(lambda x: x%2)


MPCの開始
---------
:py:class:`QMPCクラス <quickmpc.QMPC>` を使用して,あらかじめ用意した2つ以上のQuickMPCサーバに接続します.

.. code-block:: python3

import quickmpc

qmpc = quickmpc.QMPC([
"http://~~~:~~~",
"http://~~~:~~~",
"http://~~~:~~~",
])

読み込んだcsvデータを次のようにしてサーバに送信します.

.. code-block:: python3

sdf = qmpc.send_to(df)

自分以外のユーザが送信したデータは次のようにして取得します.

.. code-block:: python3

data_id = "~~~~" # 他者が sdf.get_id() により出力したID
sdf = qmpc.load_from(data_id)

使用するデータをすべてサーバに送信したら各種MPCを実行します.

.. code-block:: python3

sdf_res = sdf.sum()
sdf_res = sdf.join(sdf_other)

計算結果の取得
--------------
MPCの結果はファイルに出力するか,pandas.DataFrameに出力して引き続き加工することができます.

.. code-block:: python3

df = sdf_res.to_csv("filename.csv") # ファイルに出力
df = sdf_res.to_data_frame() # DataFrameに出力

一部の実行時間の長い計算は `progress` オプションを設定して計算ステータスをログに出力できます.

.. code-block:: python3

df = sdf_res.to_data_frame(progress=True)
14 changes: 14 additions & 0 deletions docs/libclient-py/source/reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _api_reference:

API Reference
=============

.. toctree::
:maxdepth: 1

quickmpc
quickmpc.pandas
quickmpc.proto
quickmpc.request
quickmpc.share
quickmpc.utils
16 changes: 16 additions & 0 deletions docs/libclient-py/source/reference/quickmpc.pandas.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. _quickmpc.pandas:

.. module:: quickmpc.pandas

quickmpc.pandas
===============

quickmpc.pandas is quickmpc.pandas.

.. autosummary::
:toctree: _generated/
:nosignatures:

quickmpc.pandas.ShareDataFrame
quickmpc.pandas.parse
quickmpc.pandas.read_csv
14 changes: 14 additions & 0 deletions docs/libclient-py/source/reference/quickmpc.proto.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. module:: quickmpc.proto

quickmpc.proto
==============

quickmpc.proto is quickmpc.proto

.. autosummary::
:toctree: _generated/
:nosignatures:

quickmpc.proto.common_types.common_types_pb2.JobErrorInfo
quickmpc.proto.common_types.common_types_pb2.JobStatus
quickmpc.proto.common_types.common_types_pb2.JobProgress
13 changes: 13 additions & 0 deletions docs/libclient-py/source/reference/quickmpc.request.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. module:: quickmpc.request

quickmpc.request
================

quickmpc.request is quickmpc.request.

.. autosummary::
:toctree: _generated/
:nosignatures:

quickmpc.request.QMPCRequest
quickmpc.request.QMPCRequestInterface
Loading