Skip to content

Commit

Permalink
Merge pull request #8394 from khoaguin/update-roles-data-scientist
Browse files Browse the repository at this point in the history
data scientists can see worker pools, image, workers
  • Loading branch information
shubham3121 authored Jan 15, 2024
2 parents 837f0a7 + 9a47070 commit 9dc0a9f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ..service import AbstractService
from ..service import service_method
from ..user.user_roles import DATA_OWNER_ROLE_LEVEL
from ..user.user_roles import DATA_SCIENTIST_ROLE_LEVEL
from .image_registry import SyftImageRegistry
from .image_registry_service import SyftImageRegistryService
from .utils import docker_build
Expand Down Expand Up @@ -186,7 +187,7 @@ def push(
@service_method(
path="worker_image.get_all",
name="get_all",
roles=DATA_OWNER_ROLE_LEVEL,
roles=DATA_SCIENTIST_ROLE_LEVEL,
)
def get_all(
self, context: AuthedServiceContext
Expand Down
9 changes: 5 additions & 4 deletions packages/syft/src/syft/service/worker/worker_pool_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from ..service import TYPE_TO_SERVICE
from ..service import service_method
from ..user.user_roles import DATA_OWNER_ROLE_LEVEL
from ..user.user_roles import DATA_SCIENTIST_ROLE_LEVEL
from .utils import DEFAULT_WORKER_POOL_NAME
from .utils import run_containers
from .utils import run_workers_in_threads
Expand Down Expand Up @@ -133,7 +134,7 @@ def create_pool(
@service_method(
path="worker_pool.get_all",
name="get_all",
roles=DATA_OWNER_ROLE_LEVEL,
roles=DATA_SCIENTIST_ROLE_LEVEL,
)
def get_all(
self, context: AuthedServiceContext
Expand Down Expand Up @@ -273,7 +274,7 @@ def delete_worker(
@service_method(
path="worker_pool.filter_by_image_id",
name="filter_by_image_id",
roles=DATA_OWNER_ROLE_LEVEL,
roles=DATA_SCIENTIST_ROLE_LEVEL,
)
def filter_by_image_id(
self, context: AuthedServiceContext, image_uid: UID
Expand All @@ -288,7 +289,7 @@ def filter_by_image_id(
@service_method(
path="worker_pool.get_worker",
name="get_worker",
roles=DATA_OWNER_ROLE_LEVEL,
roles=DATA_SCIENTIST_ROLE_LEVEL,
)
def get_worker(
self, context: AuthedServiceContext, worker_pool_id: UID, worker_id: UID
Expand Down Expand Up @@ -351,7 +352,7 @@ def get_worker_status(
@service_method(
path="worker_pool.worker_logs",
name="worker_logs",
roles=DATA_OWNER_ROLE_LEVEL,
roles=DATA_SCIENTIST_ROLE_LEVEL,
)
def worker_logs(
self,
Expand Down
9 changes: 7 additions & 2 deletions packages/syft/src/syft/service/worker/worker_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ..service import SyftError
from ..service import service_method
from ..user.user_roles import ADMIN_ROLE_LEVEL
from ..user.user_roles import DATA_SCIENTIST_ROLE_LEVEL
from .utils import DEFAULT_WORKER_POOL_NAME
from .utils import _get_healthcheck_based_on_status
from .worker_pool import ContainerSpawnStatus
Expand Down Expand Up @@ -143,7 +144,9 @@ def start_workers(
context, number=n, pool_name=DEFAULT_WORKER_POOL_NAME
)

@service_method(path="worker.get_all", name="get_all", roles=ADMIN_ROLE_LEVEL)
@service_method(
path="worker.get_all", name="get_all", roles=DATA_SCIENTIST_ROLE_LEVEL
)
def list(self, context: AuthedServiceContext) -> Union[SyftSuccess, SyftError]:
"""List all the workers."""
result = self.stash.get_all(context.credentials)
Expand Down Expand Up @@ -171,7 +174,9 @@ def list(self, context: AuthedServiceContext) -> Union[SyftSuccess, SyftError]:

return workers

@service_method(path="worker.status", name="status", roles=ADMIN_ROLE_LEVEL)
@service_method(
path="worker.status", name="status", roles=DATA_SCIENTIST_ROLE_LEVEL
)
def status(
self,
context: AuthedServiceContext,
Expand Down

0 comments on commit 9dc0a9f

Please sign in to comment.