Skip to content

Commit

Permalink
Merge pull request #8819 from OpenMined/eelco/rename-project-start
Browse files Browse the repository at this point in the history
  • Loading branch information
koenvanderveen committed May 15, 2024
2 parents a7d300e + 2569056 commit 82a9231
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 27 deletions.
4 changes: 2 additions & 2 deletions notebooks/api/0.8/01-submit-code.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@
"outputs": [],
"source": [
"# Once we start the project, it will submit the project along with the code request to the Domain Server\n",
"project = new_project.start()\n",
"project = new_project.send()\n",
"project"
]
},
Expand Down Expand Up @@ -599,7 +599,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.10.13"
},
"toc": {
"base_numbering": 1,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/api/0.8/06-multiple-code-requests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"\n",
"project"
]
Expand Down Expand Up @@ -578,7 +578,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.10.13"
},
"toc": {
"base_numbering": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"metadata": {},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"project"
]
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/tutorials/data-scientist/05-syft-functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
"metadata": {},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"project"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"metadata": {},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"project"
]
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/tutorials/model-auditing/colab/01-user-log.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"metadata": {},
"outputs": [],
"source": [
"project = audit_project.start()\n",
"project = audit_project.send()\n",
"project"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@
"metadata": {},
"outputs": [],
"source": [
"project = new_project.start()"
"project = new_project.send()"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@
},
"outputs": [],
"source": [
"project = new_project.start()\n",
"project = new_project.send()\n",
"assert isinstance(project, sy.service.project.project.Project)\n",
"project"
]
Expand Down
2 changes: 1 addition & 1 deletion packages/syft/src/syft/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def create_project(
user_email_address=user_email_address,
members=[self],
)
project = project_create.start()
project = project_create.send()
return project

# TODO: type of request should be REQUEST, but it will give circular import error
Expand Down
8 changes: 2 additions & 6 deletions packages/syft/src/syft/client/syncing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# stdlib
import warnings

# relative
from ..abstract_node import NodeSideType
Expand All @@ -12,6 +11,7 @@
from ..service.sync.resolve_widget import ResolveWidget
from ..service.sync.sync_state import SyncState
from ..types.uid import UID
from ..util.decorators import deprecated
from .client import SyftClient
from .sync_decision import SyncDecision
from .sync_decision import SyncDirection
Expand Down Expand Up @@ -69,12 +69,8 @@ def resolve(obj_diff_batch: ObjectDiffBatch) -> ResolveWidget:
return widget


@deprecated(reason="resolve_single has been renamed to resolve", return_syfterror=True)
def resolve_single(obj_diff_batch: ObjectDiffBatch) -> ResolveWidget:
warnings.warn(
"resolve_single has been renamed to resolve",
DeprecationWarning,
stacklevel=1,
)
return resolve(obj_diff_batch)


Expand Down
7 changes: 7 additions & 0 deletions packages/syft/src/syft/service/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from ...types.uid import UID
from ...util import options
from ...util.colors import SURFACE
from ...util.decorators import deprecated
from ...util.markdown import markdown_as_class_with_fields
from ...util.util import full_name_with_qualname
from ..code.user_code import SubmitUserCode
Expand Down Expand Up @@ -1261,7 +1262,13 @@ def create_code_request(
reason=reason,
)

@deprecated(
reason="Project.start has been renamed to Project.send", return_syfterror=True
)
def start(self, return_all_projects: bool = False) -> Project | list[Project]:
return self.send(return_all_projects=return_all_projects)

def send(self, return_all_projects: bool = False) -> Project | list[Project]:
# Currently we are assuming that the first member is the leader
# This would be changed in our future leaderless approach
leader = self.clients[0]
Expand Down
26 changes: 26 additions & 0 deletions packages/syft/src/syft/util/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
from collections.abc import Callable
import functools
from typing import Any
import warnings

# relative
from ..service.response import SyftError


def singleton(cls: Any) -> Callable:
Expand Down Expand Up @@ -46,3 +50,25 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
return previous_instances[cls].get("instance")

return wrapper


def deprecated(
reason: str = "This function is deprecated and may be removed in the future.",
return_syfterror: bool = False,
) -> Callable:
def decorator(func: Callable) -> Callable:
@functools.wraps(func)
def wrapper(*args: list, **kwargs: dict) -> Any:
message = f"{func.__qualname__} is deprecated: {reason}"
if return_syfterror:
return SyftError(message=message)
warnings.warn(
message,
category=DeprecationWarning,
stacklevel=2,
)
return func(*args, **kwargs)

return wrapper

return decorator
6 changes: 3 additions & 3 deletions packages/syft/tests/syft/project/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_project_creation(worker):
name="My Cool Project", description="My Cool Description", members=[ds_client]
)

project = new_project.start()
project = new_project.send()

assert isinstance(project, Project)
assert new_project.id == project.id
Expand All @@ -47,7 +47,7 @@ def test_error_data_owner_project_creation(worker):
name="My Cool Project", description="My Cool Description", members=[root_client]
)

project = new_project.start()
project = new_project.send()

assert isinstance(project, sy.SyftError)
assert project.message == "Only Data Scientists can create projects"
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_project_serde(worker):
name="My Cool Project", description="My Cool Description", members=[root_client]
)

project = new_project.start()
project = new_project.send()

ser_data = sy.serialize(project, to_bytes=True)
assert isinstance(ser_data, bytes)
Expand Down

0 comments on commit 82a9231

Please sign in to comment.