Skip to content

Commit

Permalink
Merge pull request #101 from acompany-develop/feature/otsuka/convert_…
Browse files Browse the repository at this point in the history
…str_to_int

convert `str` to `int` on client side
  • Loading branch information
arukuka authored Mar 14, 2023
2 parents e719675 + 151c4f7 commit 9e0bc76
Show file tree
Hide file tree
Showing 46 changed files with 2,190 additions and 587 deletions.
1 change: 1 addition & 0 deletions packages/client/libclient-py/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mypy = "*"
types-protobuf = "*"
types-tabulate = "*"
types-tqdm = "*"
mypy-protobuf = "*"

[requires]
python_version = "3.7"
211 changes: 136 additions & 75 deletions packages/client/libclient-py/Pipfile.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from quickmpc import JobStatus


def make_statuses_detailed(statuses: Optional[Iterable[int]]) \
def make_statuses_detailed(statuses: Optional[Iterable[JobStatus.ValueType]]) \
-> Optional[List[str]]:
if statuses is None:
return None
Expand Down
8 changes: 6 additions & 2 deletions packages/client/libclient-py/demo/unit_demo/delete_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging

from quickmpc import QMPC
from quickmpc import QMPC, Schema, ShareValueTypeEnum

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
Expand All @@ -18,7 +18,11 @@
# 複数のシェアを作成・送信
data_ids = []
for i in range(3):
res = qmpc.send_share([[1]], ["key"])
res = qmpc.send_share(
[[1]],
[Schema(name="key",
type=ShareValueTypeEnum.SHARE_VALUE_TYPE_FIXED_POINT)]
)
data_ids.append(res['data_id'])
logger.info(res)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def output_table(title: int, schema: List[str], table: List):
# データをシェア化する
res = qmpc.demo_sharize(secrets)
for party_id, share in enumerate(res['results']):
output_table(party_id+1, schema, share)
output_table(party_id + 1, [col.name for col in schema], share)
14 changes: 12 additions & 2 deletions packages/client/libclient-py/quickmpc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
from quickmpc.qmpc import QMPC, JobStatus, JobErrorInfo
from quickmpc.qmpc import (
QMPC, JobStatus, JobErrorInfo,
Schema, ShareValueTypeEnum
)
from .version import __version__

__all__ = ["QMPC", "JobStatus", "JobErrorInfo", "__version__"]
__all__ = [
"QMPC",
"JobStatus",
"JobErrorInfo",
"Schema",
"ShareValueTypeEnum",
"__version__",
]
7 changes: 4 additions & 3 deletions packages/client/libclient-py/quickmpc/exception.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from dataclasses import dataclass
from typing import Union
from google.protobuf.reflection import GeneratedProtocolMessageType

from .proto.common_types.common_types_pb2 import JobErrorInfo


@dataclass(frozen=True)
class QMPCJobError(Exception):
err_info: GeneratedProtocolMessageType
err_info: JobErrorInfo


@dataclass(frozen=True)
class QMPCServerError(Exception):
err_info: Union[str, GeneratedProtocolMessageType]
err_info: Union[str, JobErrorInfo]


class ArgmentError(Exception):
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
"""
@generated by mypy-protobuf. Do not edit manually!
isort:skip_file
"""
import builtins
import collections.abc
import google.protobuf.descriptor
import google.protobuf.internal.containers
import google.protobuf.internal.enum_type_wrapper
import google.protobuf.message
import sys
import typing

if sys.version_info >= (3, 10):
import typing as typing_extensions
else:
import typing_extensions

DESCRIPTOR: google.protobuf.descriptor.FileDescriptor

class _JobStatus:
ValueType = typing.NewType("ValueType", builtins.int)
V: typing_extensions.TypeAlias = ValueType

class _JobStatusEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_JobStatus.ValueType], builtins.type):
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
UNKNOWN: _JobStatus.ValueType # 0
ERROR: _JobStatus.ValueType # 1
PRE_JOB: _JobStatus.ValueType # 2
READ_DB: _JobStatus.ValueType # 3
COMPUTE: _JobStatus.ValueType # 4
COMPLETED: _JobStatus.ValueType # 5

class JobStatus(_JobStatus, metaclass=_JobStatusEnumTypeWrapper): ...

