Skip to content

Commit

Permalink
Merge branch 'dev' into fix/k8s-port
Browse files Browse the repository at this point in the history
  • Loading branch information
yashgorana authored Feb 14, 2024
2 parents 51633f3 + a0f011e commit 8ea74a2
Show file tree
Hide file tree
Showing 27 changed files with 390 additions and 194 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cd-hagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ on:
required: false
default: "false"

# Prevents concurrent runs of the same workflow
# while the previous run is still in progress
concurrency:
group: "CD - Hagrid"
cancel-in-progress: false

jobs:
call-pr-tests-linting:
if: github.repository == 'OpenMined/PySyft' && (github.event.inputs.skip_tests == 'false' || github.event_name == 'schedule') # don't run on forks
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/cd-post-release-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CD - Post Release Tests

on:
workflow_call:

workflow_dispatch:
inputs:
syft_version:
description: "Syft version to test"
required: true
type: string

jobs:
syft-install-check:
strategy:
max-parallel: 99
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.10", "3.9"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5

with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
python -m pip install --upgrade --user pip
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-py${{ matrix.python-version }}-
- name: Install Syft
run: |
pip install syft==${{ github.event.inputs.syft_version }}
- name: Check Syft version
run: |
python -c "import syft; print(syft.__version__)"
62 changes: 62 additions & 0 deletions .github/workflows/pr-tests-hagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,65 @@ jobs:
if: steps.changes.outputs.hagrid == 'true'
run: |
twine check dist/*.whl
pr-tests-syft-hagrid-comptability:
strategy:
max-parallel: 99
matrix:
os: [ubuntu-latest]
python-version: ["3.11"]
syft-version: ["0.8.2", "0.8.2b6", "0.8.3"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Check for file changes
uses: dorny/paths-filter@v3
id: changes
with:
base: ${{ github.ref }}
token: ${{ github.token }}
filters: .github/file-filters.yml

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
if: steps.changes.outputs.hagrid == 'true'
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
if: steps.changes.outputs.hagrid == 'true'
run: |
python -m pip install --upgrade --user pip
- name: Get pip cache dir
id: pip-cache
if: steps.changes.outputs.hagrid == 'true'
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4
if: steps.changes.outputs.hagrid == 'true'
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('packages/syft/setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('packages/syft/setup.cfg') }}
# https://github.com/google/jax/issues/17693
# pinning ml-dtypes due to jax version==0.4.10
- name: Install Syft ${{ matrix.syft-version }}
if: steps.changes.outputs.hagrid == 'true'
run: |
pip install ml-dtypes==0.2.0
pip install syft==${{ matrix.syft-version }}
pip install .
- name: Run Orchestra Command
if: steps.changes.outputs.hagrid == 'true'
run: |
python -c "import syft as sy; domain1 = sy.orchestra.launch(name='test-domain-1', dev_mode=True, reset=True)"
python -c "import syft as sy; domain2 = sy.orchestra.launch(name='test-domain-2',dev_mode=False, reset=True)"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ repos:
- id: mypy
name: "mypy: syft"
always_run: true
files: "^packages/syft/src/syft/serde|^packages/syft/src/syft/util/env.py|^packages/syft/src/syft/util/logger.py|^packages/syft/src/syft/util/markdown.py|^packages/syft/src/syft/util/notebook_ui/notebook_addons.py"
files: "^packages/syft/src/syft/serde|^packages/syft/src/syft/util/env.py|^packages/syft/src/syft/util/logger.py|^packages/syft/src/syft/util/markdown.py|^packages/syft/src/syft/util/notebook_ui/notebook_addons.py|^packages/syft/src/syft/service/warnings.py|^packages/syft/src/syft/service/dataset|^packages/syft/src/syft/service/worker"
#files: "^packages/syft/src/syft/serde"
args: [
"--follow-imports=skip",
Expand Down
2 changes: 1 addition & 1 deletion packages/hagrid/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.108
current_version = 0.3.110
tag = False
tag_name = {new_version}
commit = True
Expand Down
4 changes: 2 additions & 2 deletions packages/hagrid/hagrid/manifest_template.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
manifestVersion: 0.1
hagrid_version: 0.3.108
hagrid_version: 0.3.110
syft_version: 0.8.4-beta.22
dockerTag: 0.8.4-beta.22
baseUrl: https://raw.githubusercontent.com/OpenMined/PySyft/
hash: 799965e620b01f9cd1d8e7f23cc4cdc0fbc0410b
hash: 7e36da6aac7dc6b63c8f23ad3d6d07cf51281362
target_dir: ~/.hagrid/PySyft/
files:
grid:
Expand Down
14 changes: 9 additions & 5 deletions packages/hagrid/hagrid/orchestra.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from typing import Any
from typing import Callable
from typing import Optional
from typing import TYPE_CHECKING
from typing import Union

# relative
Expand All @@ -21,7 +22,6 @@
from .names import random_name
from .util import ImportFromSyft
from .util import NodeSideType
from .util import NodeType
from .util import shell

DEFAULT_PORT = 8080
Expand All @@ -31,6 +31,9 @@

ClientAlias = Any # we don't want to import Client in case it changes

if TYPE_CHECKING:
NodeType = ImportFromSyft.import_node_type()


# Define a function to read and print a stream
def read_stream(stream: subprocess.PIPE) -> None:
Expand Down Expand Up @@ -95,6 +98,7 @@ def container_exists_with(name: str, port: int) -> bool:


def get_node_type(node_type: Optional[Union[str, NodeType]]) -> Optional[NodeType]:
NodeType = ImportFromSyft.import_node_type()
if node_type is None:
node_type = os.environ.get("ORCHESTRA_NODE_TYPE", NodeType.DOMAIN)
try:
Expand Down Expand Up @@ -236,6 +240,7 @@ def deploy_to_python(
queue_port: Optional[int] = None,
) -> Optional[NodeHandle]:
stage_protocol_changes = ImportFromSyft.import_stage_protocol_changes()
NodeType = ImportFromSyft.import_node_type()
sy = get_syft_client()
if sy is None:
return sy
Expand All @@ -259,7 +264,7 @@ def deploy_to_python(
"processes": processes,
"dev_mode": dev_mode,
"tail": tail,
"node_type": str(node_type_enum),
"node_type": node_type_enum,
"node_side_type": node_side_type,
"enable_warnings": enable_warnings,
# new kwargs
Expand Down Expand Up @@ -296,7 +301,7 @@ def deploy_to_python(
worker_class = worker_classes[node_type_enum]
sig = inspect.signature(worker_class.named)
supported_kwargs = {k: v for k, v in kwargs.items() if k in sig.parameters}
if "node_type" in sig.parameters.keys():
if "node_type" in sig.parameters.keys() and "migrate" in sig.parameters:
supported_kwargs["migrate"] = True
worker = worker_class.named(**supported_kwargs)
else:
Expand Down Expand Up @@ -482,6 +487,7 @@ def launch(
queue_port: Optional[int] = None,
in_memory_workers: bool = True,
) -> Optional[NodeHandle]:
NodeType = ImportFromSyft.import_node_type()
if dev_mode is True:
os.environ["DEV_MODE"] = "True"
thread_workers = True
Expand All @@ -495,8 +501,6 @@ def launch(
dev_mode = str_to_bool(os.environ.get("DEV_MODE", f"{dev_mode}"))

node_type_enum: Optional[NodeType] = get_node_type(node_type=node_type)
if not node_type_enum:
return None

node_side_type_enum = (
NodeSideType.HIGH_SIDE
Expand Down
21 changes: 10 additions & 11 deletions packages/hagrid/hagrid/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ def __str__(self) -> str:
return self.value


class NodeType(str, Enum):
DOMAIN = "domain"
NETWORK = "network"
ENCLAVE = "enclave"
GATEWAY = "gateway"

def __str__(self) -> str:
# Use values when transforming NodeType to str
return self.value


class ImportFromSyft:
@staticmethod
def import_syft_error() -> Callable:
Expand All @@ -56,6 +45,16 @@ def stage_protocol_changes(*args: Any, **kwargs: Any) -> None:

return stage_protocol_changes

@staticmethod
def import_node_type() -> Callable:
try:
# syft absolute
from syft.abstract_node import NodeType
except Exception:
NodeType = DummyNum

return NodeType


def from_url(url: str) -> Tuple[str, str, int, str, Union[Any, str]]:
try:
Expand Down
2 changes: 1 addition & 1 deletion packages/hagrid/hagrid/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# HAGrid Version
__version__ = "0.3.108"
__version__ = "0.3.110"

if __name__ == "__main__":
print(__version__)
2 changes: 1 addition & 1 deletion packages/hagrid/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from setuptools import find_packages
from setuptools import setup

__version__ = "0.3.108"
__version__ = "0.3.110"

DATA_FILES = {"img": ["hagrid/img/*.png"], "hagrid": ["*.yml"]}

Expand Down
4 changes: 2 additions & 2 deletions packages/syft/src/syft/serde/third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def deserialize_dataframe(buf: bytes) -> DataFrame:


def deserialize_series(blob: bytes) -> Series:
df = DataFrame.from_dict(deserialize(blob, from_bytes=True))
return df[df.columns[0]]
df: DataFrame = DataFrame.from_dict(deserialize(blob, from_bytes=True))
return Series(df[df.columns[0]])


recursive_serde_register(
Expand Down
Loading

0 comments on commit 8ea74a2

Please sign in to comment.