Skip to content

Commit

Permalink
Merge pull request #5625 from OpenMined/dev
Browse files Browse the repository at this point in the history
0.5.0rc2 one more time
  • Loading branch information
madhavajay committed Jun 1, 2021
2 parents 1ef35e1 + cb9518e commit ca13c8c
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/syft-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
Expand All @@ -72,4 +73,3 @@ jobs:
alert-threshold: "200%"
comment-on-alert: true
fail-on-alert: true

1 change: 1 addition & 0 deletions .github/workflows/syft-merge_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[dev] -f https://download.pytorch.org/whl/torch_stable.html
- name: Check import works without dev packages
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/syft-pr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
Expand Down Expand Up @@ -210,6 +211,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
Expand Down Expand Up @@ -274,6 +276,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
Expand Down Expand Up @@ -329,11 +332,12 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
- name: Test PyGrid
continue-on-error: true
run: |
python ./scripts/mnist.py
pytest -m grid --durations=50
pytest -m grid --durations=50
4 changes: 2 additions & 2 deletions .github/workflows/syft-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ defaults:
working-directory: ./packages/syft

jobs:

package-security:
strategy:
max-parallel: 1
Expand Down Expand Up @@ -53,6 +52,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
Expand All @@ -72,4 +72,4 @@ jobs:
- name: Snyk security check
uses: snyk/actions/python-3.8@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
3 changes: 3 additions & 0 deletions .github/workflows/syft-version_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
Expand Down Expand Up @@ -146,6 +147,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[ci-all] -f https://download.pytorch.org/whl/torch_stable.html
python scripts/parse_setup.py setup.cfg | xargs pip install --no-deps || true
Expand Down Expand Up @@ -207,6 +209,7 @@ jobs:
pip install packaging --default-timeout=60
python scripts/adjust_torch_versions.py ./setup.cfg ${{ matrix.torch-version }}
grep -A 3 "torch_ecosystem" setup.cfg
pip install -r requirements.unstable.txt
pip install -e .[dev] -f https://download.pytorch.org/whl/torch_stable.html
- name: Check import works without dev packages
Expand Down
9 changes: 9 additions & 0 deletions packages/syft/proto/lib/torch/size.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

package syft.lib.torch;
import "proto/core/common/common_object.proto";

message Size {
repeated uint64 data = 1;
syft.core.common.UID id = 2;
}
3 changes: 3 additions & 0 deletions packages/syft/requirements.unstable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flake8-kwarger @ git+https://github.com/madhavajay/flake8-kwarger
pytorch-lightning @ git+https://github.com/tudorcebere/pytorch-lightning@tudor-om-v0
sympc @ git+https://github.com/OpenMined/SyMPC@main
6 changes: 1 addition & 5 deletions packages/syft/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ syft =
pyarrow
PyJWT==1.7.1
PyNaCl
PyYAML>=5.4.1
requests
scikit-learn
requests_toolbelt
Expand Down Expand Up @@ -91,9 +92,7 @@ libs =
petlib
pillow>=8.1.2 #security-issues
python-dp
pytorch-lightning @ git+https://github.com/tudorcebere/pytorch-lightning@tudor-om-v0
statsmodels
sympc @ git+https://github.com/OpenMined/SyMPC@main
tenseal
xgboost>=1.4
zksk
Expand All @@ -113,7 +112,6 @@ dev =
darglint
doc8
flake8
flake8-kwarger @ git+https://github.com/madhavajay/flake8-kwarger
isort
matplotlib
nbconvert
Expand Down Expand Up @@ -150,9 +148,7 @@ ci-libs =
; pillow>=8.1.2 #install-custom-dependency
; pyarrow #install-custom-dependency
; python-dp #install-custom-dependency
; pytorch-lightning@git+https://github.com/tudorcebere/pytorch-lightning@tudor-om-v0 #install-custom-dependency
; statsmodels #install-custom-dependency
; sympc@git+https://github.com/OpenMined/SyMPC@main #install-custom-dependency
; tenseal #install-custom-dependency
; xgboost>=1.4 #install-custom-dependency
; zksk #install-custom-dependency
Expand Down
1 change: 1 addition & 0 deletions packages/syft/src/syft/lib/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from . import device # noqa: 401
from . import parameter # noqa: 401
from . import return_types # noqa: 401
from . import size # noqa: 401
from . import uppercase_tensor # noqa: 401
from ...ast.globals import Globals
from ...logger import info
Expand Down
25 changes: 25 additions & 0 deletions packages/syft/src/syft/lib/torch/size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# third party
import torch

# syft relative
from ...generate_wrapper import GenerateWrapper
from ...proto.lib.torch.size_pb2 import Size as TorchSize_PB


def protobuf_torch_size_serializer(torch_size: torch.Size) -> TorchSize_PB:
serialized_size = TorchSize_PB(data=torch_size)
return serialized_size


def protobuf_torch_size_deserializer(proto_size: TorchSize_PB) -> torch.Size:
torch_size = torch.Size(proto_size.data)
return torch_size


GenerateWrapper(
wrapped_type=torch.Size,
import_path="torch.Size",
protobuf_scheme=TorchSize_PB,
type_object2proto=protobuf_torch_size_serializer,
type_proto2object=protobuf_torch_size_deserializer,
)
111 changes: 111 additions & 0 deletions packages/syft/src/syft/proto/lib/torch/size_pb2.py

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

22 changes: 22 additions & 0 deletions packages/syft/tests/syft/lib/torch/size_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# third party
import torch

# syft absolute
import syft as sy


def test_protobuf_torch_size_serializer_deserializer() -> None:
torch_size = torch.Size([4, 5, 2, 1])
torch_size_pb = sy.lib.torch.size.protobuf_torch_size_serializer(torch_size)
torch_size_deserialized = sy.lib.torch.size.protobuf_torch_size_deserializer(
torch_size_pb
)

assert isinstance(torch_size_deserialized, torch.Size)
assert torch_size == torch_size_deserialized


def test_torch_size_serde(client: sy.VirtualMachineClient) -> None:
torch_size = torch.Size([2, 3, 4, 100])
torch_size_ptr = torch_size.send(client)
assert torch_size_ptr.get() == torch_size

0 comments on commit ca13c8c

Please sign in to comment.