Skip to content

Commit

Permalink
Merge pull request #9319 from OpenMined/fix/rename_worker_pool_var_name
Browse files Browse the repository at this point in the history
Fix/rename worker pool var name
  • Loading branch information
IonesioJunior authored Sep 25, 2024
2 parents f56fe17 + b3d8b15 commit fd58782
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 57 deletions.
6 changes: 3 additions & 3 deletions notebooks/scenarios/bigquery/020-configure-api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
" description=\"This endpoint allows to query Bigquery storage via SQL queries.\",\n",
" private_function=private_func,\n",
" mock_function=mock_func,\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")\n",
"\n",
"high_client.custom_api.add(endpoint=new_endpoint)"
Expand Down Expand Up @@ -376,7 +376,7 @@
" settings={\n",
" \"calls_per_min\": 5,\n",
" },\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")"
]
},
Expand Down Expand Up @@ -431,7 +431,7 @@
"outputs": [],
"source": [
"submit_query_function = make_submit_query(\n",
" settings={}, worker_pool=this_worker_pool_name\n",
" settings={}, worker_pool_name=this_worker_pool_name\n",
")"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
" settings={\n",
" \"calls_per_min\": 5,\n",
" },\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")"
]
},
Expand Down Expand Up @@ -270,7 +270,7 @@
" description=\"This endpoint allows to query Bigquery storage via SQL queries.\",\n",
" private_function=private_func,\n",
" mock_function=mock_func,\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")\n",
"\n",
"high_client.custom_api.add(endpoint=new_endpoint)"
Expand Down Expand Up @@ -393,7 +393,7 @@
"outputs": [],
"source": [
"submit_query_function = make_submit_query(\n",
" settings={}, worker_pool=this_worker_pool_name\n",
" settings={}, worker_pool_name=this_worker_pool_name\n",
")"
]
},
Expand Down Expand Up @@ -614,7 +614,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from syft.rate_limiter import is_within_rate_limit