UNKNOWN: JobStatus.ValueType # 0
ERROR: JobStatus.ValueType # 1
PRE_JOB: JobStatus.ValueType # 2
READ_DB: JobStatus.ValueType # 3
COMPUTE: JobStatus.ValueType # 4
COMPLETED: JobStatus.ValueType # 5
global___JobStatus = JobStatus

class _ComputationMethod:
ValueType = typing.NewType("ValueType", builtins.int)
V: typing_extensions.TypeAlias = ValueType

class _ComputationMethodEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_ComputationMethod.ValueType], builtins.type):
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
COMPUTATION_METHOD_UNSPECIFIED: _ComputationMethod.ValueType # 0
COMPUTATION_METHOD_MEAN: _ComputationMethod.ValueType # 1
COMPUTATION_METHOD_VARIANCE: _ComputationMethod.ValueType # 2
COMPUTATION_METHOD_SUM: _ComputationMethod.ValueType # 3
COMPUTATION_METHOD_CORREL: _ComputationMethod.ValueType # 4
COMPUTATION_METHOD_MESH_CODE: _ComputationMethod.ValueType # 5
COMPUTATION_METHOD_JOIN_TABLE: _ComputationMethod.ValueType # 6

class ComputationMethod(_ComputationMethod, metaclass=_ComputationMethodEnumTypeWrapper): ...

COMPUTATION_METHOD_UNSPECIFIED: ComputationMethod.ValueType # 0
COMPUTATION_METHOD_MEAN: ComputationMethod.ValueType # 1
COMPUTATION_METHOD_VARIANCE: ComputationMethod.ValueType # 2
COMPUTATION_METHOD_SUM: ComputationMethod.ValueType # 3
COMPUTATION_METHOD_CORREL: ComputationMethod.ValueType # 4
COMPUTATION_METHOD_MESH_CODE: ComputationMethod.ValueType # 5
COMPUTATION_METHOD_JOIN_TABLE: ComputationMethod.ValueType # 6
global___ComputationMethod = ComputationMethod

class _ShareValueTypeEnum:
ValueType = typing.NewType("ValueType", builtins.int)
V: typing_extensions.TypeAlias = ValueType

class _ShareValueTypeEnumEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_ShareValueTypeEnum.ValueType], builtins.type):
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
SHARE_VALUE_TYPE_UNSPECIFIED: _ShareValueTypeEnum.ValueType # 0
SHARE_VALUE_TYPE_FIXED_POINT: _ShareValueTypeEnum.ValueType # 1
SHARE_VALUE_TYPE_UTF_8_INTEGER_REPRESENTATION: _ShareValueTypeEnum.ValueType # 2

class ShareValueTypeEnum(_ShareValueTypeEnum, metaclass=_ShareValueTypeEnumEnumTypeWrapper): ...

SHARE_VALUE_TYPE_UNSPECIFIED: ShareValueTypeEnum.ValueType # 0
SHARE_VALUE_TYPE_FIXED_POINT: ShareValueTypeEnum.ValueType # 1
SHARE_VALUE_TYPE_UTF_8_INTEGER_REPRESENTATION: ShareValueTypeEnum.ValueType # 2
global___ShareValueTypeEnum = ShareValueTypeEnum

