diff --git a/.gitignore b/.gitignore index 72d8b65e3ce..de762cac9c8 100644 --- a/.gitignore +++ b/.gitignore @@ -84,4 +84,7 @@ out.* packages/grid/helm/examples/dev/migration.yaml # dynaconf settings file -**/settings.yaml \ No newline at end of file +**/settings.yaml + + +notebooks/scenarios/bigquery/*.json diff --git a/notebooks/scenarios/bigquery/00-start-and-configure-server-and-admins.ipynb b/notebooks/scenarios/bigquery/00-start-and-configure-server-and-admins.ipynb index 8235576b5f5..8a438cbc935 100644 --- a/notebooks/scenarios/bigquery/00-start-and-configure-server-and-admins.ipynb +++ b/notebooks/scenarios/bigquery/00-start-and-configure-server-and-admins.ipynb @@ -222,11 +222,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -237,7 +232,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/001-scale-delete-worker-pools.ipynb b/notebooks/scenarios/bigquery/001-scale-delete-worker-pools.ipynb index 0549593495b..4741a74ebce 100644 --- a/notebooks/scenarios/bigquery/001-scale-delete-worker-pools.ipynb +++ b/notebooks/scenarios/bigquery/001-scale-delete-worker-pools.ipynb @@ -415,11 +415,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -430,7 +425,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/01-setup-datasite.ipynb b/notebooks/scenarios/bigquery/01-setup-datasite.ipynb index c734b07298e..6ce2e541480 100644 --- a/notebooks/scenarios/bigquery/01-setup-datasite.ipynb +++ b/notebooks/scenarios/bigquery/01-setup-datasite.ipynb @@ -490,11 +490,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -505,7 +500,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/011-users-emails-passwords.ipynb b/notebooks/scenarios/bigquery/011-users-emails-passwords.ipynb index c585aa55a07..b3ca595d812 100644 --- a/notebooks/scenarios/bigquery/011-users-emails-passwords.ipynb +++ b/notebooks/scenarios/bigquery/011-users-emails-passwords.ipynb @@ -412,11 +412,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -427,7 +422,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/02-configure-api.ipynb b/notebooks/scenarios/bigquery/02-configure-api.ipynb index 854190b1861..9f0051c141c 100644 --- a/notebooks/scenarios/bigquery/02-configure-api.ipynb +++ b/notebooks/scenarios/bigquery/02-configure-api.ipynb @@ -529,11 +529,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -544,7 +539,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/021-create-jobs.ipynb b/notebooks/scenarios/bigquery/021-create-jobs.ipynb index c889100e86b..ea549d3625d 100644 --- a/notebooks/scenarios/bigquery/021-create-jobs.ipynb +++ b/notebooks/scenarios/bigquery/021-create-jobs.ipynb @@ -417,11 +417,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -432,7 +427,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/04-do-review-requests.ipynb b/notebooks/scenarios/bigquery/04-do-review-requests.ipynb index 011c4bf3e25..716eb756c43 100644 --- a/notebooks/scenarios/bigquery/04-do-review-requests.ipynb +++ b/notebooks/scenarios/bigquery/04-do-review-requests.ipynb @@ -70,6 +70,15 @@ ")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "high_client.requests.get_all_pending()" + ] + }, { "cell_type": "code", "execution_count": null, @@ -211,6 +220,24 @@ "save_jobs(jobs)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "high_client.requests.get_all_approved()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "high_client.requests.get_all_rejected()" + ] + }, { "cell_type": "code", "execution_count": null, @@ -238,11 +265,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -253,7 +275,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/042-data_review.ipynb b/notebooks/scenarios/bigquery/042-data_review.ipynb deleted file mode 100644 index b0111e9e12f..00000000000 --- a/notebooks/scenarios/bigquery/042-data_review.ipynb +++ /dev/null @@ -1,276 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# stdlib\n", - "import os\n", - "\n", - "environment = os.environ.get(\"ORCHESTRA_DEPLOYMENT_TYPE\", \"python\")\n", - "environment" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# third party\n", - "\n", - "# syft absolute\n", - "import syft as sy" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "SERVER_PORT = \"8080\"\n", - "SERVER_URL = f\"http://localhost:{SERVER_PORT}\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "server = sy.orchestra.launch(\n", - " name=\"bigquery-high\",\n", - " dev_mode=True,\n", - " server_side_type=\"high\",\n", - " # reset=True,\n", - " port=SERVER_PORT,\n", - " n_consumers=4, # How many workers to be spawned\n", - " create_producer=True, # Can produce more workers\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ADMIN_EMAIL, ADMIN_PW = \"admin2@bigquery.org\", \"bqpw2\"\n", - "high_client = sy.login(\n", - " url=\"http://localhost:8080\", email=ADMIN_EMAIL, password=ADMIN_PW\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "high_client.requests" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "high_client.requests.get_all_approved()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "high_client.requests[2].code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "with sy.raises(sy.SyftException):\n", - " high_client.requests[2].code()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "job = high_client.requests[2].code(blocking=False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "job.wait()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "assert isinstance(job.result, sy.SyftError)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "high_client.requests" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for request in high_client.requests:\n", - " if request.code.service_func_name.startswith(\"wrong_syntax_query\"):\n", - " bad_request = request\n", - " if request.code.service_func_name.startswith(\"simple_query\"):\n", - " good_request = request" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "good_job = good_request.code(blocking=False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "good_job.wait()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "high_client.requests.get_all_approved()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# stdlib\n", - "import json\n", - "\n", - "# third party\n", - "from job_helpers import resolve_request\n", - "\n", - "request_dict = {}\n", - "\n", - "for request in high_client.requests:\n", - " request_id, request_status = resolve_request(request)\n", - " request_dict[str(request_id)] = str(request_status)\n", - "\n", - "with open(\".requests.json\", \"w\") as fp:\n", - " json.dump(request_dict, fp)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "bad_job = bad_request.code(blocking=False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "bad_job" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "bad_job.wait()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "retry_good_job = good_request.code(blocking=False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "retry_good_job.wait()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.5" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/notebooks/scenarios/bigquery/05-ds-get-results.ipynb b/notebooks/scenarios/bigquery/05-ds-get-results.ipynb index f9f7a36ae84..843fdefcaf6 100644 --- a/notebooks/scenarios/bigquery/05-ds-get-results.ipynb +++ b/notebooks/scenarios/bigquery/05-ds-get-results.ipynb @@ -125,39 +125,39 @@ "outputs": [], "source": [ "for job in reviewed_jobs:\n", - " print(f\"> Checking job: {job.job_type} {job.func_name} for user {job.user_email}\")\n", + " print(\n", + " f\"> Checking job: {job.job_type} {job.func_name} for user {job.user_email} {job.should_succeed}\"\n", + " )\n", " api_method = job.code_method\n", "\n", " if job.should_succeed:\n", - " print(\"Expecting job to succeed\")\n", + " # print(\"Expecting job to succeed\")\n", " j = api_method(blocking=False)\n", - " result = j.wait().get()\n", - " print(\n", - " \"> Got result of type\",\n", - " type(result),\n", - " \"expecting limit\",\n", - " job.settings[\"limit\"],\n", - " )\n", + " res = j.wait()\n", + " if isinstance(res, sy.SyftError):\n", + " job.result_as_expected = False\n", + " print(\"Expected success, got error\")\n", + " continue\n", + "\n", + " result = res.get()\n", " if hasattr(result, \"__len__\"):\n", - " print(\"> Result length\", len(result))\n", - " assert len(result) == job.settings[\"limit\"]\n", + " pass\n", + " # print(\"> Result length\", len(result))\n", + "\n", + " # assert len(result) == job.settings[\"limit\"]\n", + " print(\"success\")\n", " job.result_as_expected = True\n", " save_jobs(jobs)\n", " else:\n", - " print(\"Expecting job to fail\")\n", - " # with sy.raises(\n", - " # sy.SyftException(public_message=\"*UserCodeStatus.DENIED*\"), show=True\n", - " # ):\n", - " # with sy.raises(\n", - " # sy.SyftException, show=True\n", - " # ):\n", - " try:\n", - " j = api_method(blocking=False)\n", + " # print(\"Expecting job to fail\")\n", + " j = api_method(blocking=False)\n", + " res = j.wait()\n", + " if isinstance(res, sy.SyftError):\n", + " job.result_as_expected = True\n", + " print(\"Expected to error, success\")\n", + " else:\n", " print(\"failed job didnt raise\", type(j))\n", " job.result_as_expected = False\n", - " except Exception as e:\n", - " job.result_as_expected = True\n", - " print(\"failed job raised\", type(e))\n", "\n", " save_jobs(jobs)" ] @@ -180,7 +180,7 @@ "source": [ "# TODO fix\n", "print(f\"got expected_jobs: {len(expected_jobs)} == reviewed_jobs: {len(reviewed_jobs)}\")\n", - "# assert len(reviewed_jobs) == len(expected_jobs)" + "assert len(reviewed_jobs) == len(expected_jobs)" ] }, { @@ -210,11 +210,6 @@ } ], "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -225,7 +220,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.5" } }, "nbformat": 4, diff --git a/notebooks/scenarios/bigquery/job_helpers.py b/notebooks/scenarios/bigquery/job_helpers.py index 69695939ccd..777a781836d 100644 --- a/notebooks/scenarios/bigquery/job_helpers.py +++ b/notebooks/scenarios/bigquery/job_helpers.py @@ -312,7 +312,7 @@ def resolve_request(request): if service_func_name.startswith("job_too_much_text"): request.deny(reason="too long, boring!") # deny because it is bad if service_func_name.startswith("job_long_name"): - request.deny(reason="too long, boring!") # deny because it is bad + request.approve() if service_func_name.startswith("job_funcname_xss"): request.deny(reason="too long, boring!") # never reach doesnt matter if service_func_name.startswith("job_query_xss"): @@ -330,7 +330,6 @@ def resolve_request(request): create_simple_query_job, create_simple_query_job, create_simple_query_job, - create_wrong_asset_query, create_wrong_syntax_query, create_long_query_job, create_query_long_name,