def make_schema(settings: dict, worker_pool: str) -> Callable:
def make_schema(settings: dict, worker_pool_name: str) -> Callable:
updated_settings = {
"calls_per_min": 5,
"rate_limiter_enabled": True,
Expand All @@ -26,7 +26,7 @@ def make_schema(settings: dict, worker_pool: str) -> Callable:
helper_functions=[
is_within_rate_limit
], # Adds ratelimit as this is also a method available to data scientists
worker_pool=worker_pool,
worker_pool_name=worker_pool_name,
)
def live_schema(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .data import schema_dict


def make_schema(settings, worker_pool) -> Callable:
def make_schema(settings, worker_pool_name) -> Callable:
updated_settings = {
"calls_per_min": 5,
"rate_limiter_enabled": True,
Expand All @@ -21,7 +21,7 @@ def make_schema(settings, worker_pool) -> Callable:
description="This endpoint allows for visualising the metadata of tables available in BigQuery.",
settings=updated_settings,
helper_functions=[is_within_rate_limit],
worker_pool=worker_pool,
worker_pool_name=worker_pool_name,
)
def mock_schema(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import syft as sy


def make_submit_query(settings, worker_pool):
updated_settings = {"user_code_worker": worker_pool} | settings
def make_submit_query(settings, worker_pool_name):
updated_settings = {"user_code_worker": worker_pool_name} | settings

@sy.api_endpoint(
path="bigquery.submit_query",
description="API endpoint that allows you to submit SQL queries to run on the private data.",
worker_pool=worker_pool,
worker_pool_name=worker_pool_name,
settings=updated_settings,
)
def submit_query(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
" description=\"This endpoint allows to query Bigquery storage via SQL queries.\",\n",
" private_function=private_func,\n",
" mock_function=mock_func,\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")\n",
"\n",
"high_client.custom_api.add(endpoint=new_endpoint)"
Expand Down Expand Up @@ -407,7 +407,7 @@
" settings={\n",
" \"calls_per_min\": 5,\n",
" },\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")"
]
},
Expand Down Expand Up @@ -462,7 +462,7 @@
"outputs": [],
"source": [
"submit_query_function = make_submit_query(\n",
" settings={}, worker_pool=this_worker_pool_name\n",
" settings={}, worker_pool_name=this_worker_pool_name\n",
")"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
" description=\"This endpoint allows to query Bigquery storage via SQL queries.\",\n",
" private_function=private_func,\n",
" mock_function=mock_func,\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")\n",
"\n",
"high_client.custom_api.add(endpoint=new_endpoint)"
Expand Down Expand Up @@ -221,7 +221,7 @@
" settings={\n",
" \"calls_per_min\": 5,\n",
" },\n",
" worker_pool=this_worker_pool_name,\n",
" worker_pool_name=this_worker_pool_name,\n",
")"
]
},
Expand Down Expand Up @@ -282,7 +282,7 @@
"outputs": [],
"source": [
"submit_query_function = make_submit_query(\n",
" settings={}, worker_pool=this_worker_pool_name\n",
" settings={}, worker_pool_name=this_worker_pool_name\n",
")"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ..rate_limiter import is_within_rate_limit


def make_schema(settings: dict, worker_pool: str) -> Callable:
def make_schema(settings: dict, worker_pool_name: str) -> Callable:
updated_settings = {
"calls_per_min": 5,
"rate_limiter_enabled": True,
Expand All @@ -28,7 +28,7 @@ def make_schema(settings: dict, worker_pool: str) -> Callable:
helper_functions=[
is_within_rate_limit
], # Adds ratelimit as this is also a method available to data scientists
worker_pool=worker_pool,
worker_pool_name=worker_pool_name,
)
def live_schema(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .data import schema_dict


def make_schema(settings, worker_pool) -> Callable:
def make_schema(settings, worker_pool_name) -> Callable:
updated_settings = {
"calls_per_min": 5,
"rate_limiter_enabled": True,
Expand All @@ -21,7 +21,7 @@ def make_schema(settings, worker_pool) -> Callable:
description="This endpoint allows for visualising the metadata of tables available in BigQuery.",
settings=updated_settings,
helper_functions=[is_within_rate_limit],
worker_pool=worker_pool,
worker_pool_name=worker_pool_name,
)
def mock_schema(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import syft as sy


def make_submit_query(settings, worker_pool):
updated_settings = {"user_code_worker": worker_pool} | settings
def make_submit_query(settings, worker_pool_name):
updated_settings = {"user_code_worker": worker_pool_name} | settings

@sy.api_endpoint(
path="bigquery.submit_query",
description="API endpoint that allows you to submit SQL queries to run on the private data.",
worker_pool=worker_pool,
worker_pool_name=worker_pool_name,
settings=updated_settings,
)
def submit_query(
Expand Down
21 changes: 21 additions & 0 deletions packages/syft/src/syft/protocol/protocol_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,27 @@
"hash": "7659117222a461a959eac7aa1aaf280033c2ca4f1029f97e76051e0474e56759",
"action": "add"
}
},
"CustomAPIView": {
"2": {
"version": 2,
"hash": "7eb2cd60e9526299c3f989930733b8bfd2e81d4e93a1b82217dec2e0a786ba10",
"action": "add"
}
},
"CreateTwinAPIEndpoint": {
"2": {
"version": 2,
"hash": "f4048d6cf886ea519df25300af17912c818095288d42f7ef9183372c9c19db79",
"action": "add"
}
},
"TwinAPIEndpoint": {
"2": {
"version": 2,
"hash": "40229be687cd4290447fe8b409ba3dc1b8d410c5dac37cebb9856fb34d7507cd",
"action": "add"
}
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions packages/syft/src/syft/server/server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# futureserver.py
# future
from __future__ import annotations

Expand Down Expand Up @@ -1331,21 +1332,21 @@ def add_api_endpoint_execution_to_queue(
path: str,
log_id: UID,
*args: Any,
worker_pool: str | None = None,
worker_pool_name: str | None = None,
**kwargs: Any,
) -> Job:
job_id = UID()
task_uid = UID()
worker_settings = WorkerSettings.from_server(server=self)

if worker_pool is None:
worker_pool = self.get_default_worker_pool().unwrap()
if worker_pool_name is None:
worker_pool_name = self.get_default_worker_pool().unwrap()
else:
worker_pool = self.get_worker_pool_by_name(worker_pool).unwrap()
worker_pool_name = self.get_worker_pool_by_name(worker_pool_name).unwrap()

# Create a Worker pool reference object
worker_pool_ref = LinkedObject.from_obj(
worker_pool,
worker_pool_name,
service_type=SyftWorkerPoolService,
server_uid=self.id,
)
Expand Down
Loading

0 comments on commit fd58782

Please sign in to comment.