Skip to content

Commit

Permalink
style fixes by ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Smartappli authored and github-actions[bot] committed Aug 3, 2024
1 parent ec16803 commit abf44de
Show file tree
Hide file tree
Showing 373 changed files with 5,653 additions and 6,329 deletions.
4 changes: 2 additions & 2 deletions notebooks/api/0.8/00-load-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"source": [
"# Launch a fresh datasite server named \"test-datasite-1\" in dev mode on the local machine\n",
"server = sy.orchestra.launch(\n",
" name=\"test-datasite-1\", port=\"auto\", dev_mode=True, reset=True\n",
" name=\"test-datasite-1\", port=\"auto\", dev_mode=True, reset=True,\n",
")"
]
},
Expand Down Expand Up @@ -435,7 +435,7 @@
"source": [
"ctf = sy.Asset(name=\"canada_trade_flow\")\n",
"ctf.set_description(\n",
" \"Canada trade flow represents export & import of different commodities to other countries\"\n",
" \"Canada trade flow represents export & import of different commodities to other countries\",\n",
")"
]
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/api/0.8/02-review-code-and-approve.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
" reason=(\n",
" \"The Submitted UserCode does not add differential privacy to the output.\"\n",
" \"Kindly add differential privacy and resubmit the code.\"\n",
" )\n",
" ),\n",
")\n",
"result"
]
Expand Down
11 changes: 5 additions & 6 deletions notebooks/api/0.8/04-pytorch-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
"outputs": [],
"source": [
"# third party\n",
"import torch\n",
"import torch.nn as nn\n",
"import torch.nn.functional as F\n",
"\n",
"# syft absolute\n",
"import syft as sy\n",
"import torch\n",
"import torch.nn.functional as F\n",
"from torch import nn\n",
"\n",
"sy.requires(SYFT_VERSION)"
]
Expand Down Expand Up @@ -247,15 +246,15 @@
"source": [
"@sy.syft_function(\n",
" input_policy=sy.ExactMatch(\n",
" weights=weight_datasite_obj.id, data=train_datasite_obj.id\n",
" weights=weight_datasite_obj.id, data=train_datasite_obj.id,\n",
" ),\n",
" output_policy=sy.SingleExecutionExactOutput(),\n",
")\n",
"def train_mlp(weights, data):\n",
" # third party\n",
" import torch\n",
" import torch.nn as nn\n",
" import torch.nn.functional as F\n",
" from torch import nn\n",
"\n",
" class MLP(nn.Module):\n",
" def __init__(self, out_dims):\n",
Expand Down
32 changes: 14 additions & 18 deletions notebooks/api/0.8/05-custom-policy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"outputs": [],
"source": [
"server = sy.orchestra.launch(\n",
" name=\"test-datasite-1\", port=\"auto\", dev_mode=True, reset=True\n",
" name=\"test-datasite-1\", port=\"auto\", dev_mode=True, reset=True,\n",
")"
]
},
Expand All @@ -66,7 +66,7 @@
"outputs": [],
"source": [
"datasite_client.register(\n",
" email=\"[email protected]\", name=\"John Doe\", password=\"pw\", password_verify=\"pw\"\n",
" email=\"[email protected]\", name=\"John Doe\", password=\"pw\", password_verify=\"pw\",\n",
")"
]
},
Expand Down Expand Up @@ -244,12 +244,10 @@
"outputs": [],
"source": [
"# third party\n",
"from result import Err\n",
"from result import Ok\n",
"from result import Err, Ok\n",
"\n",
"# syft absolute\n",
"from syft.client.api import AuthedServiceContext\n",
"from syft.client.api import ServerIdentity\n",
"from syft.client.api import AuthedServiceContext, ServerIdentity\n",
"\n",
"\n",
"class CustomExactMatch(sy.CustomInputPolicy):\n",
Expand All @@ -261,7 +259,7 @@
"\n",
" try:\n",
" allowed_inputs = self.allowed_ids_only(\n",
" allowed_inputs=self.inputs, kwargs=kwargs, context=context\n",
" allowed_inputs=self.inputs, kwargs=kwargs, context=context,\n",
" )\n",
" results = self.retrieve_from_db(\n",
" code_item_id=code_item_id,\n",
Expand All @@ -286,7 +284,7 @@
" # but we are not modifying the permissions of the private data\n",
"\n",
" root_context = AuthedServiceContext(\n",
" server=context.server, credentials=context.server.verify_key\n",
" server=context.server, credentials=context.server.verify_key,\n",
" )\n",
" if context.server.server_type == ServerType.DATASITE:\n",
" for var_name, arg_id in allowed_inputs.items():\n",
Expand All @@ -301,7 +299,7 @@
" code_inputs[var_name] = kwarg_value.ok()\n",
" else:\n",
" raise Exception(\n",
" f\"Invalid Server Type for Code Submission:{context.server.server_type}\"\n",
" f\"Invalid Server Type for Code Submission:{context.server.server_type}\",\n",
" )\n",
" return Ok(code_inputs)\n",
"\n",
Expand All @@ -312,8 +310,7 @@
" context,\n",
" ):\n",
" # syft absolute\n",
" from syft import ServerType\n",
" from syft import UID\n",
" from syft import UID, ServerType\n",
"\n",
" if context.server.server_type == ServerType.DATASITE:\n",
" server_identity = ServerIdentity(\n",
Expand All @@ -324,7 +321,7 @@
" allowed_inputs = allowed_inputs.get(server_identity, {})\n",
" else:\n",
" raise Exception(\n",
" f\"Invalid Server Type for Code Submission:{context.server.server_type}\"\n",
" f\"Invalid Server Type for Code Submission:{context.server.server_type}\",\n",
" )\n",
" filtered_kwargs = {}\n",
" for key in allowed_inputs.keys():\n",
Expand All @@ -336,7 +333,7 @@
"\n",
" if uid != allowed_inputs[key]:\n",
" raise Exception(\n",
" f\"Input with uid: {uid} for `{key}` not in allowed inputs: {allowed_inputs}\"\n",
" f\"Input with uid: {uid} for `{key}` not in allowed inputs: {allowed_inputs}\",\n",
" )\n",
" filtered_kwargs[key] = value\n",
" return filtered_kwargs\n",
Expand Down Expand Up @@ -369,7 +366,7 @@
" not_approved_kwargs = set(expected_input_kwargs) - set(permitted_input_kwargs)\n",
" if len(not_approved_kwargs) > 0:\n",
" return Err(\n",
" f\"Input arguments: {not_approved_kwargs} to the function are not approved yet.\"\n",
" f\"Input arguments: {not_approved_kwargs} to the function are not approved yet.\",\n",
" )\n",
" return Ok(True)\n",
"\n",
Expand All @@ -381,8 +378,7 @@
" context,\n",
"):\n",
" # syft absolute\n",
" from syft import ServerType\n",
" from syft import UID\n",
" from syft import UID, ServerType\n",
" from syft.client.api import ServerIdentity\n",
"\n",
" if context.server.server_type == ServerType.DATASITE:\n",
Expand All @@ -394,7 +390,7 @@
" allowed_inputs = allowed_inputs.get(server_identity, {})\n",
" else:\n",
" raise Exception(\n",
" f\"Invalid Server Type for Code Submission:{context.server.server_type}\"\n",
" f\"Invalid Server Type for Code Submission:{context.server.server_type}\",\n",
" )\n",
" filtered_kwargs = {}\n",
" for key in allowed_inputs.keys():\n",
Expand All @@ -406,7 +402,7 @@
"\n",
" if uid != allowed_inputs[key]:\n",
" raise Exception(\n",
" f\"Input with uid: {uid} for `{key}` not in allowed inputs: {allowed_inputs}\"\n",
" f\"Input with uid: {uid} for `{key}` not in allowed inputs: {allowed_inputs}\",\n",
" )\n",
" filtered_kwargs[key] = value\n",
" return filtered_kwargs"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/api/0.8/06-multiple-code-requests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"outputs": [],
"source": [
"server = sy.orchestra.launch(\n",
" name=\"test-datasite-1\", port=\"auto\", reset=True, dev_mode=True\n",
" name=\"test-datasite-1\", port=\"auto\", reset=True, dev_mode=True,\n",
")"
]
},
Expand Down
2 changes: 1 addition & 1 deletion notebooks/api/0.8/07-datasite-register-control-flow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"outputs": [],
"source": [
"server = sy.orchestra.launch(\n",
" name=\"test-datasite-1\", port=\"auto\", dev_mode=True, reset=True\n",
" name=\"test-datasite-1\", port=\"auto\", dev_mode=True, reset=True,\n",
")"
]
},
Expand Down
12 changes: 6 additions & 6 deletions notebooks/api/0.8/10-container-images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
"outputs": [],
"source": [
"submit_result = datasite_client.api.services.worker_image.submit(\n",
" worker_config=docker_config\n",
" worker_config=docker_config,\n",
")"
]
},
Expand Down Expand Up @@ -474,7 +474,7 @@
"source": [
"if running_as_container:\n",
" assert workerimage.image_hash == get_image_hash(\n",
" workerimage.built_image_tag\n",
" workerimage.built_image_tag,\n",
" ), \"Worker Image image_hash does not match with built image hash\""
]
},
Expand Down Expand Up @@ -627,7 +627,7 @@
" assert status.error is None\n",
" if running_as_container:\n",
" assert status.worker.image.image_hash == get_image_hash(\n",
" workerimage.built_image_tag\n",
" workerimage.built_image_tag,\n",
" ), \"Worker Pool Image image_hash does not match with built image hash\""
]
},
Expand Down Expand Up @@ -762,7 +762,7 @@
"outputs": [],
"source": [
"worker_delete_res = datasite_client.api.services.worker.delete(\n",
" uid=second_worker.id, force=True\n",
" uid=second_worker.id, force=True,\n",
")"
]
},
Expand Down Expand Up @@ -1096,7 +1096,7 @@
"outputs": [],
"source": [
"submit_result = datasite_client.api.services.worker_image.submit(\n",
" worker_config=docker_config_2\n",
" worker_config=docker_config_2,\n",
")\n",
"submit_result"
]
Expand Down Expand Up @@ -1159,7 +1159,7 @@
"source": [
"opendp_pool_name = \"second-opendp-pool\"\n",
"pool_create_request = datasite_client.api.services.worker_pool.pool_creation_request(\n",
" pool_name=opendp_pool_name, num_workers=2, image_uid=workerimage_2.id\n",
" pool_name=opendp_pool_name, num_workers=2, image_uid=workerimage_2.id,\n",
")\n",
"pool_create_request"
]
Expand Down
Loading

0 comments on commit abf44de

Please sign in to comment.