From 8cdf60de4de920bb8b85ffb94d66e965fe5c45fa Mon Sep 17 00:00:00 2001 From: eelcovdw Date: Tue, 21 May 2024 11:03:43 +0200 Subject: [PATCH 1/4] fix endpoint --- .../syft/src/syft/service/code/user_code.py | 4 ++-- .../src/syft/service/user/user_service.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/syft/src/syft/service/code/user_code.py b/packages/syft/src/syft/service/code/user_code.py index c779037a6c9..604e21611f4 100644 --- a/packages/syft/src/syft/service/code/user_code.py +++ b/packages/syft/src/syft/service/code/user_code.py @@ -353,13 +353,13 @@ def _coll_repr_(self) -> dict[str, Any]: def user(self) -> UserView | SyftError: api = APIRegistry.api_for( node_uid=self.syft_node_location, - user_verify_key=self.user_verify_key, + user_verify_key=self.syft_client_verify_key, ) if api is None: return SyftError( message=f"Can't access Syft API. You must login to {self.syft_node_location}" ) - return api.services.user.get_current_user() + return api.services.user.get_by_verify_key(self.user_verify_key) @property def status(self) -> UserCodeStatusCollection | SyftError: diff --git a/packages/syft/src/syft/service/user/user_service.py b/packages/syft/src/syft/service/user/user_service.py index 6da986426c3..63425f90103 100644 --- a/packages/syft/src/syft/service/user/user_service.py +++ b/packages/syft/src/syft/service/user/user_service.py @@ -37,6 +37,7 @@ from .user import UserViewPage from .user import check_pwd from .user import salt_and_hash_password +from .user_roles import ADMIN_ROLE_LEVEL from .user_roles import DATA_OWNER_ROLE_LEVEL from .user_roles import DATA_SCIENTIST_ROLE_LEVEL from .user_roles import GUEST_ROLE_LEVEL @@ -220,7 +221,23 @@ def get_current_user(self, context: AuthedServiceContext) -> UserView | SyftErro credentials=context.credentials, verify_key=context.credentials ) if result.is_ok(): - # this seems weird that we get back None as Ok(None) + user = result.ok() + if user: + return user.to(UserView) + else: + SyftError(message="User not found!") + return SyftError(message=str(result.err())) + + @service_method( + path="user.get_by_verify_key", name="get_by_verify_key", roles=ADMIN_ROLE_LEVEL + ) + def get_by_verify_key_endpoint( + self, context: AuthedServiceContext, verify_key: SyftVerifyKey + ) -> UserView | SyftError: + result = self.stash.get_by_verify_key( + credentials=context.credentials, verify_key=verify_key + ) + if result.is_ok(): user = result.ok() if user: return user.to(UserView) From 4ee91e99c239d4a86698085a48e90ee01fb52603 Mon Sep 17 00:00:00 2001 From: Aziz Berkay Yesilyurt Date: Tue, 21 May 2024 14:44:06 +0200 Subject: [PATCH 2/4] Update request message to indicate function name Closes https://github.com/OpenMined/Heartbeat/issues/1343 --- packages/syft/src/syft/service/request/request.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/syft/src/syft/service/request/request.py b/packages/syft/src/syft/service/request/request.py index 889491278e8..88f035de0bb 100644 --- a/packages/syft/src/syft/service/request/request.py +++ b/packages/syft/src/syft/service/request/request.py @@ -570,11 +570,14 @@ def approve( ) if message and metadata and metadata.show_warnings and not disable_warnings: prompt_warning_message(message=message, confirm=True) + msg = ( + "Approving request ", + f"on change {self.code.service_func_name} " if is_code_request else "", + f"for domain {api.node_name}", + ) - print(f"Approving request for domain {api.node_name}") + print("".join(msg)) res = api.services.request.apply(self.id, **kwargs) - # if isinstance(res, SyftSuccess): - return res def deny(self, reason: str) -> SyftSuccess | SyftError: From cc0f26e0d5f9aaec2b0f9be20e9980dd3af84030 Mon Sep 17 00:00:00 2001 From: Madhava Jay Date: Thu, 23 May 2024 07:05:10 +1000 Subject: [PATCH 3/4] Fix nightlies --- .github/workflows/nightlies.yml | 15 --- .github/workflows/pr-tests-stack-arm64.yml | 104 --------------------- 2 files changed, 119 deletions(-) delete mode 100644 .github/workflows/pr-tests-stack-arm64.yml diff --git a/.github/workflows/nightlies.yml b/.github/workflows/nightlies.yml index 491b4dd6aad..3db29a3663c 100644 --- a/.github/workflows/nightlies.yml +++ b/.github/workflows/nightlies.yml @@ -23,22 +23,7 @@ jobs: uses: OpenMined/PySyft/.github/workflows/pr-tests-stack.yml@dev secrets: inherit - # call-pr-tests-stack-arm64: - # if: github.repository == 'OpenMined/PySyft' # don't run on forks - # uses: OpenMined/PySyft/.github/workflows/pr-tests-stack-arm64.yml@dev - # secrets: inherit - - call-pr-tests-stack-public: - if: github.repository == 'OpenMined/PySyft' # don't run on forks - uses: OpenMined/PySyft/.github/workflows/pr-tests-stack-public.yml@dev - secrets: inherit - call-container-scan: if: github.repository == 'OpenMined/PySyft' # don't run on forks uses: OpenMined/PySyft/.github/workflows/container-scan.yml@dev secrets: inherit - - # call-rhel-tests: - # if: github.repository == 'OpenMined/PySyft' # don't run on forks - # uses: OpenMined/PySyft/.github/workflows/rhel-tests.yml@dev - # secrets: inherit diff --git a/.github/workflows/pr-tests-stack-arm64.yml b/.github/workflows/pr-tests-stack-arm64.yml deleted file mode 100644 index 7bb4e07de40..00000000000 --- a/.github/workflows/pr-tests-stack-arm64.yml +++ /dev/null @@ -1,104 +0,0 @@ -# The following test is disable temporarily until we switch to -# Self hosted runners for running the arm64 tests -# name: PR Tests - Stack - Arm64 - -# on: -# workflow_call: - -# workflow_dispatch: -# inputs: -# none: -# description: "Run Version Tests Manually" -# required: false - -# concurrency: -# group: stackarm64-${{ github.event_name == 'pull_request' && format('{0}-{1}', github.workflow, github.event.pull_request.number) || github.workflow_ref }} -# cancel-in-progress: true - -# jobs: -# pr-tests-stack-arm64: -# strategy: -# max-parallel: 3 -# matrix: -# os: [ubuntu-latest] -# python-version: ["3.12"] - -# runs-on: ${{matrix.os}} - -# steps: -# # - name: set permissions on work folder for self-runners -# # run: | -# # sudo chown -R $USER:$USER ~/actions-runner/_work/ - -# - uses: actions/checkout@v4 - -# # free 10GB of space -# - name: Remove unnecessary files -# if: matrix.os == 'ubuntu-latest' -# run: | -# sudo rm -rf /usr/share/dotnet -# sudo rm -rf "$AGENT_TOOLSDIRECTORY" -# docker image prune --all --force -# docker builder prune --all --force -# docker system prune --all --force - -# - 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 -# with: -# python-version: ${{ matrix.python-version }} - -# - name: Upgrade pip -# run: | -# pip install --upgrade pip uv==0.1.35 -# uv --version - -# # - name: Get pip cache dir -# # id: pip-cache -# # shell: bash -# # run: | -# # echo "dir=$(uv cache dir)" >> $GITHUB_OUTPUT - -# # - name: pip cache -# # uses: actions/cache@v3 -# # with: -# # path: ${{ steps.pip-cache.outputs.dir }} -# # key: ${{ runner.os }}-uv-py${{ matrix.python-version }} -# # restore-keys: | -# # ${{ runner.os }}-uv-py${{ matrix.python-version }} - -# - name: Install tox -# run: | -# pip install --upgrade tox tox-uv==1.5.1 - -# - name: Install Docker Compose -# if: runner.os == 'Linux' -# shell: bash -# run: | -# mkdir -p ~/.docker/cli-plugins -# DOCKER_COMPOSE_VERSION=v2.21.0 -# curl -sSL https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose -# chmod +x ~/.docker/cli-plugins/docker-compose - -# - name: Setup linux/arm64 Docker -# run: | -# docker rm $(docker ps -aq) --force || true -# docker volume prune -f || true -# docker buildx create --platform linux/arm64 --name arm64builder || true -# docker buildx use arm64builder || true -# docker run --privileged --rm tonistiigi/binfmt --install arm64 -# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - -# - name: Run integration tests -# uses: nick-fields/retry@v3 -# with: -# timeout_seconds: 36000 -# max_attempts: 3 -# command: tox -e stack.test.integration From 8a0900d45c427b007b1d9fb1c48e6975f89deb60 Mon Sep 17 00:00:00 2001 From: Madhava Jay Date: Thu, 23 May 2024 07:24:07 +1000 Subject: [PATCH 4/4] Updating readme --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2a68d0d07ce..3761693131c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,14 @@ $ pip install -U syft[data_science] # from Jupyter / Python import syft as sy sy.requires(">=0.8.6,<0.8.7") -node = sy.orchestra.launch(name="my-domain", port=8080, dev_mode=True, reset=True) +node = sy.orchestra.launch( + name="my-domain", + port=8080, + create_producer=True, + n_consumers=1, + dev_mode=True, + reset=True, # resets database +) ``` ```bash @@ -39,7 +46,11 @@ Starting syft-node server on 0.0.0.0:8080 ```python import syft as sy sy.requires(">=0.8.6,<0.8.7") -domain_client = sy.login(port=8080, email="info@openmined.org", password="changethis") +domain_client = sy.login( + port=8080, + email="info@openmined.org", + password="changethis" +) ``` ## PySyft in 10 minutes @@ -58,6 +69,7 @@ domain_client = sy.login(port=8080, email="info@openmined.org", password="change - 09-blob-storage.ipynb - 10-container-images.ipynb - 11-container-images-k8s.ipynb +- 12-custom-api-endpoint.ipynb ## Deploy Kubernetes Helm Chart @@ -102,7 +114,7 @@ For AWS EKS helm install ... --set ingress.className="alb" ``` -For Google GKE we need the [`gce` annotation](https://cloud.google.com/kubernetes-engine/docs/how-to/load-balance-ingress#create-ingress) annotation. +For Google GKE we need the [`gce` annotation](https://cloud.google.com/kubernetes-engine/docs/how-to/load-balance-ingress#create-ingress). ```sh helm install ... --set ingress.class="gce" @@ -110,7 +122,7 @@ helm install ... --set ingress.class="gce" ## Note: -🚨 Our old deployment tool `Hagrid` has been `Deprecated`. For the updated deployment options kindly refer to +🚨 Our old deployment tool `HAGrid` has been `deprecated`. For the updated deployment options kindly refer to: - πŸ“š Deployments @@ -121,7 +133,7 @@ helm install ... --set ingress.class="gce" # Install Notes -- PySyft 0.8.1 Requires: 🐍 `python 3.10 - 3.12` - Run: `pip install -U syft` +- PySyft 0.8.6 Requires: 🐍 `python 3.10 - 3.12` - Run: `pip install -U syft` - PyGrid Requires: 🐳 `docker` or ☸️ `kubernetes` # Versions