@typing_extensions.final
class ProcedureProgress(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

ID_FIELD_NUMBER: builtins.int
DESCRIPTION_FIELD_NUMBER: builtins.int
PROGRESS_FIELD_NUMBER: builtins.int
COMPLETED_FIELD_NUMBER: builtins.int
DETAILS_FIELD_NUMBER: builtins.int
id: builtins.int
"""unique id in ProgressManager context"""
description: builtins.str
"""describe specific process in job"""
progress: builtins.float
"""describe progress by [0.0, 100.0]"""
completed: builtins.bool
"""describe that procedure is completed or not"""
details: builtins.str
"""describe progress in details"""
def __init__(
self,
*,
id: builtins.int = ...,
description: builtins.str = ...,
progress: builtins.float = ...,
completed: builtins.bool = ...,
details: builtins.str | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["_details", b"_details", "details", b"details"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["_details", b"_details", "completed", b"completed", "description", b"description", "details", b"details", "id", b"id", "progress", b"progress"]) -> None: ...
def WhichOneof(self, oneof_group: typing_extensions.Literal["_details", b"_details"]) -> typing_extensions.Literal["details"] | None: ...

global___ProcedureProgress = ProcedureProgress

@typing_extensions.final
class JobProgress(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

JOB_UUID_FIELD_NUMBER: builtins.int
STATUS_FIELD_NUMBER: builtins.int
PROGRESSES_FIELD_NUMBER: builtins.int
job_uuid: builtins.str
status: global___JobStatus.ValueType
@property
def progresses(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ProcedureProgress]: ...
def __init__(
self,
*,
job_uuid: builtins.str = ...,
status: global___JobStatus.ValueType = ...,
progresses: collections.abc.Iterable[global___ProcedureProgress] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["job_uuid", b"job_uuid", "progresses", b"progresses", "status", b"status"]) -> None: ...

global___JobProgress = JobProgress

@typing_extensions.final
class Stacktrace(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

@typing_extensions.final
class Frame(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

SOURCE_LOCATION_FIELD_NUMBER: builtins.int
SOURCE_LINE_FIELD_NUMBER: builtins.int
FUNCTION_NAME_FIELD_NUMBER: builtins.int
source_location: builtins.str
source_line: builtins.int
function_name: builtins.str
def __init__(
self,
*,
source_location: builtins.str = ...,
source_line: builtins.int = ...,
function_name: builtins.str = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["function_name", b"function_name", "source_line", b"source_line", "source_location", b"source_location"]) -> None: ...

FRAMES_FIELD_NUMBER: builtins.int
@property
def frames(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Stacktrace.Frame]: ...
def __init__(
self,
*,
frames: collections.abc.Iterable[global___Stacktrace.Frame] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["frames", b"frames"]) -> None: ...

global___Stacktrace = Stacktrace

@typing_extensions.final
class JobErrorInfo(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

WHAT_FIELD_NUMBER: builtins.int
ADDITIONAL_INFO_FIELD_NUMBER: builtins.int
STACKTRACE_FIELD_NUMBER: builtins.int
what: builtins.str
additional_info: builtins.str
@property
def stacktrace(self) -> global___Stacktrace: ...
def __init__(
self,
*,
what: builtins.str = ...,
additional_info: builtins.str | None = ...,
stacktrace: global___Stacktrace | None = ...,
) -> None: ...
def HasField(self, field_name: typing_extensions.Literal["_additional_info", b"_additional_info", "_stacktrace", b"_stacktrace", "additional_info", b"additional_info", "stacktrace", b"stacktrace"]) -> builtins.bool: ...
def ClearField(self, field_name: typing_extensions.Literal["_additional_info", b"_additional_info", "_stacktrace", b"_stacktrace", "additional_info", b"additional_info", "stacktrace", b"stacktrace", "what", b"what"]) -> None: ...
@typing.overload
def WhichOneof(self, oneof_group: typing_extensions.Literal["_additional_info", b"_additional_info"]) -> typing_extensions.Literal["additional_info"] | None: ...
@typing.overload
def WhichOneof(self, oneof_group: typing_extensions.Literal["_stacktrace", b"_stacktrace"]) -> typing_extensions.Literal["stacktrace"] | None: ...

global___JobErrorInfo = JobErrorInfo

@typing_extensions.final
class Schema(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

NAME_FIELD_NUMBER: builtins.int
TYPE_FIELD_NUMBER: builtins.int
name: builtins.str
type: global___ShareValueTypeEnum.ValueType
def __init__(
self,
*,
name: builtins.str = ...,
type: global___ShareValueTypeEnum.ValueType = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["name", b"name", "type", b"type"]) -> None: ...

global___Schema = Schema
3 changes: 3 additions & 0 deletions packages/client/libclient-py/quickmpc/proto/generate_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def generate_files():
f"-I{_proto_path}",
"--python_out=.",
"--grpc_python_out=.",
"--mypy_out=.",
"--mypy_grpc_out=.",
f"{_proto_path}/libc_to_manage_container/libc_to_manage.proto",
)
)
Expand All @@ -25,6 +27,7 @@ def generate_files():
"",
f"-I{_proto_path}",
"--python_out=.",
"--mypy_out=.",
f"{_proto_path}/common_types/common_types.proto",
)
)
Expand Down
Loading

0 comments on commit 9e0bc76

Please sign in to comment.