Skip to content

Commit

Permalink
Merge branch 'dev' into small_dataset_changes
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvanderveen authored Jun 15, 2023
2 parents c52fe90 + 27a2560 commit cb53866
Show file tree
Hide file tree
Showing 18 changed files with 209 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.8.1-beta.9
current_version = 0.8.1-beta.10
tag = False
tag_name = {new_version}
commit = True
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mono Repo Global Version
__version__ = "0.8.1-beta.9"
__version__ = "0.8.1-beta.10"
# elsewhere we can call this file: `python VERSION` and simply take the stdout

# stdlib
Expand Down
3 changes: 1 addition & 2 deletions notebooks/api/0.8/01-submit-code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@
},
"outputs": [],
"source": [
"@sy.syft_function(input_policy=sy.ExactMatch(trade_data=asset),\n",
" output_policy=sy.SingleExecutionExactOutput())\n",
"@sy.syft_function_single_use(trade_data=asset)\n",
"def sum_trade_value_mil(trade_data):\n",
" import pandas as pd\n",
" from opendp.mod import enable_features\n",
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mono Repo Global Version
__version__ = "0.8.1-beta.9"
__version__ = "0.8.1-beta.10"
# elsewhere we can call this file: `python VERSION` and simply take the stdout

# stdlib
Expand Down
10 changes: 5 additions & 5 deletions packages/grid/devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ images:
tags:
- "######"
- latest
- "0.8.1-beta.9"
- "0.8.1-beta.10"
createPullSecret: true
dockerfile: ./backend/backend.dockerfile
context: ../
Expand All @@ -121,7 +121,7 @@ images:
tags:
- "######"
- latest
- "0.8.1-beta.9"
- "0.8.1-beta.10"
createPullSecret: true
dockerfile: ./frontend/frontend.dockerfile
context: ./frontend
Expand All @@ -137,7 +137,7 @@ images:
tags:
- "######"
- latest
- "0.8.1-beta.9"
- "0.8.1-beta.10"
createPullSecret: true
dockerfile: ./vpn/headscale.dockerfile
context: ./vpn
Expand All @@ -149,7 +149,7 @@ images:
tags:
- "######"
- latest
- "0.8.1-beta.9"
- "0.8.1-beta.10"
createPullSecret: true
dockerfile: ./vpn/tailscale.dockerfile
context: ./vpn
Expand All @@ -161,7 +161,7 @@ images:
tags:
- "######"
- latest
- "0.8.1-beta.9"
- "0.8.1-beta.10"
createPullSecret: true
dockerfile: ./vpn/iptables.dockerfile
context: ./vpn
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pygrid-ui",
"version": "0.8.1-beta.9",
"version": "0.8.1-beta.10",
"private": true,
"scripts": {
"dev": "pnpm i && vite dev --host --port 80",
Expand Down
6 changes: 3 additions & 3 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.24
syft_version: 0.8.1-beta.9
dockerTag: 0.8.1-beta.9
syft_version: 0.8.1-beta.10
dockerTag: 0.8.1-beta.10
baseUrl: https://raw.githubusercontent.com/OpenMined/PySyft/
hash: cdb7e476a444cbf9d51fa9e029020384cafe7d6c
hash: aa69e5aec85fb652342861105dedce1aa317d0ac
target_dir: ~/.hagrid/PySyft/
files:
grid:
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = syft
version = attr: "0.8.1-beta.9"
version = attr: "0.8.1-beta.10"
description = Perform numpy-like analysis on data that remains in someone elses server
author = OpenMined
author_email = [email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/src/syft/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Mono Repo Global Version
__version__ = "0.8.1-beta.9"
__version__ = "0.8.1-beta.10"
# elsewhere we can call this file: `python VERSION` and simply take the stdout

# stdlib
Expand Down
7 changes: 4 additions & 3 deletions packages/syft/src/syft/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.8.1-beta.9"
__version__ = "0.8.1-beta.10"

# stdlib
import pathlib
Expand Down Expand Up @@ -38,8 +38,9 @@
from .service.action.action_object import ActionObject # noqa: F401
from .service.action.plan import Plan # noqa: F401
from .service.action.plan import planify # noqa: F401
from .service.code.user_code import UserCodeStatus # noqa: F401
from .service.code.user_code import syft_function # noqa: F401
from .service.code.user_code import UserCodeStatus # noqa: F401; noqa: F401
from .service.code.user_code import syft_function # noqa: F401; noqa: F401
from .service.code.user_code import syft_function_single_use # noqa: F401; noqa: F401
from .service.data_subject import DataSubjectCreate as DataSubject # noqa: F401
from .service.dataset.dataset import Contributor # noqa: F401
from .service.dataset.dataset import CreateAsset as Asset # noqa: F401
Expand Down
26 changes: 26 additions & 0 deletions packages/syft/src/syft/service/code/user_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from ..metadata.node_metadata import EnclaveMetadata
from ..policy.policy import CustomInputPolicy
from ..policy.policy import CustomOutputPolicy
from ..policy.policy import ExactMatch
from ..policy.policy import InputPolicy
from ..policy.policy import OutputPolicy
from ..policy.policy import Policy
Expand Down Expand Up @@ -106,6 +107,12 @@ def __init__(self, base_dict: Dict):
def __repr__(self):
return str(self.base_dict)

def __repr_syft_nested__(self):
string = ""
for node_view, status in self.base_dict.items():
string += f"{node_view.node_name}: {status}<br>"
return string

@property
def approved(self) -> bool:
# approved for this node only
Expand Down Expand Up @@ -347,6 +354,16 @@ def wrapper(*args: Any, **kwargs: Any) -> Callable:
def code(self) -> str:
return self.raw_code

def show_code_cell(self):
warning_message = """# WARNING: \n# Before you submit
# change the name of the function \n# for no duplicates\n\n"""

# third party
from IPython import get_ipython

ip = get_ipython()
ip.set_next_input(warning_message + self.raw_code)


@serializable(without=["local_function"])
class SubmitUserCode(SyftObject):
Expand All @@ -366,6 +383,8 @@ class SubmitUserCode(SyftObject):
input_kwargs: List[str]
enclave_metadata: Optional[EnclaveMetadata] = None

__attr_repr_cols__ = ["func_name", "code"]

@property
def kwargs(self) -> List[str]:
return self.input_policy_init_kwargs
Expand Down Expand Up @@ -394,6 +413,13 @@ def debox_asset(arg: Any) -> Any:
return deboxed_arg


def syft_function_single_use(*args: Any, **kwargs: Any):
return syft_function(
input_policy=ExactMatch(*args, **kwargs),
output_policy=SingleExecutionExactOutput(),
)


def syft_function(
input_policy: Union[InputPolicy, UID],
output_policy: Optional[Union[OutputPolicy, UID]] = None,
Expand Down
19 changes: 15 additions & 4 deletions packages/syft/src/syft/service/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
from ...serde.serializable import serializable
from ...store.document_store import PartitionKey
from ...types.datetime import DateTime
from ...types.syft_object import SURFACE_DARK_BRIGHT
from ...types.syft_object import SYFT_OBJECT_VERSION_1
from ...types.syft_object import SyftObject
from ...types.syft_object import itables_css
from ...types.transforms import TransformContext
from ...types.transforms import generate_id
from ...types.transforms import transform
from ...types.transforms import validate_url
from ...types.uid import UID
from ...util import options
from ...util.colors import ON_SURFACE_HIGHEST
from ...util.colors import SURFACE
from ...util.colors import SURFACE_SURFACE
from ...util.fonts import ITABLES_CSS
from ...util.fonts import fonts_css
from ...util.markdown import as_markdown_python_code
Expand Down Expand Up @@ -88,6 +90,15 @@ class Asset(SyftObject):
__attr_repr_cols__ = ["name", "shape"]

def _repr_html_(self) -> Any:
itables_css = f"""
.itables table {{
margin: 0 auto;
float: left;
color: {ON_SURFACE_HIGHEST[options.color_theme]};
}}
.itables table th {{color: {SURFACE_SURFACE[options.color_theme]};}}
"""

# relative
from ...service.action.action_object import ActionObject

Expand All @@ -106,7 +117,7 @@ def _repr_html_(self) -> Any:
f"""
<style>
{fonts_css}
.syft-asset {{color: {SURFACE_DARK_BRIGHT};}}
.syft-asset {{color: {SURFACE[options.color_theme]};}}
.syft-asset h3,
.syft-asset p
{{font-family: 'Open Sans'}}
Expand Down Expand Up @@ -338,7 +349,7 @@ def _repr_html_(self) -> Any:
f"""
<style>
{fonts_css}
.syft-dataset {{color: {SURFACE_DARK_BRIGHT};}}
.syft-dataset {{color: {SURFACE[options.color_theme]};}}
.syft-dataset h3,
.syft-dataset p
{{font-family: 'Open Sans';}}
Expand Down
39 changes: 39 additions & 0 deletions packages/syft/src/syft/service/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@
from ...types.datetime import DateTime
from ...types.syft_object import SYFT_OBJECT_VERSION_1
from ...types.syft_object import SyftObject
from ...types.syft_object import short_qual_name
from ...types.transforms import TransformContext
from ...types.transforms import keep
from ...types.transforms import transform
from ...types.uid import UID
from ...util import options
from ...util.colors import SURFACE
from ...util.markdown import markdown_as_class_with_fields
from ...util.util import full_name_with_qualname
from ..code.user_code import SubmitUserCode
from ..network.network_service import NodePeer
from ..network.routes import NodeRoute
Expand Down Expand Up @@ -116,6 +120,12 @@ class ProjectEvent(SyftObject):
creator_verify_key: Optional[SyftVerifyKey]
signature: Optional[bytes] # dont use in signing

def __repr_syft_nested__(self):
return (
short_qual_name(full_name_with_qualname(self)),
f"{str(self.id)[:4]}...{str(self.id)[-3:]}",
)

@pydantic.root_validator(pre=True)
def make_timestamp(cls, values: Dict[str, Any]) -> Dict[str, Any]:
if "timestamp" not in values or values["timestamp"] is None:
Expand Down Expand Up @@ -704,6 +714,21 @@ class Project(SyftObject):
# store: Dict[UID, Dict[UID, SyftObject]] = {}
# permissions: Dict[UID, Dict[UID, Set[str]]] = {}

def _repr_html_(self) -> Any:
return (
f"""
<style>
.syft-project {{color: {SURFACE[options.color_theme]};}}
</style>
"""
+ "<div class='syft-project'>"
+ f"<h3>{self.name}</h3>"
+ f"<p>{self.description}</p>"
+ f"<p><strong>Created by: </strong>{self.created_by}</p>"
+ self.requests._repr_html_()
+ "</div>"
)

def _broadcast_event(
self, project_event: ProjectEvent
) -> Union[SyftSuccess, SyftError]:
Expand Down Expand Up @@ -1165,6 +1190,20 @@ def __init__(self, *args, **kwargs):
# Convert SyftClients to NodeIdentities
self.members = list(map(self.to_node_identity, self.members))

def _repr_html_(self) -> Any:
return (
f"""
<style>
.syft-project-create {{color: {SURFACE[options.color_theme]};}}
</style>
"""
+ "<div class='syft-project-create'>"
+ f"<h3>{self.name}</h3>"
+ f"<p>{self.description}</p>"
+ f"<p><strong>Created by: </strong>{self.created_by}</p>"
+ "</div>"
)

@validator("members", pre=True)
def verify_members(cls, val: Union[List[SyftClient], List[NodeIdentity]]):
# SyftClients must be logged in by the same emails
Expand Down
Loading

0 comments on commit cb53866

Please sign in to comment.