diff --git a/examples/forecast/forecast_instance.ipynb b/examples/forecast/forecast_instance.ipynb new file mode 100644 index 00000000..232901c8 --- /dev/null +++ b/examples/forecast/forecast_instance.ipynb @@ -0,0 +1,166 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "ab7dc6e0", + "metadata": {}, + "source": [ + "# Forecast Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "aebb03ba", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/forecast/forecast_instance_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/forecast/forecast_instance_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7ef634ce", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.forecast.forecast_instance as forecast_instance" + ] + }, + { + "cell_type": "markdown", + "id": "5f4f811e", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7d282050", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "96092ed1", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "1488d21f", + "metadata": {}, + "source": [ + "## get forecast instances" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "646f90e3", + "metadata": {}, + "outputs": [], + "source": [ + "forecast = forecast_instance.get_forecast_instances(\"test-spec\", \"SWT\", \"designator\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "afa15099", + "metadata": {}, + "source": [ + "## retrieve forecast instance json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "76b2ffcd", + "metadata": {}, + "outputs": [], + "source": [ + "forecast_date = datetime.utcfromtimestamp(1624284010000 / 1000)\n", + "issue_date = datetime.utcfromtimestamp(1653221020000 / 1000)\n", + "forecast = forecast_instance.get_forecast_instance(\n", + " \"test-spec\", \"SWT\", \"designator\", forecast_date, issue_date\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "id": "ed9bce32", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "3ce6a6e1", + "metadata": {}, + "source": [ + "## store forecast instance json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "659193b8", + "metadata": {}, + "outputs": [], + "source": [ + "forecast_instance.store_forecast_instance(_FORECAST_INSTANCE_JSON)\n" + ] + }, + { + "cell_type": "markdown", + "id": "b733cbf7", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "cfc52b02", + "metadata": {}, + "source": [ + "## delete forecast instance json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "55b01423", + "metadata": {}, + "outputs": [], + "source": [ + "forecast_date = datetime.utcfromtimestamp(1624284010000 / 1000)\n", + "issue_date = datetime.utcfromtimestamp(1653221020000 / 1000)\n", + "forecast_instance.delete_forecast_instance(\n", + " \"test-spec\", \"SWT\", \"designator\", forecast_date, issue_date\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/forecast/forecast_spec.ipynb b/examples/forecast/forecast_spec.ipynb new file mode 100644 index 00000000..89cfa4bc --- /dev/null +++ b/examples/forecast/forecast_spec.ipynb @@ -0,0 +1,162 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "5a0412fa", + "metadata": {}, + "source": [ + "# Forecast Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "e807fd07", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/forecast/forecast_spec_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/forecast/forecast_spec_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5f27357f", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.forecast.forecast_spec as forecast_spec\n", + "from cwms.cwms_types import DeleteMethod" + ] + }, + { + "cell_type": "markdown", + "id": "b901d06f", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "45d5fbce", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "6c35dcd9", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "38156106", + "metadata": {}, + "source": [ + "## get forecast specs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "036cbba3", + "metadata": {}, + "outputs": [], + "source": [ + "forecast = forecast_spec.get_forecast_specs(\n", + " \"id_mask\", \"office_mask\", \"designator_mask\", \"source_entity\"\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "id": "56ed6dd6", + "metadata": {}, + "source": [ + "## get forecast spec" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e701b235", + "metadata": {}, + "outputs": [], + "source": [ + "forecast = forecast_spec.get_forecast_spec(\"test-spec\", \"SWT\", \"designator\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "c4beea74", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "be5bb3d5", + "metadata": {}, + "source": [ + "## store forecast spec json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f6b04f28", + "metadata": {}, + "outputs": [], + "source": [ + "forecast_spec.store_forecast_spec(_FORECAST_SPEC_JSON)\n" + ] + }, + { + "cell_type": "markdown", + "id": "4ccfb97b", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "6ad09e7a", + "metadata": {}, + "source": [ + "## delete forecast spec" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c8f256e6", + "metadata": {}, + "outputs": [], + "source": [ + "forecast_spec.delete_forecast_spec(\n", + " \"test-spec\", \"SWT\", \"designator\", DeleteMethod.DELETE_KEY\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/levels/location_levels.ipynb b/examples/levels/location_levels.ipynb new file mode 100644 index 00000000..0b71ba85 --- /dev/null +++ b/examples/levels/location_levels.ipynb @@ -0,0 +1,223 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "a695015e", + "metadata": {}, + "source": [ + "# Levels Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "85f5e45e", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/levels/location_levels_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/levels/location_levels_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fc2f0442", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.levels.location_levels as location_levels" + ] + }, + { + "cell_type": "markdown", + "id": "4e5d13cc", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "70ce6702", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "4681d4fe", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "827220d9", + "metadata": {}, + "source": [ + "## retrieve loc levels default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6f939a95", + "metadata": {}, + "outputs": [], + "source": [ + "levels = location_levels.get_location_levels()\n" + ] + }, + { + "cell_type": "markdown", + "id": "7d4fbd19", + "metadata": {}, + "source": [ + "## get loc levels" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4cf25af1", + "metadata": {}, + "outputs": [], + "source": [ + "level_id = \"AARK.Elev.Inst.0.Bottom of Inlet\"\n", + "office_id = \"SWT\"\n", + "unit = \"m\"\n", + "datum = \"NAV88\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2020, 2, 14, 10, 30, 0))\n", + "end = timezone.localize(datetime(2020, 3, 30, 10, 30, 0))\n", + "page = \"MHx8bnVsbHx8MTAw\"\n", + "page_size = 100\n", + "levels = location_levels.get_location_levels(\n", + " level_id, office_id, unit, datum, begin, end, page, page_size\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "id": "9216419a", + "metadata": {}, + "source": [ + "## get loc level" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2c018420", + "metadata": {}, + "outputs": [], + "source": [ + "level_id = \"AARK.Elev.Inst.0.Bottom of Inlet\"\n", + "office_id = \"SWT\"\n", + "unit = \"m\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "effective_date = timezone.localize(datetime(2020, 2, 14, 10, 30, 0))\n", + "levels = location_levels.get_location_level(level_id, office_id, effective_date, unit)\n" + ] + }, + { + "cell_type": "markdown", + "id": "a6893947", + "metadata": {}, + "source": [ + "## get loc level ts" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "10b28f32", + "metadata": {}, + "outputs": [], + "source": [ + "level_id = \"AARK.Elev.Inst.0.Bottom of Inlet\"\n", + "office_id = \"SWT\"\n", + "interval = \"1Day\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2020, 2, 14, 10, 30, 0))\n", + "end = timezone.localize(datetime(2020, 3, 14, 10, 30, 0))\n", + "levels = location_levels.get_level_as_timeseries(\n", + " level_id, office_id, \"m\", begin, end, interval\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "id": "ab64fbd7", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "77760591", + "metadata": {}, + "source": [ + "## store loc level json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "82cb19a0", + "metadata": {}, + "outputs": [], + "source": [ + "data = _LOC_LEVEL_JSON\n", + "location_levels.store_location_level(data)\n" + ] + }, + { + "cell_type": "markdown", + "id": "8b0b6738", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "236b044f", + "metadata": {}, + "source": [ + "## delete loc level" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "421b6546", + "metadata": {}, + "outputs": [], + "source": [ + "level_id = \"AARK.Elev.Inst.0.Bottom of Inlet\"\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "effective_date = timezone.localize(datetime(2020, 2, 14, 10, 30, 0))\n", + "location_levels.delete_location_level(level_id, office_id, effective_date, True)\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/levels/specified_levels.ipynb b/examples/levels/specified_levels.ipynb new file mode 100644 index 00000000..03521a77 --- /dev/null +++ b/examples/levels/specified_levels.ipynb @@ -0,0 +1,185 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "597d9bf2", + "metadata": {}, + "source": [ + "# Levels Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "1a0097ba", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/levels/specified_levels_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/levels/specified_levels_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0e1080f3", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pytz\n", + "from requests.exceptions import HTTPError\n", + "import cwms.api\n", + "import cwms.levels.specified_levels as specified_levels" + ] + }, + { + "cell_type": "markdown", + "id": "665b3280", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "06bb052c", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "aef52128", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "9ffd3ae9", + "metadata": {}, + "source": [ + "## get specified levels default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9ffba5c6", + "metadata": {}, + "outputs": [], + "source": [ + "levels = specified_levels.get_specified_levels()\n" + ] + }, + { + "cell_type": "markdown", + "id": "322d834b", + "metadata": {}, + "source": [ + "## get specified levels" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7c9392a", + "metadata": {}, + "outputs": [], + "source": [ + "levels = specified_levels.get_specified_levels(\"*\", \"SWT\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "17c5638f", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "5635be36", + "metadata": {}, + "source": [ + "## store specified level" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0279ac05", + "metadata": {}, + "outputs": [], + "source": [ + "specified_levels.store_specified_level(_SPEC_LEVEL_JSON)\n" + ] + }, + { + "cell_type": "markdown", + "id": "cf837093", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "1504637b", + "metadata": {}, + "source": [ + "## delete specified level" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a88cb67", + "metadata": {}, + "outputs": [], + "source": [ + "specified_levels.delete_specified_level(\"Test\", \"SWT\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "629b737f", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "60213c9d", + "metadata": {}, + "source": [ + "## update specified level" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "71218433", + "metadata": {}, + "outputs": [], + "source": [ + "specified_levels.update_specified_level(\"Test\", \"Test2\", \"SWT\")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/locations/gate_changes.ipynb b/examples/locations/gate_changes.ipynb new file mode 100644 index 00000000..fa7c31de --- /dev/null +++ b/examples/locations/gate_changes.ipynb @@ -0,0 +1,160 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "583dd40d", + "metadata": {}, + "source": [ + "# Locations Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "7fc665ff", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/locations/gate_changes_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/locations/gate_changes_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c5b5755", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import urllib.parse\n", + "from datetime import datetime\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.locations.gate_changes as gate_changes" + ] + }, + { + "cell_type": "markdown", + "id": "5d7dbe6c", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c4f8dd0", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "ce09bdb6", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "9758ac6c", + "metadata": {}, + "source": [ + "## get all gate changes" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8b0a6f26", + "metadata": {}, + "outputs": [], + "source": [ + "office_id = \"SPK\"\n", + "project_id = \"SPK.BIGH\"\n", + "start = datetime.fromisoformat(\"2022-01-01T00:00:00\")\n", + "end = datetime.fromisoformat(\"2025-01-01T00:00:00\")\n", + "data = gate_changes.get_all_gate_changes(office_id, project_id, start, end)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "80ae853a", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "774edb16", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "fa24f50c", + "metadata": {}, + "source": [ + "## store gate change" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "116b41ed", + "metadata": {}, + "outputs": [], + "source": [ + "data = _GATE_CHANGE_JSON\n", + "gate_changes.store_gate_change(data, False)\n" + ] + }, + { + "cell_type": "markdown", + "id": "f8fa613f", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "e48f061e", + "metadata": {}, + "source": [ + "## delete gate change" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e5e5046d", + "metadata": {}, + "outputs": [], + "source": [ + "office_id = \"SPK\"\n", + "project_id = \"SPK.BIGH\"\n", + "start = datetime.fromisoformat(\"2022-01-01T00:00:00\")\n", + "end = datetime.fromisoformat(\"2025-01-01T00:00:00\")\n", + "gate_changes.delete_gate_change(office_id, project_id, start, end)\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/locations/physical_locations.ipynb b/examples/locations/physical_locations.ipynb new file mode 100644 index 00000000..f20cbb18 --- /dev/null +++ b/examples/locations/physical_locations.ipynb @@ -0,0 +1,121 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "207ca34b", + "metadata": {}, + "source": [ + "# Locations Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "7a930066", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/locations/physical_locations_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/locations/physical_locations_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dbf27870", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import pandas as pd\n", + "import cwms.api\n", + "import cwms.locations.physical_locations as locations" + ] + }, + { + "cell_type": "markdown", + "id": "051b3605", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9c6ade83", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "12782fa4", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "a6c55409", + "metadata": {}, + "source": [ + "## get location group" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d17fb27f", + "metadata": {}, + "outputs": [], + "source": [ + "group_id = \"test-location-group\"\n", + "category_id = \"test-location-category\"\n", + "office_id = \"test-office\"\n", + "data = locations.get_location_group(group_id, category_id, office_id)\n", + "values = data.df.to_numpy().tolist()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "be36c301", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a90ab4a", + "metadata": {}, + "outputs": [], + "source": [ + "data.df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "29a4b4af", + "metadata": {}, + "outputs": [], + "source": [ + "values" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/outlets/outlets.ipynb b/examples/outlets/outlets.ipynb new file mode 100644 index 00000000..a8575a78 --- /dev/null +++ b/examples/outlets/outlets.ipynb @@ -0,0 +1,202 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "57c3d14f", + "metadata": {}, + "source": [ + "# Outlets Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "5e335a24", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/outlets/outlets_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/outlets/outlets_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0e93e9fa", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import cwms.outlets.outlets as outlets\n", + "from cwms.cwms_types import DeleteMethod" + ] + }, + { + "cell_type": "markdown", + "id": "15b6c6b7", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cb6ff0c4", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "3139b601", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "5bece550", + "metadata": {}, + "source": [ + "## get outlet" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e03fa375", + "metadata": {}, + "outputs": [], + "source": [ + "data = outlets.get_outlet(\"SPK\", \"BIGH-TG1\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aec9854f", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "947910ae", + "metadata": {}, + "source": [ + "## get outlets" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bcd73237", + "metadata": {}, + "outputs": [], + "source": [ + "data = outlets.get_outlets(\"SPK\", \"BIGH\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fe828730", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "5cea143e", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "f901924a", + "metadata": {}, + "source": [ + "## store outlet" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "73a27d6a", + "metadata": {}, + "outputs": [], + "source": [ + "outlets.store_outlet(_OUTLET_JSON, True)\n" + ] + }, + { + "cell_type": "markdown", + "id": "4ac79b31", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "ac509add", + "metadata": {}, + "source": [ + "## delete outlet" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f3909939", + "metadata": {}, + "outputs": [], + "source": [ + "outlets.delete_outlet(\"SPK\", \"Test\", DeleteMethod.DELETE_ALL)\n" + ] + }, + { + "cell_type": "markdown", + "id": "f9520c96", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "21c027ed", + "metadata": {}, + "source": [ + "## rename outlet" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f31d8612", + "metadata": {}, + "outputs": [], + "source": [ + "outlets.rename_outlet(\"SPK\", \"Test\", \"Test2\")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/outlets/virtual_outlets.ipynb b/examples/outlets/virtual_outlets.ipynb new file mode 100644 index 00000000..11038cd7 --- /dev/null +++ b/examples/outlets/virtual_outlets.ipynb @@ -0,0 +1,176 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "4fe12d03", + "metadata": {}, + "source": [ + "# Outlets Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "7821a50f", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/outlets/virtual_outlets_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/outlets/virtual_outlets_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c96eb272", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import cwms.outlets.virtual_outlets as virtual_outlets\n", + "from cwms.cwms_types import DeleteMethod" + ] + }, + { + "cell_type": "markdown", + "id": "1df056e0", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3cb193b2", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "e9e95e28", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "98c38144", + "metadata": {}, + "source": [ + "## get virtual outlet" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "59dd066e", + "metadata": {}, + "outputs": [], + "source": [ + "data = virtual_outlets.get_virtual_outlet(\"SPK\", \"BIGH\", \"Compound Tainter Gates\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e4bbb6df", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "10a9e1fb", + "metadata": {}, + "source": [ + "## get virtual outlets" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "02950da9", + "metadata": {}, + "outputs": [], + "source": [ + "data = virtual_outlets.get_virtual_outlets(\"SPK\", \"BIGH\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "98b81376", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "38878fe5", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "684d9215", + "metadata": {}, + "source": [ + "## store virtual outlet" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b5dc69e5", + "metadata": {}, + "outputs": [], + "source": [ + "virtual_outlets.store_virtual_outlet(_VIRTUAL_OUTLET_JSON, True)\n" + ] + }, + { + "cell_type": "markdown", + "id": "fba1d071", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "29cf200c", + "metadata": {}, + "source": [ + "## delete virtual outlet" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bba65fb7", + "metadata": {}, + "outputs": [], + "source": [ + "virtual_outlets.delete_virtual_outlet(\"SWT\", \"PROJ\", \"Test\", DeleteMethod.DELETE_ALL)\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/projects/project_lock_rights.ipynb b/examples/projects/project_lock_rights.ipynb new file mode 100644 index 00000000..5f0debee --- /dev/null +++ b/examples/projects/project_lock_rights.ipynb @@ -0,0 +1,139 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "f5a2ee9e", + "metadata": {}, + "source": [ + "# Projects Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "f24c0cce", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/projects/project_lock_rights_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/projects/project_lock_rights_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7815f520", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import cwms.projects.project_lock_rights as project_lock_rights" + ] + }, + { + "cell_type": "markdown", + "id": "320be32c", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4a816164", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "2a104f31", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "2d846352", + "metadata": {}, + "source": [ + "## get project lock rights" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a97a8992", + "metadata": {}, + "outputs": [], + "source": [ + "data = project_lock_rights.get_project_lock_rights(\"SPK\", \"B*\", \"G*\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3636d736", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "2d28082c", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "f46abcfb", + "metadata": {}, + "source": [ + "## remove all project lock rights" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "905f9c2b", + "metadata": {}, + "outputs": [], + "source": [ + "project_lock_rights.remove_all_project_lock_rights(\"SPK\", \"GitHub\", \"Actions\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "469fb0ed", + "metadata": {}, + "source": [ + "## update project lock rights" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "335de3ad", + "metadata": {}, + "outputs": [], + "source": [ + "project_lock_rights.update_project_lock_rights(\"SPK\", \"GitHub\", \"Actions\", True, \"P*\")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/projects/project_locks.ipynb b/examples/projects/project_locks.ipynb new file mode 100644 index 00000000..8b63ef46 --- /dev/null +++ b/examples/projects/project_locks.ipynb @@ -0,0 +1,203 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "3a5340c0", + "metadata": {}, + "source": [ + "# Projects Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "9812bbbc", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/projects/project_locks_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/projects/project_locks_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "afa5df7a", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import cwms.projects.project_locks as project_locks" + ] + }, + { + "cell_type": "markdown", + "id": "3509c718", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9b6506b4", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "7cc354c5", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "dde8f184", + "metadata": {}, + "source": [ + "## get project lock" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd283387", + "metadata": {}, + "outputs": [], + "source": [ + "data = project_locks.get_project_lock(\"SPK\", \"BIGH\", \"GitHub\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1555e13b", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "4dbad165", + "metadata": {}, + "source": [ + "## get project locks" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0247e644", + "metadata": {}, + "outputs": [], + "source": [ + "data = project_locks.get_project_locks(\"SPK\", \"P*\", \"G*\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "91aa381e", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "26ff9eaa", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "9a4d3d97", + "metadata": {}, + "source": [ + "## revoke project lock" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "31bef173", + "metadata": {}, + "outputs": [], + "source": [ + "project_locks.revoke_project_lock(\"SPK\", \"TEST\", 20)\n" + ] + }, + { + "cell_type": "markdown", + "id": "53d29415", + "metadata": {}, + "source": [ + "## request project lock" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4a5431fc", + "metadata": {}, + "outputs": [], + "source": [ + "project_locks.request_project_lock(_PROJECT_LOCK_JSON, True, 20)\n" + ] + }, + { + "cell_type": "markdown", + "id": "6b50ea1a", + "metadata": {}, + "source": [ + "## deny project lock request" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "abf7dd19", + "metadata": {}, + "outputs": [], + "source": [ + "project_locks.deny_project_lock_request(\"LOCKID123\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "3786af64", + "metadata": {}, + "source": [ + "## release project lock" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2807a43b", + "metadata": {}, + "outputs": [], + "source": [ + "project_locks.release_project_lock(\"SPK\", \"LOCKID123\")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/projects/projects.ipynb b/examples/projects/projects.ipynb new file mode 100644 index 00000000..74bd0fd7 --- /dev/null +++ b/examples/projects/projects.ipynb @@ -0,0 +1,255 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0c801fd4", + "metadata": {}, + "source": [ + "# Projects Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "120791d9", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/projects/projects_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/projects/projects_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c81af0d5", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pytz\n", + "import cwms.projects.projects as projects\n", + "from cwms.cwms_types import DeleteMethod" + ] + }, + { + "cell_type": "markdown", + "id": "60102549", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3361044f", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "6674d9fc", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "08bea915", + "metadata": {}, + "source": [ + "## get project" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd8a54c8", + "metadata": {}, + "outputs": [], + "source": [ + "data = projects.get_project(\"SPK\", \"BIGH\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8bf8538d", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "a5613088", + "metadata": {}, + "source": [ + "## get projects" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "99034bd9", + "metadata": {}, + "outputs": [], + "source": [ + "data = projects.get_projects(\"SPK\", \"B*\", \"abc\", 50)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "24e7633e", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "2cd5c387", + "metadata": {}, + "source": [ + "## get project locations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f2aad3a1", + "metadata": {}, + "outputs": [], + "source": [ + "data = projects.get_project_locations(\"SPK\", \"p.*\", \"O.*\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d50e2b40", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "10025a89", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "fd2b6e0a", + "metadata": {}, + "source": [ + "## store project" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "52b23851", + "metadata": {}, + "outputs": [], + "source": [ + "projects.store_project(_PROJECT_JSON, True)\n" + ] + }, + { + "cell_type": "markdown", + "id": "47cb14e6", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "ff2222c9", + "metadata": {}, + "source": [ + "## delete project" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1e48d4e5", + "metadata": {}, + "outputs": [], + "source": [ + "projects.delete_project(\"SPK\", \"Test\", DeleteMethod.DELETE_ALL)\n" + ] + }, + { + "cell_type": "markdown", + "id": "16d1f869", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "547182b9", + "metadata": {}, + "source": [ + "## rename project" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fe734b33", + "metadata": {}, + "outputs": [], + "source": [ + "projects.rename_project(\"SPK\", \"Test\", \"Test2\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "ba7386cc", + "metadata": {}, + "source": [ + "## status update" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "78c8e74a", + "metadata": {}, + "outputs": [], + "source": [ + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2024, 2, 12, 0, 0, 0))\n", + "end = timezone.localize(datetime(2020, 2, 12, 2, 0, 0))\n", + "projects.status_update(\n", + " \"SPK\", \"Test\", \"UnitTest\", \"GitHub\", \"ABC.Flow.Ave.1Day.1Day.computed\", begin, end\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/ratings/rating_spec.ipynb b/examples/ratings/rating_spec.ipynb new file mode 100644 index 00000000..9456932c --- /dev/null +++ b/examples/ratings/rating_spec.ipynb @@ -0,0 +1,109 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "75fb2ed5", + "metadata": {}, + "source": [ + "# Ratings Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "65763b7a", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/ratings/rating_spec_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/ratings/rating_spec_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aeba7bdc", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import pandas as pd\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.ratings.ratings_spec as ratings_spec" + ] + }, + { + "cell_type": "markdown", + "id": "12f63fb7", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "42f3d38f", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "bfed21ca", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "4b35fdfd", + "metadata": {}, + "source": [ + "## get rating spec default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "49ba9362", + "metadata": {}, + "outputs": [], + "source": [ + "rating_id = \"TestRating.Stage;Flow.USGS-EXSA-TEST.USGS-NWIS-TEST?office=MVP\"\n", + "office_id = \"MVP\"\n", + "spec = ratings_spec.get_rating_spec(rating_id=rating_id, office_id=office_id)\n" + ] + }, + { + "cell_type": "markdown", + "id": "5f74c528", + "metadata": {}, + "source": [ + "## get rating specs default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5b9b2be8", + "metadata": {}, + "outputs": [], + "source": [ + "office_id = \"MVP\"\n", + "specs = ratings_spec.get_rating_specs(office_id=office_id)\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/ratings/rating_template.ipynb b/examples/ratings/rating_template.ipynb new file mode 100644 index 00000000..c4f218fd --- /dev/null +++ b/examples/ratings/rating_template.ipynb @@ -0,0 +1,111 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "edd92861", + "metadata": {}, + "source": [ + "# Ratings Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "ba561864", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/ratings/rating_template_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/ratings/rating_template_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "004a5e3f", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import pandas as pd\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.ratings.ratings_template as ratings_template" + ] + }, + { + "cell_type": "markdown", + "id": "df061ced", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "63e27180", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "0318711c", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "6ad41a03", + "metadata": {}, + "source": [ + "## get rating template default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "680f1259", + "metadata": {}, + "outputs": [], + "source": [ + "rating_temp = \"Stage;Flow.USGS-EXSA-TEST\"\n", + "office_id = \"MVP\"\n", + "template = ratings_template.get_rating_template(\n", + " template_id=rating_temp, office_id=office_id\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "id": "949dc267", + "metadata": {}, + "source": [ + "## get rating templates default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "acbf92c1", + "metadata": {}, + "outputs": [], + "source": [ + "office_id = \"MVP\"\n", + "templates = ratings_template.get_rating_templates(office_id=office_id)\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/ratings/ratings.ipynb b/examples/ratings/ratings.ipynb new file mode 100644 index 00000000..92e5807c --- /dev/null +++ b/examples/ratings/ratings.ipynb @@ -0,0 +1,191 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "ffa0a924", + "metadata": {}, + "source": [ + "# Ratings Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "b58bc855", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/ratings/ratings_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/ratings/ratings_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e40e11d1", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import pandas as pd\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.ratings.ratings as ratings" + ] + }, + { + "cell_type": "markdown", + "id": "c6f74b09", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f7654316", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "a5e93048", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "6c6951b9", + "metadata": {}, + "source": [ + "## get ratings default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "60f117ff", + "metadata": {}, + "outputs": [], + "source": [ + "office_id = \"MVP\"\n", + "rating_id = \"TestRating.Stage;Flow.USGS-EXSA-TEST.USGS-NWIS-TEST\"\n", + "specs = ratings.get_ratings(rating_id=rating_id, office_id=office_id, method=\"EAGER\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "03951d51", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "62445cf1", + "metadata": {}, + "source": [ + "## ratings df to json default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2ae4ab04", + "metadata": {}, + "outputs": [], + "source": [ + "rating_json = {\n", + " \"rating-template\": {\n", + " \"office-id\": \"MVP\",\n", + " \"parameters-id\": \"Stage;Flow\",\n", + " \"version\": \"USGS-EXSA-TEST\",\n", + " \"ind-parameter-specs\": {\n", + " \"ind-parameter-spec\": {\n", + " \"position\": \"1\",\n", + " \"parameter\": \"Stage\",\n", + " \"in-range-method\": \"LINEAR\",\n", + " \"out-range-low-method\": \"LINEAR\",\n", + " \"out-range-high-method\": \"LINEAR\",\n", + " }\n", + " },\n", + " \"dep-parameter\": \"Flow\",\n", + " \"description\": \"Expanded, Shift-Adjusted Stream Rating\",\n", + " },\n", + " \"rating-spec\": {\n", + " \"office-id\": \"MVP\",\n", + " \"rating-spec-id\": \"TestRating.Stage;Flow.USGS-EXSA-TEST.USGS-NWIS-TEST\",\n", + " \"template-id\": \"Stage;Flow.USGS-EXSA-TEST\",\n", + " \"location-id\": \"TestRating\",\n", + " \"version\": \"USGS-NWIS-TEST\",\n", + " \"source-agency\": \"USGS\",\n", + " \"in-range-method\": \"LINEAR\",\n", + " \"out-range-low-method\": \"NEAREST\",\n", + " \"out-range-high-method\": \"NEAREST\",\n", + " \"active\": \"true\",\n", + " \"auto-update\": \"true\",\n", + " \"auto-activate\": \"true\",\n", + " \"auto-migrate-extension\": \"true\",\n", + " \"ind-rounding-specs\": {\n", + " \"ind-rounding-spec\": {\"position\": \"1\", \"element-value\": \"2223456782\"}\n", + " },\n", + " \"dep-rounding-spec\": \"2222233332\",\n", + " \"description\": \"TESTing rating spec\",\n", + " },\n", + " \"simple-rating\": {\n", + " \"office-id\": \"MVP\",\n", + " \"rating-spec-id\": \"TestRating.Stage;Flow.USGS-EXSA-TEST.USGS-NWIS-TEST\",\n", + " \"units-id\": \"ft;cfs\",\n", + " \"effective-date\": \"2024-07-03T09:03:01.540655\",\n", + " \"transition-start-date\": None,\n", + " \"active\": True,\n", + " \"description\": \"Testing Rating Curves. Test Rating\",\n", + " \"rating-points\": {\n", + " \"point\": [\n", + " {\"ind\": 1, \"dep\": 100},\n", + " {\"ind\": 2, \"dep\": 200},\n", + " {\"ind\": 3, \"dep\": 300},\n", + " {\"ind\": 4, \"dep\": 400},\n", + " {\"ind\": 5, \"dep\": 500},\n", + " {\"ind\": 6, \"dep\": 600},\n", + " {\"ind\": 7, \"dep\": 700},\n", + " {\"ind\": 8, \"dep\": 800},\n", + " {\"ind\": 9, \"dep\": 900},\n", + " {\"ind\": 10, \"dep\": 1000},\n", + " ]\n", + " },\n", + " },\n", + "}\n", + "rating_table_df = pd.DataFrame(\n", + " {\n", + " \"ind\": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],\n", + " \"dep\": [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],\n", + " }\n", + ")\n", + "rating_table_json = ratings.rating_simple_df_to_json(\n", + " data=rating_table_df,\n", + " rating_id=\"TestRating.Stage;Flow.USGS-EXSA-TEST.USGS-NWIS-TEST\",\n", + " office_id=\"MVP\",\n", + " units=\"ft;cfs\",\n", + " effective_date=pd.to_datetime(\"2024-07-03T09:03:01.540655\"),\n", + " transition_start_date=None,\n", + " description=\"Testing Rating Curves. Test Rating\",\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/standard_text/standard_text.ipynb b/examples/standard_text/standard_text.ipynb new file mode 100644 index 00000000..f901ce1b --- /dev/null +++ b/examples/standard_text/standard_text.ipynb @@ -0,0 +1,268 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "04af78b8", + "metadata": {}, + "source": [ + "# Standard Text Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "f3d36445", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/standard_text/standard_text_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/standard_text/standard_text_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f9970126", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.standard_text.standard_text as standard_text\n", + "from cwms.cwms_types import DeleteMethod" + ] + }, + { + "cell_type": "markdown", + "id": "93e0002e", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ff293a55", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "9324249c", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "6219702b", + "metadata": {}, + "source": [ + "## get standard text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7c0ec3bf", + "metadata": {}, + "outputs": [], + "source": [ + "text_id = \"HW\"\n", + "office_id = \"SPK\"\n", + "data = standard_text.get_standard_text(text_id, office_id)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bbf14958", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "d2395040", + "metadata": {}, + "source": [ + "## get standard text catalog default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e9a2a366", + "metadata": {}, + "outputs": [], + "source": [ + "data = standard_text.get_standard_text_catalog()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4f4feab7", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "64f2950b", + "metadata": {}, + "source": [ + "## get standard text catalog" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3de83d2d", + "metadata": {}, + "outputs": [], + "source": [ + "text_id = \"HW\"\n", + "office_id = \"SPK\"\n", + "data = standard_text.get_standard_text_catalog(text_id, office_id)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d42b947a", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "f32f1d52", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "b2cf567c", + "metadata": {}, + "source": [ + "## create standard text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c4d555cb", + "metadata": {}, + "outputs": [], + "source": [ + "# Input Data:\n", + "data = {\"id\": {\"office-id\": \"SPK\", \"id\": \"HW\"}, \"standard-text\": \"Hello, World\"}\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "00202afe", + "metadata": {}, + "outputs": [], + "source": [ + "standard_text.store_standard_text(data, fail_if_exists=True)\n" + ] + }, + { + "cell_type": "markdown", + "id": "e8fcb811", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "ede430d4", + "metadata": {}, + "source": [ + "## delete standard text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4ccc5755", + "metadata": {}, + "outputs": [], + "source": [ + "text_id = \"HW\"\n", + "office_id = \"SPK\"\n", + "standard_text.delete_standard_text(text_id, DeleteMethod.DELETE_ALL, office_id)\n" + ] + }, + { + "cell_type": "markdown", + "id": "b7cb0ead", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "8653788a", + "metadata": {}, + "source": [ + "## create standard text json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "81c0b697", + "metadata": {}, + "outputs": [], + "source": [ + "# Input Data:\n", + "data = {\"id\": {\"office-id\": \"SPK\", \"id\": \"HW\"}, \"standard-text\": \"Hello, World\"}\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f43b74fb", + "metadata": {}, + "outputs": [], + "source": [ + "text_id = \"HW\"\n", + "office_id = \"SPK\"\n", + "sd_text = \"Hello, World\"\n", + "st_json = standard_text.standard_text_to_json(\n", + " text_id=text_id, standard_text=sd_text, office_id=office_id\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/timeseries/timeseries.ipynb b/examples/timeseries/timeseries.ipynb new file mode 100644 index 00000000..e2e129bc --- /dev/null +++ b/examples/timeseries/timeseries.ipynb @@ -0,0 +1,582 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "badbe30d", + "metadata": {}, + "source": [ + "# Timeseries Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "2f4ce257", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/timeseries/timeseries_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/timeseries/timeseries_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "21395597", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pandas as pd\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.timeseries.timeseries as timeseries" + ] + }, + { + "cell_type": "markdown", + "id": "20802b09", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "31a5b22f", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "840cb4e9", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "f920c3ef", + "metadata": {}, + "source": [ + "## get timeseries unversioned default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6c8212a4", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"TEST.Text.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"UTC\")\n", + "begin = timezone.localize(datetime(2008, 5, 1, 15, 0, 0))\n", + "end = timezone.localize(datetime(2008, 5, 1, 17, 0, 0))\n", + "data = timeseries.get_timeseries(\n", + " ts_id=timeseries_id, office_id=office_id, begin=begin, end=end\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fd46bb39", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b71e0e94", + "metadata": {}, + "outputs": [], + "source": [ + "data.df" + ] + }, + { + "cell_type": "markdown", + "id": "c3ebeb7a", + "metadata": {}, + "source": [ + "## get empty ts df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "db6d7576", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"KEYS.Elev.Inst.1Hour.0.Ccp-Rev\"\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"UTC\")\n", + "begin = timezone.localize(datetime(2024, 5, 1, 15, 0, 0))\n", + "end = timezone.localize(datetime(2024, 5, 1, 17, 0, 0))\n", + "data = timeseries.get_timeseries(\n", + " ts_id=timeseries_id, office_id=office_id, begin=begin, end=end\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a2335849", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8639f5f3", + "metadata": {}, + "outputs": [], + "source": [ + "data.df" + ] + }, + { + "cell_type": "markdown", + "id": "f48d5005", + "metadata": {}, + "source": [ + "## get timeseries paging" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9f40aa84", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"Test.Stage.Inst.15Minutes.0.TEST_PAGING\"\n", + "office_id = \"NWDM\"\n", + "timezone = pytz.timezone(\"UTC\")\n", + "begin = timezone.localize(datetime(2024, 10, 3, 11, 0, 0))\n", + "end = timezone.localize(datetime(2024, 10, 4, 11, 0, 0))\n", + "data = timeseries.get_timeseries(\n", + " ts_id=timeseries_id, office_id=office_id, begin=begin, end=end, page_size=10\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a30c8401", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "209c5bda", + "metadata": {}, + "outputs": [], + "source": [ + "data.df" + ] + }, + { + "cell_type": "markdown", + "id": "a8810f90", + "metadata": {}, + "source": [ + "## get timeseries group default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "05bfc851", + "metadata": {}, + "outputs": [], + "source": [ + "group_id = \"USGS TS Data Acquisition\"\n", + "category_id = \"Data Acquisition\"\n", + "office_id = \"CWMS\"\n", + "data = timeseries.get_timeseries_group(\n", + " group_id=group_id, category_id=category_id, office_id=office_id\n", + ")\n", + "values = data.df.to_numpy().tolist()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e5548dbf", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f3892fed", + "metadata": {}, + "outputs": [], + "source": [ + "data.df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ecc7c647", + "metadata": {}, + "outputs": [], + "source": [ + "values" + ] + }, + { + "cell_type": "markdown", + "id": "b6e9255e", + "metadata": {}, + "source": [ + "## get multi timeseries default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "350c4f70", + "metadata": {}, + "outputs": [], + "source": [ + "ts_ids = [\n", + " \"TEST.Text.Inst.1Hour.0.MockTest\",\n", + " \"TEST.Text.Inst.1Hour.0.MockTest:2021-06-20 08:00:00-00:00\",\n", + "]\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"UTC\")\n", + "begin = timezone.localize(datetime(2008, 5, 1, 15, 0, 0))\n", + "end = timezone.localize(datetime(2008, 5, 1, 17, 0, 0))\n", + "data = cwms.get_multi_timeseries_df(\n", + " ts_ids=ts_ids, office_id=office_id, begin=begin, end=end, melted=False\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bf259b3e", + "metadata": {}, + "outputs": [], + "source": [ + "data.df" + ] + }, + { + "cell_type": "markdown", + "id": "1f51480a", + "metadata": {}, + "source": [ + "## get timeseries versioned default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "96764faa", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"TEST.Text.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"UTC\")\n", + "begin = timezone.localize(datetime(2008, 5, 1, 15, 0, 0))\n", + "end = timezone.localize(datetime(2008, 5, 1, 17, 0, 0))\n", + "version_date = timezone.localize(datetime(2021, 6, 20, 8, 0, 0))\n", + "data = timeseries.get_timeseries(\n", + " ts_id=timeseries_id,\n", + " office_id=office_id,\n", + " begin=begin,\n", + " end=end,\n", + " version_date=version_date,\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c9f78564", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "92cfc513", + "metadata": {}, + "outputs": [], + "source": [ + "data.df" + ] + }, + { + "cell_type": "markdown", + "id": "204f5a05", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "48f34449", + "metadata": {}, + "source": [ + "## create timeseries unversioned default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b6a026c9", + "metadata": {}, + "outputs": [], + "source": [ + "# Input Data:\n", + "data = {\n", + " \"office-id\": \"SWT\",\n", + " \"name\": \"TEST.Flow.Inst.1Hour.0.MockTest\",\n", + " \"date-version-type\": \"UNVERSIONED\",\n", + " \"units\": \"CFS\",\n", + " \"value-columns\": [\n", + " {\"name\": \"date-time\", \"ordinal\": 1, \"datatype\": \"java.sql.Timestamp\"},\n", + " {\"name\": \"value\", \"ordinal\": 2, \"datatype\": \"java.lang.Double\"},\n", + " {\"name\": \"quality-code\", \"ordinal\": 3, \"datatype\": \"int\"},\n", + " ],\n", + " \"values\": [\n", + " [1209654000000, 1, 0],\n", + " [1209657600000, 2, 0],\n", + " [1209661200000, 3, 0],\n", + " [1209664800000, 4, 0],\n", + " ],\n", + "}\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "efc26106", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries.store_timeseries(data=data)\n" + ] + }, + { + "cell_type": "markdown", + "id": "fdccba70", + "metadata": {}, + "source": [ + "## create timeseries versioned default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b442cad1", + "metadata": {}, + "outputs": [], + "source": [ + "# Input Data:\n", + "data = {\n", + " \"date-version-type\": \"SINGLE_VERSION\",\n", + " \"office-id\": \"SWT\",\n", + " \"name\": \"TEST.Flow.Inst.1Hour.0.MockTest\",\n", + " \"units\": \"CFS\",\n", + " \"version-date\": \"2021-06-20T08:00:00-0000[UTC]\",\n", + " \"value-columns\": [\n", + " {\"name\": \"date-time\", \"ordinal\": 1, \"datatype\": \"java.sql.Timestamp\"},\n", + " {\"name\": \"value\", \"ordinal\": 2, \"datatype\": \"java.lang.Double\"},\n", + " {\"name\": \"quality-code\", \"ordinal\": 3, \"datatype\": \"int\"},\n", + " ],\n", + " \"values\": [\n", + " [1209654000000, 4, 0],\n", + " [1209657600000, 4, 0],\n", + " [1209661200000, 4, 0],\n", + " [1209664800000, 3, 0],\n", + " ],\n", + "}\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7ff5cd68", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries.store_timeseries(data=data)\n" + ] + }, + { + "cell_type": "markdown", + "id": "bd5e402e", + "metadata": {}, + "source": [ + "# Other API Calls" + ] + }, + { + "cell_type": "markdown", + "id": "b8a0bcc9", + "metadata": {}, + "source": [ + "## update timeseries groups" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3018209a", + "metadata": {}, + "outputs": [], + "source": [ + "group_id = \"USGS TS Data Acquisition\"\n", + "office_id = \"CWMS\"\n", + "replace_assigned_ts = True\n", + "data = _TS_GROUP\n", + "timeseries.update_timeseries_groups(\n", + " data=data,\n", + " group_id=group_id,\n", + " office_id=office_id,\n", + " replace_assigned_ts=replace_assigned_ts,\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "id": "fe745c51", + "metadata": {}, + "source": [ + "## timeseries group df to json valid data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fbe7f5a0", + "metadata": {}, + "outputs": [], + "source": [ + "data = pd.DataFrame(\n", + " {\n", + " \"office-id\": [\"office123\", \"office456\"],\n", + " \"timeseries-id\": [\"ts1\", \"ts2\"],\n", + " \"alias-id\": [None, \"alias2\"],\n", + " \"attribute\": [0, 10],\n", + " \"ts-code\": [\"code1\", None],\n", + " }\n", + ")\n", + "required_columns = [\"office-id\", \"timeseries-id\"]\n", + "data = data.dropna(subset=required_columns)\n", + "optional_columns = [\"alias-id\", \"ts-code\"]\n", + "for col in optional_columns:\n", + " if col in data.columns:\n", + " data[col] = data[col].where(pd.notnull(data[col]), None)\n", + "expected_json = {\n", + " \"office-id\": \"office123\",\n", + " \"id\": \"group123\",\n", + " \"time-series-category\": {\"office-id\": \"office123\", \"id\": \"cat123\"},\n", + " \"assigned-time-series\": [\n", + " {\n", + " \"office-id\": \"office123\",\n", + " \"timeseries-id\": \"ts1\",\n", + " \"alias-id\": None,\n", + " \"attribute\": 0,\n", + " \"ts-code\": \"code1\",\n", + " },\n", + " {\n", + " \"office-id\": \"office456\",\n", + " \"timeseries-id\": \"ts2\",\n", + " \"alias-id\": \"alias2\",\n", + " \"attribute\": 10,\n", + " },\n", + " ],\n", + "}\n", + "result = timeseries.timeseries_group_df_to_json(data, \"group123\", \"office123\", \"cat123\")\n" + ] + }, + { + "cell_type": "markdown", + "id": "d5172705", + "metadata": {}, + "source": [ + "## timeseries df to json" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "accb3d4a", + "metadata": {}, + "outputs": [], + "source": [ + "test_json = {\n", + " \"name\": \"TestLoc.Stage.Inst.1Hour.0.Testing\",\n", + " \"office-id\": \"MVP\",\n", + " \"units\": \"ft\",\n", + " \"values\": [\n", + " [\"2024-08-18T04:00:00+00:00\", 1, 0],\n", + " [\"2024-08-18T05:00:00+00:00\", 1, 0],\n", + " [\"2024-08-18T06:00:00+00:00\", 1, 0],\n", + " [\"2024-08-18T07:00:00+00:00\", 1, 0],\n", + " [\"2024-08-18T08:00:00+00:00\", 1, 0],\n", + " ],\n", + " \"version-date\": None,\n", + "}\n", + "data = pd.DataFrame(\n", + " {\n", + " \"date-time\": pd.date_range(\n", + " start=\"2024-08-18\", end=\"2024-08-18 04:00\", freq=\"1h\"\n", + " ),\n", + " \"value\": 1,\n", + " }\n", + ")\n", + "data[\"date-time\"] = data[\"date-time\"].dt.tz_localize(\"US/Eastern\")\n", + "office_id = \"MVP\"\n", + "ts_id = \"TestLoc.Stage.Inst.1Hour.0.Testing\"\n", + "data2 = data.copy()\n", + "ts_json = cwms.timeseries_df_to_json(\n", + " data=data, ts_id=ts_id, office_id=office_id, units=\"ft\"\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/timeseries/timeseries_bin.ipynb b/examples/timeseries/timeseries_bin.ipynb new file mode 100644 index 00000000..21344e9a --- /dev/null +++ b/examples/timeseries/timeseries_bin.ipynb @@ -0,0 +1,225 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "02085323", + "metadata": {}, + "source": [ + "# Timeseries Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "d86e72bc", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/timeseries/timeseries_bin_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/timeseries/timeseries_bin_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e2c8b8f0", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.timeseries.timeseries_bin as timeseries" + ] + }, + { + "cell_type": "markdown", + "id": "e435d278", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2860e97e", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "202d761f", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "2985fa19", + "metadata": {}, + "source": [ + "## get binary timeseries default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "282a5264", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"TEST.Binary.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SPK\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2024, 2, 12, 0, 0, 0))\n", + "end = timezone.localize(datetime(2020, 2, 12, 2, 0, 0))\n", + "data = timeseries.get_binary_timeseries(timeseries_id, office_id, begin, end)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "72e561b5", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "cf80ef90", + "metadata": {}, + "source": [ + "## get binary timeseries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a2122af2", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"TEST.Binary.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SPK\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2024, 2, 12, 0, 0, 0))\n", + "end = timezone.localize(datetime(2020, 2, 12, 2, 0, 0))\n", + "data = timeseries.get_binary_timeseries(\n", + " timeseries_id, office_id, begin, end, bin_type_mask=\"text/plain\"\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0cf286b3", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "9473100b", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "c94dea38", + "metadata": {}, + "source": [ + "## create binary timeseries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c86d53e7", + "metadata": {}, + "outputs": [], + "source": [ + "# Input Data:\n", + "data = {\n", + " \"office-id\": \"SPK\",\n", + " \"name\": \"TEST.Binary.Inst.1Hour.0.MockTest\",\n", + " \"interval-offset\": 0,\n", + " \"time-zone\": \"America/Los_Angeles\",\n", + " \"binary-values\": [\n", + " {\n", + " \"date-time\": \"2024-02-12T00:00:00Z\",\n", + " \"version-date\": \"2024-02-12T00:00:00Z\",\n", + " \"data-entry-date\": \"2024-02-12T00:00:00Z\",\n", + " \"attribute\": 0,\n", + " \"media-type\": \"text/plain\",\n", + " \"file-extension\": \"txt\",\n", + " \"binary-value\": [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100],\n", + " }\n", + " ],\n", + "}\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8513678", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries.store_binary_timeseries(data, True)\n" + ] + }, + { + "cell_type": "markdown", + "id": "5220fac3", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "43c79f20", + "metadata": {}, + "source": [ + "## delete binary timeseries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a6ad153d", + "metadata": {}, + "outputs": [], + "source": [ + "level_id = \"TEST.Binary.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SPK\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2024, 2, 12, 0, 0, 0))\n", + "end = timezone.localize(datetime(2020, 2, 12, 2, 0, 0))\n", + "timeseries.delete_binary_timeseries(\n", + " level_id, office_id, begin, end, bin_type_mask=\"text/plain\"\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/timeseries/timeseries_profile.ipynb b/examples/timeseries/timeseries_profile.ipynb new file mode 100644 index 00000000..62d5544e --- /dev/null +++ b/examples/timeseries/timeseries_profile.ipynb @@ -0,0 +1,183 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "e378e086", + "metadata": {}, + "source": [ + "# Timeseries Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "b82e9a5e", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/timeseries/timeseries_profile_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/timeseries/timeseries_profile_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e1f65159", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import cwms.api\n", + "import cwms.timeseries.timeseries_profile as timeseries" + ] + }, + { + "cell_type": "markdown", + "id": "7df2bc45", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f2382340", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "4a1a7502", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "22b577cb", + "metadata": {}, + "source": [ + "## get timeseries profile" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d5f19043", + "metadata": {}, + "outputs": [], + "source": [ + "parameter_id = \"Depth\"\n", + "office_id = \"SWT\"\n", + "location_id = \"SWAN\"\n", + "data = timeseries.get_timeseries_profile(office_id, location_id, parameter_id)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3584773e", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "b6f197cc", + "metadata": {}, + "source": [ + "## get all timeseries profile" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ce80b1ea", + "metadata": {}, + "outputs": [], + "source": [ + "data = timeseries.get_timeseries_profiles(\"*\", \"*\", \"*\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40f8ac9f", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "57eebbaa", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "de992f47", + "metadata": {}, + "source": [ + "## store timeseries profile" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "33f2b9f1", + "metadata": {}, + "outputs": [], + "source": [ + "data = _TSP_JSON\n", + "timeseries.store_timeseries_profile(data, False)\n" + ] + }, + { + "cell_type": "markdown", + "id": "1f449cac", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "d8102255", + "metadata": {}, + "source": [ + "## delete timeseries profile" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "77cb1cd3", + "metadata": {}, + "outputs": [], + "source": [ + "location_id = \"SWAN\"\n", + "parameter_id = \"Depth\"\n", + "office_id = \"SWT\"\n", + "timeseries.delete_timeseries_profile(office_id, parameter_id, location_id)\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/timeseries/timeseries_profile_instance.ipynb b/examples/timeseries/timeseries_profile_instance.ipynb new file mode 100644 index 00000000..3b125130 --- /dev/null +++ b/examples/timeseries/timeseries_profile_instance.ipynb @@ -0,0 +1,203 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "1cfbb04b", + "metadata": {}, + "source": [ + "# Timeseries Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "a74454c1", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/timeseries/timeseries_profile_instance_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/timeseries/timeseries_profile_instance_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "91b46d70", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import urllib.parse\n", + "from datetime import datetime\n", + "from pathlib import Path\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.timeseries.timeseries_profile_instance as timeseries" + ] + }, + { + "cell_type": "markdown", + "id": "205eea78", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e952f202", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "e9551b6c", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "b87939bd", + "metadata": {}, + "source": [ + "## get timeseries profile instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "96d57597", + "metadata": {}, + "outputs": [], + "source": [ + "location_id = \"SWAN\"\n", + "parameter_id = \"Temp-Water\"\n", + "version = \"Raw\"\n", + "unit = \"C\"\n", + "office_id = \"SWT\"\n", + "version_date = tz.localize(datetime(2014, 8, 16, 4, 55, 0))\n", + "start = tz.localize(datetime(2015, 3, 3, 6, 45, 0))\n", + "end = tz.localize(datetime(2015, 3, 3, 7, 15, 0))\n", + "data = timeseries.get_timeseries_profile_instance(\n", + " office_id, location_id, parameter_id, version, unit, version_date, start, end\n", + ")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a9b0d1e", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "a4d942d0", + "metadata": {}, + "source": [ + "## get all timeseries profile instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7723ffe8", + "metadata": {}, + "outputs": [], + "source": [ + "data = timeseries.get_timeseries_profile_instances(\"*\", \"*\", \"*\", \"*\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8453ddd", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "3309ca3d", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "ae7c1cf5", + "metadata": {}, + "source": [ + "## store timeseries profile instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "99a951cf", + "metadata": {}, + "outputs": [], + "source": [ + "data = urllib.parse.quote_plus(_TSP_PROFILE_DATA)\n", + "version = \"Raw\"\n", + "version_date = tz.localize(datetime(2020, 1, 1, 13, 30, 0))\n", + "timeseries.store_timeseries_profile_instance(\n", + " _TSP_PROFILE_DATA, version, version_date, None, False\n", + ")\n" + ] + }, + { + "cell_type": "markdown", + "id": "b287e34e", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "74a4f3c4", + "metadata": {}, + "source": [ + "## delete timeseries profile instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "90edcae6", + "metadata": {}, + "outputs": [], + "source": [ + "location_id = \"SWAN\"\n", + "office_id = \"SWT\"\n", + "parameter_id = \"Length\"\n", + "version = \"Raw\"\n", + "version_date = tz.localize(datetime(2010, 6, 4, 12, 0, 0))\n", + "date = tz.localize(datetime(2010, 6, 4, 14, 0, 0))\n", + "timeseries.delete_timeseries_profile_instance(\n", + " office_id, location_id, parameter_id, version, version_date, date\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/timeseries/timeseries_profile_parser.ipynb b/examples/timeseries/timeseries_profile_parser.ipynb new file mode 100644 index 00000000..8808d51a --- /dev/null +++ b/examples/timeseries/timeseries_profile_parser.ipynb @@ -0,0 +1,183 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "dd3eb6db", + "metadata": {}, + "source": [ + "# Timeseries Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "e17ac508", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/timeseries/timeseries_profile_parser_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/timeseries/timeseries_profile_parser_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2cdc3c06", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "import cwms.api\n", + "import cwms.timeseries.timeseries_profile_parser as timeseries" + ] + }, + { + "cell_type": "markdown", + "id": "2ae32ecc", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b4d83088", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "fffb3a6d", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "277ce901", + "metadata": {}, + "source": [ + "## get timeseries profile parser" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bcbdb990", + "metadata": {}, + "outputs": [], + "source": [ + "location_id = \"SWAN\"\n", + "office_id = \"SWT\"\n", + "parameter_id = \"Temp\"\n", + "data = timeseries.get_timeseries_profile_parser(office_id, location_id, parameter_id)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3fb71d42", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "034b08ca", + "metadata": {}, + "source": [ + "## get all timeseries profile parser" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8d71ad78", + "metadata": {}, + "outputs": [], + "source": [ + "data = timeseries.get_timeseries_profile_parsers(\"*\", \"*\", \"*\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "37fde80f", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "04ba00fd", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "789c3c25", + "metadata": {}, + "source": [ + "## store timeseries profile parser" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d3c278f2", + "metadata": {}, + "outputs": [], + "source": [ + "data = _TSP_PARSER_JSON\n", + "timeseries.store_timeseries_profile_parser(data, False)\n" + ] + }, + { + "cell_type": "markdown", + "id": "f15cbf57", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "b6e06f14", + "metadata": {}, + "source": [ + "## delete timeseries profile parser" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1ee1a978", + "metadata": {}, + "outputs": [], + "source": [ + "parameter_id = \"Length\"\n", + "location_id = \"SWAN\"\n", + "office_id = \"SWT\"\n", + "timeseries.delete_timeseries_profile_parser(office_id, location_id, parameter_id)\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/examples/timeseries/timeseries_txt.ipynb b/examples/timeseries/timeseries_txt.ipynb new file mode 100644 index 00000000..30effab9 --- /dev/null +++ b/examples/timeseries/timeseries_txt.ipynb @@ -0,0 +1,241 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "fb03eb2c", + "metadata": {}, + "source": [ + "# Timeseries Examples\n" + ] + }, + { + "cell_type": "markdown", + "id": "11337246", + "metadata": {}, + "source": [ + "**Example generated from:** [/tests/timeseries/timeseries_txt_test.py](https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main/tests/timeseries/timeseries_txt_test.py)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0a9dd96d", + "metadata": {}, + "outputs": [], + "source": [ + "from cwms.api import init_session\n", + "from datetime import datetime\n", + "import pytz\n", + "import cwms.api\n", + "import cwms.timeseries.timeseries_txt as timeseries" + ] + }, + { + "cell_type": "markdown", + "id": "ea195059", + "metadata": {}, + "source": [ + "### Initializing the database and write access\n", + "cwms-python will connect by default to the USACE public database available through [CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n", + "\n", + "https://cwms-data.usace.army.mil/cwms-data/\n", + "\n", + "The apiRoot can be updated to access data directly from a USACE district database.\n", + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) with a 🔒 icon require the apiKey be set." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "45e2c953", + "metadata": {}, + "outputs": [], + "source": [ + "api_root = \"https://cwms-data-test.cwbi.us/cwms-data/\"\n", + "api = init_session(api_root=api_root)" + ] + }, + { + "cell_type": "markdown", + "id": "bd40df6a", + "metadata": {}, + "source": [ + "# GET Requests" + ] + }, + { + "cell_type": "markdown", + "id": "28a50176", + "metadata": {}, + "source": [ + "## get text timeseries default" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fa9febfd", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"TEST.Text.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2024, 2, 12, 0, 0, 0))\n", + "end = timezone.localize(datetime(2020, 2, 12, 2, 0, 0))\n", + "data = timeseries.get_text_timeseries(timeseries_id, office_id, begin, end)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2895c69c", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "5e06813a", + "metadata": {}, + "source": [ + "## get text timeseries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e7117111", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries_id = \"TEST.Text.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2024, 2, 12, 0, 0, 0))\n", + "end = timezone.localize(datetime(2020, 2, 12, 2, 0, 0))\n", + "data = timeseries.get_text_timeseries(timeseries_id, office_id, begin, end)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "92018cf4", + "metadata": {}, + "outputs": [], + "source": [ + "data.json" + ] + }, + { + "cell_type": "markdown", + "id": "3d5104b8", + "metadata": {}, + "source": [ + "# STORE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "2a1e84df", + "metadata": {}, + "source": [ + "## create text timeseries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "05b99d8e", + "metadata": {}, + "outputs": [], + "source": [ + "# Input Data:\n", + "data = {\n", + " \"office-id\": \"SWT\",\n", + " \"name\": \"TEST.Text.Inst.1Hour.0.MockTest\",\n", + " \"regular-text-values\": [\n", + " {\n", + " \"date-time\": \"2024-02-12T00:00:00Z\",\n", + " \"version-date\": \"2024-02-12T00:00:00Z\",\n", + " \"data-entry-date\": \"2024-02-12T00:00:00Z\",\n", + " \"attribute\": 0,\n", + " \"text-id\": \"id1\",\n", + " \"text-value\": \"Hello, Davis\",\n", + " },\n", + " {\n", + " \"date-time\": \"2024-02-12T01:00:00Z\",\n", + " \"version-date\": \"2024-02-12T00:00:00Z\",\n", + " \"data-entry-date\": \"2024-02-12T00:00:00Z\",\n", + " \"text-id\": \"id2\",\n", + " \"text-value\": \"Hello, USA\",\n", + " },\n", + " ],\n", + " \"standard-text-values\": [\n", + " {\n", + " \"date-time\": \"2024-02-12T02:00:00Z\",\n", + " \"version-date\": \"2024-02-12T00:00:00Z\",\n", + " \"data-entry-date\": \"2024-02-12T00:00:00Z\",\n", + " \"attribute\": 0,\n", + " \"office-id\": \"CWMS\",\n", + " \"standard-text-id\": \"HW\",\n", + " \"text-value\": \"Hello, World\",\n", + " }\n", + " ],\n", + " \"standard-text-catalog\": [\n", + " {\"office-id\": \"CWMS\", \"entries\": [{\"id\": \"HW\", \"value\": \"Hello, World\"}]}\n", + " ],\n", + "}\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7469658", + "metadata": {}, + "outputs": [], + "source": [ + "timeseries.store_text_timeseries(data, True)\n" + ] + }, + { + "cell_type": "markdown", + "id": "8f45ece5", + "metadata": {}, + "source": [ + "# DELETE Requests" + ] + }, + { + "cell_type": "markdown", + "id": "d0c78d2b", + "metadata": {}, + "source": [ + "## delete text timeseries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "25f07f98", + "metadata": {}, + "outputs": [], + "source": [ + "level_id = \"TEST.Text.Inst.1Hour.0.MockTest\"\n", + "office_id = \"SWT\"\n", + "timezone = pytz.timezone(\"US/Pacific\")\n", + "begin = timezone.localize(datetime(2024, 2, 12, 0, 0, 0))\n", + "end = timezone.localize(datetime(2020, 2, 12, 2, 0, 0))\n", + "timeseries.delete_text_timeseries(\n", + " level_id, office_id, begin, end, text_mask=\"Hello, World\"\n", + ")\n" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/poetry.lock b/poetry.lock index a1fd39d4..153f6ce1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,25 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.0.1 and should not be changed by hand. + +[[package]] +name = "attrs" +version = "25.1.0" +description = "Classes Without Boilerplate" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "attrs-25.1.0-py3-none-any.whl", hash = "sha256:c75a69e28a550a7e93789579c22aa26b0f5b83b75dc4e08fe092980051e1090a"}, + {file = "attrs-25.1.0.tar.gz", hash = "sha256:1c97078a80c814273a76b2a298a932eb681c87415c11dee0a6921de7f1b02c3e"}, +] + +[package.extras] +benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit-uv", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier (<24.7)"] +tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-xdist[psutil]"] +tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] [[package]] name = "black" @@ -6,6 +27,8 @@ version = "24.10.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "black-24.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812"}, {file = "black-24.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea"}, @@ -52,6 +75,8 @@ version = "2024.8.30" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" +groups = ["main", "dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "certifi-2024.8.30-py3-none-any.whl", hash = "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8"}, {file = "certifi-2024.8.30.tar.gz", hash = "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9"}, @@ -63,6 +88,8 @@ version = "3.4.0" description = "Validate configuration and produce human readable error messages." optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "cfgv-3.4.0-py2.py3-none-any.whl", hash = "sha256:b7265b1f29fd3316bfcd2b330d63d024f2bfd8bcb8b0272f8e19a504856c48f9"}, {file = "cfgv-3.4.0.tar.gz", hash = "sha256:e52591d4c5f5dead8e0f673fb16db7949d2cfb3f7da4582893288f0ded8fe560"}, @@ -74,6 +101,8 @@ version = "3.4.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." optional = false python-versions = ">=3.7.0" +groups = ["main", "dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:4f9fc98dad6c2eaa32fc3af1417d95b5e3d08aff968df0cd320066def971f9a6"}, {file = "charset_normalizer-3.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0de7b687289d3c1b3e8660d0741874abe7888100efe14bd0f9fd7141bcbda92b"}, @@ -188,6 +217,8 @@ version = "8.1.7" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, @@ -202,6 +233,8 @@ version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["dev"] +markers = "python_version <= \"3.11\" and platform_system == \"Windows\" or python_version <= \"3.11\" and sys_platform == \"win32\" or python_version >= \"3.12\" and platform_system == \"Windows\" or python_version >= \"3.12\" and sys_platform == \"win32\"" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, @@ -213,6 +246,8 @@ version = "7.6.3" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "coverage-7.6.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6da42bbcec130b188169107ecb6ee7bd7b4c849d24c9370a0c884cf728d8e976"}, {file = "coverage-7.6.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c222958f59b0ae091f4535851cbb24eb57fc0baea07ba675af718fb5302dddb2"}, @@ -290,6 +325,8 @@ version = "0.3.9" description = "Distribution utilities" optional = false python-versions = "*" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "distlib-0.3.9-py2.py3-none-any.whl", hash = "sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87"}, {file = "distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403"}, @@ -301,6 +338,8 @@ version = "1.9.0" description = "Distro - an OS platform information API" optional = false python-versions = ">=3.6" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2"}, {file = "distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed"}, @@ -312,6 +351,8 @@ version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, @@ -320,12 +361,30 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "fastjsonschema" +version = "2.21.1" +description = "Fastest Python implementation of JSON schema" +optional = false +python-versions = "*" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "fastjsonschema-2.21.1-py3-none-any.whl", hash = "sha256:c9e5b7e908310918cf494a434eeb31384dd84a98b57a30bcb1f535015b554667"}, + {file = "fastjsonschema-2.21.1.tar.gz", hash = "sha256:794d4f0a58f848961ba16af7b9c85a3e88cd360df008c59aac6fc5ae9323b5d4"}, +] + +[package.extras] +devel = ["colorama", "json-spec", "jsonschema", "pylint", "pytest", "pytest-benchmark", "pytest-cache", "validictory"] + [[package]] name = "filelock" version = "3.16.1" description = "A platform independent file lock." optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0"}, {file = "filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435"}, @@ -342,6 +401,8 @@ version = "2.6.1" description = "File identification library for Python" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "identify-2.6.1-py2.py3-none-any.whl", hash = "sha256:53863bcac7caf8d2ed85bd20312ea5dcfc22226800f6d6881f232d861db5a8f0"}, {file = "identify-2.6.1.tar.gz", hash = "sha256:91478c5fb7c3aac5ff7bf9b4344f803843dc586832d5f110d672b19aa1984c98"}, @@ -356,6 +417,8 @@ version = "3.10" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.6" +groups = ["main", "dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"}, {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"}, @@ -370,6 +433,8 @@ version = "2.0.0" description = "brain-dead simple config-ini parsing" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, @@ -381,6 +446,8 @@ version = "5.13.2" description = "A Python utility / library to sort Python imports." optional = false python-versions = ">=3.8.0" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, @@ -389,12 +456,75 @@ files = [ [package.extras] colors = ["colorama (>=0.4.6)"] +[[package]] +name = "jsonschema" +version = "4.23.0" +description = "An implementation of JSON Schema validation for Python" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "jsonschema-4.23.0-py3-none-any.whl", hash = "sha256:fbadb6f8b144a8f8cf9f0b89ba94501d143e50411a1278633f56a7acf7fd5566"}, + {file = "jsonschema-4.23.0.tar.gz", hash = "sha256:d71497fef26351a33265337fa77ffeb82423f3ea21283cd9467bb03999266bc4"}, +] + +[package.dependencies] +attrs = ">=22.2.0" +jsonschema-specifications = ">=2023.03.6" +referencing = ">=0.28.4" +rpds-py = ">=0.7.1" + +[package.extras] +format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] +format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3986-validator (>0.1.0)", "uri-template", "webcolors (>=24.6.0)"] + +[[package]] +name = "jsonschema-specifications" +version = "2024.10.1" +description = "The JSON Schema meta-schemas and vocabularies, exposed as a Registry" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "jsonschema_specifications-2024.10.1-py3-none-any.whl", hash = "sha256:a09a0680616357d9a0ecf05c12ad234479f549239d0f5b55f3deea67475da9bf"}, + {file = "jsonschema_specifications-2024.10.1.tar.gz", hash = "sha256:0f38b83639958ce1152d02a7f062902c41c8fd20d558b0c34344292d417ae272"}, +] + +[package.dependencies] +referencing = ">=0.31.0" + +[[package]] +name = "jupyter-core" +version = "5.7.2" +description = "Jupyter core package. A base package on which Jupyter projects rely." +optional = false +python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "jupyter_core-5.7.2-py3-none-any.whl", hash = "sha256:4f7315d2f6b4bcf2e3e7cb6e46772eba760ae459cd1f59d29eb57b0a01bd7409"}, + {file = "jupyter_core-5.7.2.tar.gz", hash = "sha256:aa5f8d32bbf6b431ac830496da7392035d6f61b4f54872f15c4bd2a9c3f536d9"}, +] + +[package.dependencies] +platformdirs = ">=2.5" +pywin32 = {version = ">=300", markers = "sys_platform == \"win32\" and platform_python_implementation != \"PyPy\""} +traitlets = ">=5.3" + +[package.extras] +docs = ["myst-parser", "pydata-sphinx-theme", "sphinx-autodoc-typehints", "sphinxcontrib-github-alt", "sphinxcontrib-spelling", "traitlets"] +test = ["ipykernel", "pre-commit", "pytest (<8)", "pytest-cov", "pytest-timeout"] + [[package]] name = "maison" version = "1.4.2" description = "Read settings from config files" optional = false python-versions = ">=3.7.1,<4.0.0" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "maison-1.4.2-py3-none-any.whl", hash = "sha256:b63fe6751494935fc453dfb76319af223e4cb8bab32ac5464c2a9ca0edda8765"}, {file = "maison-1.4.2.tar.gz", hash = "sha256:d2abac30a5c6a0749526d70ae95a63c6acf43461a1c10e51410b36734e053ec7"}, @@ -411,6 +541,8 @@ version = "1.12.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "mypy-1.12.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:4397081e620dc4dc18e2f124d5e1d2c288194c2c08df6bdb1db31c38cd1fe1ed"}, {file = "mypy-1.12.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:684a9c508a283f324804fea3f0effeb7858eb03f85c4402a967d187f64562469"}, @@ -463,17 +595,44 @@ version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." optional = false python-versions = ">=3.5" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, ] +[[package]] +name = "nbformat" +version = "5.10.4" +description = "The Jupyter Notebook format" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "nbformat-5.10.4-py3-none-any.whl", hash = "sha256:3b48d6c8fbca4b299bf3982ea7db1af21580e4fec269ad087b9e81588891200b"}, + {file = "nbformat-5.10.4.tar.gz", hash = "sha256:322168b14f937a5d11362988ecac2a4952d3d8e3a2cbeb2319584631226d5b3a"}, +] + +[package.dependencies] +fastjsonschema = ">=2.15" +jsonschema = ">=2.6" +jupyter-core = ">=4.12,<5.0.dev0 || >=5.1.dev0" +traitlets = ">=5.1" + +[package.extras] +docs = ["myst-parser", "pydata-sphinx-theme", "sphinx", "sphinxcontrib-github-alt", "sphinxcontrib-spelling"] +test = ["pep440", "pre-commit", "pytest", "testpath"] + [[package]] name = "nodeenv" version = "1.9.1" description = "Node.js virtual environment builder" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"}, {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"}, @@ -485,6 +644,8 @@ version = "2.0.2" description = "Fundamental package for array computing in Python" optional = false python-versions = ">=3.9" +groups = ["main", "dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "numpy-2.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:51129a29dbe56f9ca83438b706e2e69a39892b5eda6cedcb6b0c9fdc9b0d3ece"}, {file = "numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04"}, @@ -533,74 +694,14 @@ files = [ {file = "numpy-2.0.2.tar.gz", hash = "sha256:883c987dee1880e2a864ab0dc9892292582510604156762362d9326444636e78"}, ] -[[package]] -name = "numpy" -version = "2.1.2" -description = "Fundamental package for array computing in Python" -optional = false -python-versions = ">=3.10" -files = [ - {file = "numpy-2.1.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:30d53720b726ec36a7f88dc873f0eec8447fbc93d93a8f079dfac2629598d6ee"}, - {file = "numpy-2.1.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e8d3ca0a72dd8846eb6f7dfe8f19088060fcb76931ed592d29128e0219652884"}, - {file = "numpy-2.1.2-cp310-cp310-macosx_14_0_arm64.whl", hash = "sha256:fc44e3c68ff00fd991b59092a54350e6e4911152682b4782f68070985aa9e648"}, - {file = "numpy-2.1.2-cp310-cp310-macosx_14_0_x86_64.whl", hash = "sha256:7c1c60328bd964b53f8b835df69ae8198659e2b9302ff9ebb7de4e5a5994db3d"}, - {file = "numpy-2.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6cdb606a7478f9ad91c6283e238544451e3a95f30fb5467fbf715964341a8a86"}, - {file = "numpy-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d666cb72687559689e9906197e3bec7b736764df6a2e58ee265e360663e9baf7"}, - {file = "numpy-2.1.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c6eef7a2dbd0abfb0d9eaf78b73017dbfd0b54051102ff4e6a7b2980d5ac1a03"}, - {file = "numpy-2.1.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:12edb90831ff481f7ef5f6bc6431a9d74dc0e5ff401559a71e5e4611d4f2d466"}, - {file = "numpy-2.1.2-cp310-cp310-win32.whl", hash = "sha256:a65acfdb9c6ebb8368490dbafe83c03c7e277b37e6857f0caeadbbc56e12f4fb"}, - {file = "numpy-2.1.2-cp310-cp310-win_amd64.whl", hash = "sha256:860ec6e63e2c5c2ee5e9121808145c7bf86c96cca9ad396c0bd3e0f2798ccbe2"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b42a1a511c81cc78cbc4539675713bbcf9d9c3913386243ceff0e9429ca892fe"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:faa88bc527d0f097abdc2c663cddf37c05a1c2f113716601555249805cf573f1"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_14_0_arm64.whl", hash = "sha256:c82af4b2ddd2ee72d1fc0c6695048d457e00b3582ccde72d8a1c991b808bb20f"}, - {file = "numpy-2.1.2-cp311-cp311-macosx_14_0_x86_64.whl", hash = "sha256:13602b3174432a35b16c4cfb5de9a12d229727c3dd47a6ce35111f2ebdf66ff4"}, - {file = "numpy-2.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1ebec5fd716c5a5b3d8dfcc439be82a8407b7b24b230d0ad28a81b61c2f4659a"}, - {file = "numpy-2.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2b49c3c0804e8ecb05d59af8386ec2f74877f7ca8fd9c1e00be2672e4d399b1"}, - {file = "numpy-2.1.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2cbba4b30bf31ddbe97f1c7205ef976909a93a66bb1583e983adbd155ba72ac2"}, - {file = "numpy-2.1.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:8e00ea6fc82e8a804433d3e9cedaa1051a1422cb6e443011590c14d2dea59146"}, - {file = "numpy-2.1.2-cp311-cp311-win32.whl", hash = "sha256:5006b13a06e0b38d561fab5ccc37581f23c9511879be7693bd33c7cd15ca227c"}, - {file = "numpy-2.1.2-cp311-cp311-win_amd64.whl", hash = "sha256:f1eb068ead09f4994dec71c24b2844f1e4e4e013b9629f812f292f04bd1510d9"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d7bf0a4f9f15b32b5ba53147369e94296f5fffb783db5aacc1be15b4bf72f43b"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b1d0fcae4f0949f215d4632be684a539859b295e2d0cb14f78ec231915d644db"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:f751ed0a2f250541e19dfca9f1eafa31a392c71c832b6bb9e113b10d050cb0f1"}, - {file = "numpy-2.1.2-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:bd33f82e95ba7ad632bc57837ee99dba3d7e006536200c4e9124089e1bf42426"}, - {file = "numpy-2.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b8cde4f11f0a975d1fd59373b32e2f5a562ade7cde4f85b7137f3de8fbb29a0"}, - {file = "numpy-2.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d95f286b8244b3649b477ac066c6906fbb2905f8ac19b170e2175d3d799f4df"}, - {file = "numpy-2.1.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:ab4754d432e3ac42d33a269c8567413bdb541689b02d93788af4131018cbf366"}, - {file = "numpy-2.1.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e585c8ae871fd38ac50598f4763d73ec5497b0de9a0ab4ef5b69f01c6a046142"}, - {file = "numpy-2.1.2-cp312-cp312-win32.whl", hash = "sha256:9c6c754df29ce6a89ed23afb25550d1c2d5fdb9901d9c67a16e0b16eaf7e2550"}, - {file = "numpy-2.1.2-cp312-cp312-win_amd64.whl", hash = "sha256:456e3b11cb79ac9946c822a56346ec80275eaf2950314b249b512896c0d2505e"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a84498e0d0a1174f2b3ed769b67b656aa5460c92c9554039e11f20a05650f00d"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:4d6ec0d4222e8ffdab1744da2560f07856421b367928026fb540e1945f2eeeaf"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:259ec80d54999cc34cd1eb8ded513cb053c3bf4829152a2e00de2371bd406f5e"}, - {file = "numpy-2.1.2-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:675c741d4739af2dc20cd6c6a5c4b7355c728167845e3c6b0e824e4e5d36a6c3"}, - {file = "numpy-2.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:05b2d4e667895cc55e3ff2b56077e4c8a5604361fc21a042845ea3ad67465aa8"}, - {file = "numpy-2.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43cca367bf94a14aca50b89e9bc2061683116cfe864e56740e083392f533ce7a"}, - {file = "numpy-2.1.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:76322dcdb16fccf2ac56f99048af32259dcc488d9b7e25b51e5eca5147a3fb98"}, - {file = "numpy-2.1.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:32e16a03138cabe0cb28e1007ee82264296ac0983714094380b408097a418cfe"}, - {file = "numpy-2.1.2-cp313-cp313-win32.whl", hash = "sha256:242b39d00e4944431a3cd2db2f5377e15b5785920421993770cddb89992c3f3a"}, - {file = "numpy-2.1.2-cp313-cp313-win_amd64.whl", hash = "sha256:f2ded8d9b6f68cc26f8425eda5d3877b47343e68ca23d0d0846f4d312ecaa445"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:2ffef621c14ebb0188a8633348504a35c13680d6da93ab5cb86f4e54b7e922b5"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:ad369ed238b1959dfbade9018a740fb9392c5ac4f9b5173f420bd4f37ba1f7a0"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:d82075752f40c0ddf57e6e02673a17f6cb0f8eb3f587f63ca1eaab5594da5b17"}, - {file = "numpy-2.1.2-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:1600068c262af1ca9580a527d43dc9d959b0b1d8e56f8a05d830eea39b7c8af6"}, - {file = "numpy-2.1.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a26ae94658d3ba3781d5e103ac07a876b3e9b29db53f68ed7df432fd033358a8"}, - {file = "numpy-2.1.2-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13311c2db4c5f7609b462bc0f43d3c465424d25c626d95040f073e30f7570e35"}, - {file = "numpy-2.1.2-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:2abbf905a0b568706391ec6fa15161fad0fb5d8b68d73c461b3c1bab6064dd62"}, - {file = "numpy-2.1.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:ef444c57d664d35cac4e18c298c47d7b504c66b17c2ea91312e979fcfbdfb08a"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:bdd407c40483463898b84490770199d5714dcc9dd9b792f6c6caccc523c00952"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-macosx_14_0_x86_64.whl", hash = "sha256:da65fb46d4cbb75cb417cddf6ba5e7582eb7bb0b47db4b99c9fe5787ce5d91f5"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c193d0b0238638e6fc5f10f1b074a6993cb13b0b431f64079a509d63d3aa8b7"}, - {file = "numpy-2.1.2-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a7d80b2e904faa63068ead63107189164ca443b42dd1930299e0d1cb041cec2e"}, - {file = "numpy-2.1.2.tar.gz", hash = "sha256:13532a088217fa624c99b843eeb54640de23b3414b14aa66d023805eb731066c"}, -] - [[package]] name = "packaging" version = "24.1" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, @@ -612,6 +713,8 @@ version = "2.2.3" description = "Powerful data structures for data analysis, time series, and statistics" optional = false python-versions = ">=3.9" +groups = ["main"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pandas-2.2.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1948ddde24197a0f7add2bdc4ca83bf2b1ef84a1bc8ccffd95eda17fd836ecb5"}, {file = "pandas-2.2.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:381175499d3802cde0eabbaf6324cce0c4f5d52ca6f8c377c29ad442f50f6348"}, @@ -698,6 +801,8 @@ version = "2.2.2.240807" description = "Type annotations for pandas" optional = false python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pandas_stubs-2.2.2.240807-py3-none-any.whl", hash = "sha256:893919ad82be4275f0d07bb47a95d08bae580d3fdea308a7acfcb3f02e76186e"}, {file = "pandas_stubs-2.2.2.240807.tar.gz", hash = "sha256:64a559725a57a449f46225fbafc422520b7410bff9252b661a225b5559192a93"}, @@ -713,6 +818,8 @@ version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, @@ -724,6 +831,8 @@ version = "4.3.6" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, @@ -740,6 +849,8 @@ version = "1.5.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, @@ -755,6 +866,8 @@ version = "3.8.0" description = "A framework for managing and maintaining multi-language pre-commit hooks." optional = false python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pre_commit-3.8.0-py2.py3-none-any.whl", hash = "sha256:9a90a53bf82fdd8778d58085faf8d83df56e40dfe18f45b19446e26bf1b3a63f"}, {file = "pre_commit-3.8.0.tar.gz", hash = "sha256:8bb6494d4a20423842e198980c9ecf9f96607a07ea29549e180eef9ae80fe7af"}, @@ -773,6 +886,8 @@ version = "1.10.18" description = "Data validation and settings management using python type hints" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pydantic-1.10.18-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e405ffcc1254d76bb0e760db101ee8916b620893e6edfbfee563b3c6f7a67c02"}, {file = "pydantic-1.10.18-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e306e280ebebc65040034bff1a0a81fd86b2f4f05daac0131f29541cafd80b80"}, @@ -832,6 +947,8 @@ version = "8.3.3" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"}, {file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"}, @@ -854,6 +971,8 @@ version = "4.1.0" description = "Pytest plugin for measuring coverage." optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, @@ -872,6 +991,8 @@ version = "2.9.0.post0" description = "Extensions to the standard Python datetime module" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +groups = ["main"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, @@ -886,17 +1007,50 @@ version = "2024.2" description = "World timezone definitions, modern and historical" optional = false python-versions = "*" +groups = ["main"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "pytz-2024.2-py2.py3-none-any.whl", hash = "sha256:31c7c1817eb7fae7ca4b8c7ee50c72f93aa2dd863de768e1ef4245d426aa0725"}, {file = "pytz-2024.2.tar.gz", hash = "sha256:2aa355083c50a0f93fa581709deac0c9ad65cca8a9e9beac660adcbd493c798a"}, ] +[[package]] +name = "pywin32" +version = "308" +description = "Python for Window Extensions" +optional = false +python-versions = "*" +groups = ["dev"] +markers = "python_version <= \"3.11\" and sys_platform == \"win32\" and platform_python_implementation != \"PyPy\" or python_version >= \"3.12\" and sys_platform == \"win32\" and platform_python_implementation != \"PyPy\"" +files = [ + {file = "pywin32-308-cp310-cp310-win32.whl", hash = "sha256:796ff4426437896550d2981b9c2ac0ffd75238ad9ea2d3bfa67a1abd546d262e"}, + {file = "pywin32-308-cp310-cp310-win_amd64.whl", hash = "sha256:4fc888c59b3c0bef905ce7eb7e2106a07712015ea1c8234b703a088d46110e8e"}, + {file = "pywin32-308-cp310-cp310-win_arm64.whl", hash = "sha256:a5ab5381813b40f264fa3495b98af850098f814a25a63589a8e9eb12560f450c"}, + {file = "pywin32-308-cp311-cp311-win32.whl", hash = "sha256:5d8c8015b24a7d6855b1550d8e660d8daa09983c80e5daf89a273e5c6fb5095a"}, + {file = "pywin32-308-cp311-cp311-win_amd64.whl", hash = "sha256:575621b90f0dc2695fec346b2d6302faebd4f0f45c05ea29404cefe35d89442b"}, + {file = "pywin32-308-cp311-cp311-win_arm64.whl", hash = "sha256:100a5442b7332070983c4cd03f2e906a5648a5104b8a7f50175f7906efd16bb6"}, + {file = "pywin32-308-cp312-cp312-win32.whl", hash = "sha256:587f3e19696f4bf96fde9d8a57cec74a57021ad5f204c9e627e15c33ff568897"}, + {file = "pywin32-308-cp312-cp312-win_amd64.whl", hash = "sha256:00b3e11ef09ede56c6a43c71f2d31857cf7c54b0ab6e78ac659497abd2834f47"}, + {file = "pywin32-308-cp312-cp312-win_arm64.whl", hash = "sha256:9b4de86c8d909aed15b7011182c8cab38c8850de36e6afb1f0db22b8959e3091"}, + {file = "pywin32-308-cp313-cp313-win32.whl", hash = "sha256:1c44539a37a5b7b21d02ab34e6a4d314e0788f1690d65b48e9b0b89f31abbbed"}, + {file = "pywin32-308-cp313-cp313-win_amd64.whl", hash = "sha256:fd380990e792eaf6827fcb7e187b2b4b1cede0585e3d0c9e84201ec27b9905e4"}, + {file = "pywin32-308-cp313-cp313-win_arm64.whl", hash = "sha256:ef313c46d4c18dfb82a2431e3051ac8f112ccee1a34f29c263c583c568db63cd"}, + {file = "pywin32-308-cp37-cp37m-win32.whl", hash = "sha256:1f696ab352a2ddd63bd07430080dd598e6369152ea13a25ebcdd2f503a38f1ff"}, + {file = "pywin32-308-cp37-cp37m-win_amd64.whl", hash = "sha256:13dcb914ed4347019fbec6697a01a0aec61019c1046c2b905410d197856326a6"}, + {file = "pywin32-308-cp38-cp38-win32.whl", hash = "sha256:5794e764ebcabf4ff08c555b31bd348c9025929371763b2183172ff4708152f0"}, + {file = "pywin32-308-cp38-cp38-win_amd64.whl", hash = "sha256:3b92622e29d651c6b783e368ba7d6722b1634b8e70bd376fd7610fe1992e19de"}, + {file = "pywin32-308-cp39-cp39-win32.whl", hash = "sha256:7873ca4dc60ab3287919881a7d4f88baee4a6e639aa6962de25a98ba6b193341"}, + {file = "pywin32-308-cp39-cp39-win_amd64.whl", hash = "sha256:71b3322d949b4cc20776436a9c9ba0eeedcbc9c650daa536df63f0ff111bb920"}, +] + [[package]] name = "pyyaml" version = "6.0.2" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"}, {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"}, @@ -953,12 +1107,32 @@ files = [ {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"}, ] +[[package]] +name = "referencing" +version = "0.36.2" +description = "JSON Referencing + Python" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "referencing-0.36.2-py3-none-any.whl", hash = "sha256:e8699adbbf8b5c7de96d8ffa0eb5c158b3beafce084968e2ea8bb08c6794dcd0"}, + {file = "referencing-0.36.2.tar.gz", hash = "sha256:df2e89862cd09deabbdba16944cc3f10feb6b3e6f18e902f7cc25609a34775aa"}, +] + +[package.dependencies] +attrs = ">=22.2.0" +rpds-py = ">=0.7.0" +typing-extensions = {version = ">=4.4.0", markers = "python_version < \"3.13\""} + [[package]] name = "requests" version = "2.32.3" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" +groups = ["main", "dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, @@ -980,6 +1154,8 @@ version = "1.12.1" description = "Mock out responses from the requests package" optional = false python-versions = ">=3.5" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "requests-mock-1.12.1.tar.gz", hash = "sha256:e9e12e333b525156e82a3c852f22016b9158220d2f47454de9cae8a77d371401"}, {file = "requests_mock-1.12.1-py2.py3-none-any.whl", hash = "sha256:b1e37054004cdd5e56c84454cc7df12b25f90f382159087f4b6915aaeef39563"}, @@ -997,6 +1173,8 @@ version = "1.0.0" description = "A utility belt for advanced users of python-requests" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +groups = ["main"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "requests-toolbelt-1.0.0.tar.gz", hash = "sha256:7681a0a3d047012b5bdc0ee37d7f8f07ebe76ab08caeccfc3921ce23c88d5bc6"}, {file = "requests_toolbelt-1.0.0-py2.py3-none-any.whl", hash = "sha256:cccfdd665f0a24fcf4726e690f65639d272bb0637b9b92dfd91a5568ccf6bd06"}, @@ -1005,12 +1183,128 @@ files = [ [package.dependencies] requests = ">=2.0.1,<3.0.0" +[[package]] +name = "rpds-py" +version = "0.22.3" +description = "Python bindings to Rust's persistent data structures (rpds)" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "rpds_py-0.22.3-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:6c7b99ca52c2c1752b544e310101b98a659b720b21db00e65edca34483259967"}, + {file = "rpds_py-0.22.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:be2eb3f2495ba669d2a985f9b426c1797b7d48d6963899276d22f23e33d47e37"}, + {file = "rpds_py-0.22.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:70eb60b3ae9245ddea20f8a4190bd79c705a22f8028aaf8bbdebe4716c3fab24"}, + {file = "rpds_py-0.22.3-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4041711832360a9b75cfb11b25a6a97c8fb49c07b8bd43d0d02b45d0b499a4ff"}, + {file = "rpds_py-0.22.3-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:64607d4cbf1b7e3c3c8a14948b99345eda0e161b852e122c6bb71aab6d1d798c"}, + {file = "rpds_py-0.22.3-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e69b0a0e2537f26d73b4e43ad7bc8c8efb39621639b4434b76a3de50c6966e"}, + {file = "rpds_py-0.22.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc27863442d388870c1809a87507727b799c8460573cfbb6dc0eeaef5a11b5ec"}, + {file = "rpds_py-0.22.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e79dd39f1e8c3504be0607e5fc6e86bb60fe3584bec8b782578c3b0fde8d932c"}, + {file = "rpds_py-0.22.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:e0fa2d4ec53dc51cf7d3bb22e0aa0143966119f42a0c3e4998293a3dd2856b09"}, + {file = "rpds_py-0.22.3-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:fda7cb070f442bf80b642cd56483b5548e43d366fe3f39b98e67cce780cded00"}, + {file = "rpds_py-0.22.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:cff63a0272fcd259dcc3be1657b07c929c466b067ceb1c20060e8d10af56f5bf"}, + {file = "rpds_py-0.22.3-cp310-cp310-win32.whl", hash = "sha256:9bd7228827ec7bb817089e2eb301d907c0d9827a9e558f22f762bb690b131652"}, + {file = "rpds_py-0.22.3-cp310-cp310-win_amd64.whl", hash = "sha256:9beeb01d8c190d7581a4d59522cd3d4b6887040dcfc744af99aa59fef3e041a8"}, + {file = "rpds_py-0.22.3-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d20cfb4e099748ea39e6f7b16c91ab057989712d31761d3300d43134e26e165f"}, + {file = "rpds_py-0.22.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:68049202f67380ff9aa52f12e92b1c30115f32e6895cd7198fa2a7961621fc5a"}, + {file = "rpds_py-0.22.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb4f868f712b2dd4bcc538b0a0c1f63a2b1d584c925e69a224d759e7070a12d5"}, + {file = "rpds_py-0.22.3-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bc51abd01f08117283c5ebf64844a35144a0843ff7b2983e0648e4d3d9f10dbb"}, + {file = "rpds_py-0.22.3-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0f3cec041684de9a4684b1572fe28c7267410e02450f4561700ca5a3bc6695a2"}, + {file = "rpds_py-0.22.3-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7ef9d9da710be50ff6809fed8f1963fecdfecc8b86656cadfca3bc24289414b0"}, + {file = "rpds_py-0.22.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59f4a79c19232a5774aee369a0c296712ad0e77f24e62cad53160312b1c1eaa1"}, + {file = "rpds_py-0.22.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1a60bce91f81ddaac922a40bbb571a12c1070cb20ebd6d49c48e0b101d87300d"}, + {file = "rpds_py-0.22.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:e89391e6d60251560f0a8f4bd32137b077a80d9b7dbe6d5cab1cd80d2746f648"}, + {file = "rpds_py-0.22.3-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:e3fb866d9932a3d7d0c82da76d816996d1667c44891bd861a0f97ba27e84fc74"}, + {file = "rpds_py-0.22.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:1352ae4f7c717ae8cba93421a63373e582d19d55d2ee2cbb184344c82d2ae55a"}, + {file = "rpds_py-0.22.3-cp311-cp311-win32.whl", hash = "sha256:b0b4136a252cadfa1adb705bb81524eee47d9f6aab4f2ee4fa1e9d3cd4581f64"}, + {file = "rpds_py-0.22.3-cp311-cp311-win_amd64.whl", hash = "sha256:8bd7c8cfc0b8247c8799080fbff54e0b9619e17cdfeb0478ba7295d43f635d7c"}, + {file = "rpds_py-0.22.3-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:27e98004595899949bd7a7b34e91fa7c44d7a97c40fcaf1d874168bb652ec67e"}, + {file = "rpds_py-0.22.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1978d0021e943aae58b9b0b196fb4895a25cc53d3956b8e35e0b7682eefb6d56"}, + {file = "rpds_py-0.22.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:655ca44a831ecb238d124e0402d98f6212ac527a0ba6c55ca26f616604e60a45"}, + {file = "rpds_py-0.22.3-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:feea821ee2a9273771bae61194004ee2fc33f8ec7db08117ef9147d4bbcbca8e"}, + {file = "rpds_py-0.22.3-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:22bebe05a9ffc70ebfa127efbc429bc26ec9e9b4ee4d15a740033efda515cf3d"}, + {file = "rpds_py-0.22.3-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3af6e48651c4e0d2d166dc1b033b7042ea3f871504b6805ba5f4fe31581d8d38"}, + {file = "rpds_py-0.22.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e67ba3c290821343c192f7eae1d8fd5999ca2dc99994114643e2f2d3e6138b15"}, + {file = "rpds_py-0.22.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:02fbb9c288ae08bcb34fb41d516d5eeb0455ac35b5512d03181d755d80810059"}, + {file = "rpds_py-0.22.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:f56a6b404f74ab372da986d240e2e002769a7d7102cc73eb238a4f72eec5284e"}, + {file = "rpds_py-0.22.3-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:0a0461200769ab3b9ab7e513f6013b7a97fdeee41c29b9db343f3c5a8e2b9e61"}, + {file = "rpds_py-0.22.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:8633e471c6207a039eff6aa116e35f69f3156b3989ea3e2d755f7bc41754a4a7"}, + {file = "rpds_py-0.22.3-cp312-cp312-win32.whl", hash = "sha256:593eba61ba0c3baae5bc9be2f5232430453fb4432048de28399ca7376de9c627"}, + {file = "rpds_py-0.22.3-cp312-cp312-win_amd64.whl", hash = "sha256:d115bffdd417c6d806ea9069237a4ae02f513b778e3789a359bc5856e0404cc4"}, + {file = "rpds_py-0.22.3-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:ea7433ce7e4bfc3a85654aeb6747babe3f66eaf9a1d0c1e7a4435bbdf27fea84"}, + {file = "rpds_py-0.22.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:6dd9412824c4ce1aca56c47b0991e65bebb7ac3f4edccfd3f156150c96a7bf25"}, + {file = "rpds_py-0.22.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:20070c65396f7373f5df4005862fa162db5d25d56150bddd0b3e8214e8ef45b4"}, + {file = "rpds_py-0.22.3-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0b09865a9abc0ddff4e50b5ef65467cd94176bf1e0004184eb915cbc10fc05c5"}, + {file = "rpds_py-0.22.3-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3453e8d41fe5f17d1f8e9c383a7473cd46a63661628ec58e07777c2fff7196dc"}, + {file = "rpds_py-0.22.3-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f5d36399a1b96e1a5fdc91e0522544580dbebeb1f77f27b2b0ab25559e103b8b"}, + {file = "rpds_py-0.22.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:009de23c9c9ee54bf11303a966edf4d9087cd43a6003672e6aa7def643d06518"}, + {file = "rpds_py-0.22.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1aef18820ef3e4587ebe8b3bc9ba6e55892a6d7b93bac6d29d9f631a3b4befbd"}, + {file = "rpds_py-0.22.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f60bd8423be1d9d833f230fdbccf8f57af322d96bcad6599e5a771b151398eb2"}, + {file = "rpds_py-0.22.3-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:62d9cfcf4948683a18a9aff0ab7e1474d407b7bab2ca03116109f8464698ab16"}, + {file = "rpds_py-0.22.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:9253fc214112405f0afa7db88739294295f0e08466987f1d70e29930262b4c8f"}, + {file = "rpds_py-0.22.3-cp313-cp313-win32.whl", hash = "sha256:fb0ba113b4983beac1a2eb16faffd76cb41e176bf58c4afe3e14b9c681f702de"}, + {file = "rpds_py-0.22.3-cp313-cp313-win_amd64.whl", hash = "sha256:c58e2339def52ef6b71b8f36d13c3688ea23fa093353f3a4fee2556e62086ec9"}, + {file = "rpds_py-0.22.3-cp313-cp313t-macosx_10_12_x86_64.whl", hash = "sha256:f82a116a1d03628a8ace4859556fb39fd1424c933341a08ea3ed6de1edb0283b"}, + {file = "rpds_py-0.22.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:3dfcbc95bd7992b16f3f7ba05af8a64ca694331bd24f9157b49dadeeb287493b"}, + {file = "rpds_py-0.22.3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:59259dc58e57b10e7e18ce02c311804c10c5a793e6568f8af4dead03264584d1"}, + {file = "rpds_py-0.22.3-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5725dd9cc02068996d4438d397e255dcb1df776b7ceea3b9cb972bdb11260a83"}, + {file = "rpds_py-0.22.3-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:99b37292234e61325e7a5bb9689e55e48c3f5f603af88b1642666277a81f1fbd"}, + {file = "rpds_py-0.22.3-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:27b1d3b3915a99208fee9ab092b8184c420f2905b7d7feb4aeb5e4a9c509b8a1"}, + {file = "rpds_py-0.22.3-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f612463ac081803f243ff13cccc648578e2279295048f2a8d5eb430af2bae6e3"}, + {file = "rpds_py-0.22.3-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f73d3fef726b3243a811121de45193c0ca75f6407fe66f3f4e183c983573e130"}, + {file = "rpds_py-0.22.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:3f21f0495edea7fdbaaa87e633a8689cd285f8f4af5c869f27bc8074638ad69c"}, + {file = "rpds_py-0.22.3-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:1e9663daaf7a63ceccbbb8e3808fe90415b0757e2abddbfc2e06c857bf8c5e2b"}, + {file = "rpds_py-0.22.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:a76e42402542b1fae59798fab64432b2d015ab9d0c8c47ba7addddbaf7952333"}, + {file = "rpds_py-0.22.3-cp313-cp313t-win32.whl", hash = "sha256:69803198097467ee7282750acb507fba35ca22cc3b85f16cf45fb01cb9097730"}, + {file = "rpds_py-0.22.3-cp313-cp313t-win_amd64.whl", hash = "sha256:f5cf2a0c2bdadf3791b5c205d55a37a54025c6e18a71c71f82bb536cf9a454bf"}, + {file = "rpds_py-0.22.3-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:378753b4a4de2a7b34063d6f95ae81bfa7b15f2c1a04a9518e8644e81807ebea"}, + {file = "rpds_py-0.22.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3445e07bf2e8ecfeef6ef67ac83de670358abf2996916039b16a218e3d95e97e"}, + {file = "rpds_py-0.22.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7b2513ba235829860b13faa931f3b6846548021846ac808455301c23a101689d"}, + {file = "rpds_py-0.22.3-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eaf16ae9ae519a0e237a0f528fd9f0197b9bb70f40263ee57ae53c2b8d48aeb3"}, + {file = "rpds_py-0.22.3-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:583f6a1993ca3369e0f80ba99d796d8e6b1a3a2a442dd4e1a79e652116413091"}, + {file = "rpds_py-0.22.3-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4617e1915a539a0d9a9567795023de41a87106522ff83fbfaf1f6baf8e85437e"}, + {file = "rpds_py-0.22.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c150c7a61ed4a4f4955a96626574e9baf1adf772c2fb61ef6a5027e52803543"}, + {file = "rpds_py-0.22.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2fa4331c200c2521512595253f5bb70858b90f750d39b8cbfd67465f8d1b596d"}, + {file = "rpds_py-0.22.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:214b7a953d73b5e87f0ebece4a32a5bd83c60a3ecc9d4ec8f1dca968a2d91e99"}, + {file = "rpds_py-0.22.3-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:f47ad3d5f3258bd7058d2d506852217865afefe6153a36eb4b6928758041d831"}, + {file = "rpds_py-0.22.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:f276b245347e6e36526cbd4a266a417796fc531ddf391e43574cf6466c492520"}, + {file = "rpds_py-0.22.3-cp39-cp39-win32.whl", hash = "sha256:bbb232860e3d03d544bc03ac57855cd82ddf19c7a07651a7c0fdb95e9efea8b9"}, + {file = "rpds_py-0.22.3-cp39-cp39-win_amd64.whl", hash = "sha256:cfbc454a2880389dbb9b5b398e50d439e2e58669160f27b60e5eca11f68ae17c"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:d48424e39c2611ee1b84ad0f44fb3b2b53d473e65de061e3f460fc0be5f1939d"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:24e8abb5878e250f2eb0d7859a8e561846f98910326d06c0d51381fed59357bd"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4b232061ca880db21fa14defe219840ad9b74b6158adb52ddf0e87bead9e8493"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ac0a03221cdb5058ce0167ecc92a8c89e8d0decdc9e99a2ec23380793c4dcb96"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eb0c341fa71df5a4595f9501df4ac5abfb5a09580081dffbd1ddd4654e6e9123"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:bf9db5488121b596dbfc6718c76092fda77b703c1f7533a226a5a9f65248f8ad"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b8db6b5b2d4491ad5b6bdc2bc7c017eec108acbf4e6785f42a9eb0ba234f4c9"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b3d504047aba448d70cf6fa22e06cb09f7cbd761939fdd47604f5e007675c24e"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:e61b02c3f7a1e0b75e20c3978f7135fd13cb6cf551bf4a6d29b999a88830a338"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-musllinux_1_2_i686.whl", hash = "sha256:e35ba67d65d49080e8e5a1dd40101fccdd9798adb9b050ff670b7d74fa41c566"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:26fd7cac7dd51011a245f29a2cc6489c4608b5a8ce8d75661bb4a1066c52dfbe"}, + {file = "rpds_py-0.22.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:177c7c0fce2855833819c98e43c262007f42ce86651ffbb84f37883308cb0e7d"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:bb47271f60660803ad11f4c61b42242b8c1312a31c98c578f79ef9387bbde21c"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:70fb28128acbfd264eda9bf47015537ba3fe86e40d046eb2963d75024be4d055"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44d61b4b7d0c2c9ac019c314e52d7cbda0ae31078aabd0f22e583af3e0d79723"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f0e260eaf54380380ac3808aa4ebe2d8ca28b9087cf411649f96bad6900c728"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b25bc607423935079e05619d7de556c91fb6adeae9d5f80868dde3468657994b"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fb6116dfb8d1925cbdb52595560584db42a7f664617a1f7d7f6e32f138cdf37d"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a63cbdd98acef6570c62b92a1e43266f9e8b21e699c363c0fef13bd530799c11"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2b8f60e1b739a74bab7e01fcbe3dddd4657ec685caa04681df9d562ef15b625f"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:2e8b55d8517a2fda8d95cb45d62a5a8bbf9dd0ad39c5b25c8833efea07b880ca"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-musllinux_1_2_i686.whl", hash = "sha256:2de29005e11637e7a2361fa151f780ff8eb2543a0da1413bb951e9f14b699ef3"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:666ecce376999bf619756a24ce15bb14c5bfaf04bf00abc7e663ce17c3f34fe7"}, + {file = "rpds_py-0.22.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:5246b14ca64a8675e0a7161f7af68fe3e910e6b90542b4bfb5439ba752191df6"}, + {file = "rpds_py-0.22.3.tar.gz", hash = "sha256:e32fee8ab45d3c2db6da19a5323bc3362237c8b653c70194414b892fd06a080d"}, +] + [[package]] name = "ruyaml" version = "0.91.0" description = "ruyaml is a fork of ruamel.yaml" optional = false python-versions = ">=3.6" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "ruyaml-0.91.0-py3-none-any.whl", hash = "sha256:50e0ee3389c77ad340e209472e0effd41ae0275246df00cdad0a067532171755"}, {file = "ruyaml-0.91.0.tar.gz", hash = "sha256:6ce9de9f4d082d696d3bde264664d1bcdca8f5a9dff9d1a1f1a127969ab871ab"}, @@ -1029,6 +1323,8 @@ version = "75.1.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "setuptools-75.1.0-py3-none-any.whl", hash = "sha256:35ab7fd3bcd95e6b7fd704e4a1539513edad446c097797f2985e0e4b960772f2"}, {file = "setuptools-75.1.0.tar.gz", hash = "sha256:d59a21b17a275fb872a9c3dae73963160ae079f1049ed956880cd7c09b120538"}, @@ -1049,6 +1345,8 @@ version = "1.16.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +groups = ["main"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, @@ -1060,6 +1358,8 @@ version = "0.10.2" description = "Python Library for Tom's Obvious, Minimal Language" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, @@ -1071,17 +1371,38 @@ version = "2.0.2" description = "A lil' TOML parser" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_full_version <= \"3.11.0a6\"" files = [ {file = "tomli-2.0.2-py3-none-any.whl", hash = "sha256:2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38"}, {file = "tomli-2.0.2.tar.gz", hash = "sha256:d46d457a85337051c36524bc5349dd91b1877838e2979ac5ced3e710ed8a60ed"}, ] +[[package]] +name = "traitlets" +version = "5.14.3" +description = "Traitlets Python configuration system" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" +files = [ + {file = "traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f"}, + {file = "traitlets-5.14.3.tar.gz", hash = "sha256:9ed0579d3502c94b4b3732ac120375cda96f923114522847de4b3bb98b96b6b7"}, +] + +[package.extras] +docs = ["myst-parser", "pydata-sphinx-theme", "sphinx"] +test = ["argcomplete (>=3.0.3)", "mypy (>=1.7.0)", "pre-commit", "pytest (>=7.0,<8.2)", "pytest-mock", "pytest-mypy-testing"] + [[package]] name = "types-pytz" version = "2024.2.0.20241003" description = "Typing stubs for pytz" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "types-pytz-2024.2.0.20241003.tar.gz", hash = "sha256:575dc38f385a922a212bac00a7d6d2e16e141132a3c955078f4a4fd13ed6cb44"}, {file = "types_pytz-2024.2.0.20241003-py3-none-any.whl", hash = "sha256:3e22df1336c0c6ad1d29163c8fda82736909eb977281cb823c57f8bae07118b7"}, @@ -1093,6 +1414,8 @@ version = "2.32.0.20240914" description = "Typing stubs for requests" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "types-requests-2.32.0.20240914.tar.gz", hash = "sha256:2850e178db3919d9bf809e434eef65ba49d0e7e33ac92d588f4a5e295fffd405"}, {file = "types_requests-2.32.0.20240914-py3-none-any.whl", hash = "sha256:59c2f673eb55f32a99b2894faf6020e1a9f4a402ad0f192bfee0b64469054310"}, @@ -1107,6 +1430,8 @@ version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, @@ -1118,6 +1443,8 @@ version = "2024.2" description = "Provider of IANA time zone data" optional = false python-versions = ">=2" +groups = ["main"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "tzdata-2024.2-py2.py3-none-any.whl", hash = "sha256:a48093786cdcde33cad18c2555e8532f34422074448fbc874186f0abd79565cd"}, {file = "tzdata-2024.2.tar.gz", hash = "sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc"}, @@ -1129,6 +1456,8 @@ version = "2.2.3" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" +groups = ["main", "dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "urllib3-2.2.3-py3-none-any.whl", hash = "sha256:ca899ca043dcb1bafa3e262d73aa25c465bfb49e0bd9dd5d59f1d0acba2f8fac"}, {file = "urllib3-2.2.3.tar.gz", hash = "sha256:e7d814a81dad81e6caf2ec9fdedb284ecc9c73076b62654547cc64ccdcae26e9"}, @@ -1146,6 +1475,8 @@ version = "20.26.6" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "virtualenv-20.26.6-py3-none-any.whl", hash = "sha256:7345cc5b25405607a624d8418154577459c3e0277f5466dd79c49d5e492995f2"}, {file = "virtualenv-20.26.6.tar.gz", hash = "sha256:280aede09a2a5c317e409a00102e7077c6432c5a38f0ef938e643805a7ad2c48"}, @@ -1166,6 +1497,8 @@ version = "1.16.1" description = "A simple opionated yaml formatter that keeps your comments!" optional = false python-versions = ">=3.8" +groups = ["dev"] +markers = "python_version <= \"3.11\" or python_version >= \"3.12\"" files = [ {file = "yamlfix-1.16.1-py3-none-any.whl", hash = "sha256:8c505ca27cf19181ca8943101b56b8e4ad58f47aa792fbab01339ededaddb7d2"}, {file = "yamlfix-1.16.1.tar.gz", hash = "sha256:f49ba70e457a1add6724a6859505d22f7f222f56f7e31f37822c530fc2e7ec94"}, @@ -1177,6 +1510,6 @@ maison = ">=1.4.0,<1.4.3" ruyaml = ">=0.91.0" [metadata] -lock-version = "2.0" +lock-version = "2.1" python-versions = "^3.9" -content-hash = "56893da3e5c4e664c7f2d8bd0ca69a996b85d028096cf412bbda217440e10936" +content-hash = "8749f1ce2f8131096db1f824de5a37b3d95ded8ca877de168330ad38669201f3" diff --git a/pyproject.toml b/pyproject.toml index 45e508a7..35514bdd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ pytest-cov = "^4.1.0" pandas-stubs = "^2.2.1.240316" types-requests = "^2.31.0.20240311" yamlfix = "^1.16.0" +nbformat = "^5.10.4" [build-system] requires = ["poetry-core"] diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..719bc68b --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,3 @@ +# cwms-python Generation and Helper Scripts + +* generate_examples.py - creates example jupiter notebooks from the mock api tests \ No newline at end of file diff --git a/scripts/generate_examples.py b/scripts/generate_examples.py new file mode 100644 index 00000000..219c2f20 --- /dev/null +++ b/scripts/generate_examples.py @@ -0,0 +1,301 @@ +import ast +import json +import os +import re + +import black +import nbformat +import pandas as pd + +# Base directories +TESTS_DIR = "./tests/" +EXAMPLES_DIR = "./examples/" + +# Ensure examples directory exists +os.makedirs(EXAMPLES_DIR, exist_ok=True) + +GITHUB_BASE_URL = "https://github.com/HydrologicEngineeringCenter/cwms-python/tree/main" + +# Ignore these directories when generating examples +IGNORE_DIR_NAMES = [TESTS_DIR, "/resources/", "/__pycache__"] + + +def extract_api_calls_and_mock_responses(test_file_path): + """ + Parses a test file, extracts API calls, mock API responses, and generates notebook-friendly code. + """ + with open(test_file_path, "r", encoding="utf-8") as file: + source_code = file.read() + + # Parse the Python test file + tree = ast.parse(source_code) + + setup_code = [] + function_contents = {} + resource_data = {} # Store JSON file contents used in mocks + mock_paths = {} # Store API paths and method types + + # Extract import statements and function bodies + for node in tree.body: + + if isinstance(node, ast.Import) or isinstance(node, ast.ImportFrom): + # If the import has the word test in it, skip it + if re.search(r"test", ast.unparse(node)): + continue + setup_code.append(ast.unparse(node)) + + elif isinstance(node, ast.Assign): # Look for variable assignments + for target in node.targets: + if isinstance(target, ast.Name) and isinstance(node.value, ast.Call): + if ( + isinstance(node.value.func, ast.Name) + and node.value.func.id == "read_resource_file" + ): + filename = node.value.args[ + 0 + ].value # Extract the filename being loaded + resource_data[target.id] = ( + filename # Store variable name and JSON file + ) + + elif isinstance(node, ast.Expr): # Check for mock API paths + call_code = ast.unparse(node).strip() + match = re.search(r"requests_mock", call_code) + if match: + continue # Ignore requests_mock calls + + elif isinstance(node, ast.FunctionDef) and node.name.startswith("test_"): + function_code = [] + for sub_node in node.body: + call_code = ast.unparse(sub_node).strip() + if isinstance(sub_node, ast.Expr): # Function call expressions + if not re.search( + r"requests_mock", call_code + ): # Ignore requests_mock + function_code.append(call_code) + elif isinstance( + sub_node, + (ast.Assign, ast.Assert, ast.If, ast.For, ast.While, ast.Try), + ): + if re.search(r"requests_mock", call_code): # Ignore requests_mock + continue + function_code.append(call_code) + function_contents[node.name] = function_code + return setup_code, function_contents, resource_data, mock_paths + + +def load_mock_data(resource_data): + """ + Reads mock JSON files from 'tests/resources/' and returns their contents. + """ + mock_outputs = {} + for var_name, filename in resource_data.items(): + file_path = os.path.join( + "tests/resources/", filename + ) # Assuming mock files are stored here + try: + with open(file_path, "r", encoding="utf-8") as json_file: + data = json.load(json_file) + mock_outputs[var_name] = data + except FileNotFoundError: + print(f"⚠️ Warning: Resource file not found: {file_path}") + mock_outputs[var_name] = None + return mock_outputs + + +def generate_notebooks(): + """ + Recursively scans TESTS_DIR, processes test files, and generates corresponding Jupyter notebooks. + """ + for root, _, files in os.walk(TESTS_DIR): + # Skip exact matches of ignored directories + if any(root.endswith(ignore) for ignore in IGNORE_DIR_NAMES): + print("⚠️\tIgnoring ", root) + continue + for file in files: + if file.endswith("_test.py"): + test_file_path = os.path.join(root, file) + setup_code, function_contents, resource_data, mock_paths = ( + extract_api_calls_and_mock_responses(test_file_path) + ) + + if function_contents: + # Load mock responses + mock_outputs = load_mock_data(resource_data) + + # Create a matching notebook filename + notebook_name = file.replace("_test.py", ".ipynb") + + # Preserve directory structure in examples/ + relative_path = os.path.relpath(root, TESTS_DIR) + test_github_link = f"{GITHUB_BASE_URL}{test_file_path}".replace( + "\\", "/" + ).replace("main.", "main") + + output_dir = os.path.join(EXAMPLES_DIR, relative_path) + os.makedirs(output_dir, exist_ok=True) + + notebook_path = os.path.join(output_dir, notebook_name) + + # Create Notebook cells + notebook_cells = [] + # Build our example page title + last_dir = os.path.basename(os.path.dirname(test_file_path)) + formatted_title = last_dir.replace("_", " ").title() + notebook_cells.append( + nbformat.v4.new_markdown_cell(f"# {formatted_title} Examples\n") + ) + notebook_cells.append( + nbformat.v4.new_markdown_cell( + f"**Example generated from:** [{test_github_link.replace(GITHUB_BASE_URL, "")}]({test_github_link})" + ) + ) + if setup_code: + notebook_cells.append( + nbformat.v4.new_code_cell( + "\n".join( + ["from cwms.api import init_session"] + setup_code + ) + ) + ) + + # Init database/write access section + notebook_cells.append( + nbformat.v4.new_markdown_cell( + "### Initializing the database and write access\n" + "cwms-python will connect by default to the USACE public database available through " + "[CWMS Data](https://cwms-data.usace.army.mil/cwms-data/). \n" + "\nhttps://cwms-data.usace.army.mil/cwms-data/\n\n" + "The apiRoot can be updated to access data directly from a USACE district database.\n" + "* Endpoints on the [Swagger Docs page](https://cwms-data.usace.army.mil/cwms-data/swagger-ui.html) " + "with a 🔒 icon require the apiKey be set." + ) + ) + notebook_cells.append( + nbformat.v4.new_code_cell( + 'api_root = "https://cwms-data-test.cwbi.us/cwms-data/"\n' + "api = init_session(api_root=api_root)" + ) + ) + + # Organize function calls by operation type + categorized_functions = { + "GET Requests": {}, + "POST Requests": {}, + "STORE Requests": {}, + "DELETE Requests": {}, + "PATCH Requests": {}, + "Other API Calls": {}, + } + + for function_name, statements in function_contents.items(): + function_code = "\n".join( + statements + ) # Keep full function contents as a single block + if ".get" in function_code: + categorized_functions["GET Requests"][ + function_name + ] = function_code + elif ".post" in function_code: + categorized_functions["POST Requests"][ + function_name + ] = function_code + elif ".store" in function_code: + categorized_functions["STORE Requests"][ + function_name + ] = function_code + elif ".delete" in function_code: + categorized_functions["DELETE Requests"][ + function_name + ] = function_code + elif ".patch" in function_code: + categorized_functions["PATCH Requests"][ + function_name + ] = function_code + else: + categorized_functions["Other API Calls"][ + function_name + ] = function_code + + # Add categorized function calls with function-specific subheadings + for category, functions in categorized_functions.items(): + if functions: + notebook_cells.append( + nbformat.v4.new_markdown_cell(f"# {category}") + ) + + for function_name, function_code in functions.items(): + notebook_cells.append( + nbformat.v4.new_markdown_cell( + f"## {function_name.replace("_", ' ').replace("test ", '')}" + ) + ) + + # Check if function uses a mock data variable and replace it inline + modified_function_code = function_code + # Only set the input data if we are doing a store call + if "create" in function_name: + for var_name, data in mock_outputs.items(): + if var_name in function_code: + modified_function_code = ( + modified_function_code.replace( + var_name, "data" + ) + ) + + # Insert the actual data dictionary as an initialization step + data_input = black.format_str( + str(data), mode=black.Mode() + ) + notebook_cells.append( + nbformat.v4.new_code_cell( + f"# Input Data:\n" + f"data = {black.format_str(str(data), mode=black.Mode())}\n" + ) + ) + modified_function_code = modified_function_code.replace( + "data = data\n", "" + ) + # Do not show assert calls in code + no_assert_code = re.sub( + r"assert .*", "", modified_function_code + ) + # Remove extra new lines at the end + no_assert_code = re.sub(r"\n\n+", "\n", no_assert_code) + notebook_cells.append( + nbformat.v4.new_code_cell( + black.format_str( + no_assert_code, mode=black.Mode() + ) + ) + ) + + # Replace assert calls with a suitable code cell + # But only if there is assert data.json, assert data.df, or assert values + # i.e. the regex should look for these things + + # Extract only relevant assert statements + assert_calls = re.findall( + r"assert (data\.json|data\.df|values|type\(data\))", + modified_function_code, + ) + # Generate a separate code block for each valid assert statement + for assert_call in assert_calls: + notebook_cells.append( + nbformat.v4.new_code_cell( + assert_call.replace("type(data)", "data.df") + ) + ) + + # Create and save the notebook + notebook = nbformat.v4.new_notebook() + notebook.cells = notebook_cells + + with open(notebook_path, "w", encoding="utf-8") as nb_file: + nbformat.write(notebook, nb_file) + + print(f"✅\tNotebook saved: {notebook_path}") + + +if __name__ == "__main__": + generate_notebooks() diff --git a/tests/timeseries/timeseries_test.py b/tests/timeseries/timeseries_test.py index 2ca21f76..4fe60123 100644 --- a/tests/timeseries/timeseries_test.py +++ b/tests/timeseries/timeseries_test.py @@ -165,24 +165,25 @@ def test_get_timeseries_unversioned_default(requests_mock): def test_get_empty_ts_df(requests_mock): + + timeseries_id = "KEYS.Elev.Inst.1Hour.0.Ccp-Rev" + office_id = "SWT" requests_mock.get( f"{_MOCK_ROOT}" - "/timeseries?office=SWT&" - "name=TEST.Text.Inst.1Hour.0.EMPTYTest&" + f"/timeseries?office={office_id}&" + f"name={timeseries_id}&" "unit=EN&" - "begin=2008-05-01T15%3A00%3A00%2B00%3A00&" - "end=2008-05-01T17%3A00%3A00%2B00%3A00&" + "begin=2024-05-01T15%3A00%3A00%2B00%3A00&" + "end=2024-05-01T17%3A00%3A00%2B00%3A00&" "page-size=500000&" "trim=true", json=_EMPTY_TS_JSON, ) - timeseries_id = "TEST.Text.Inst.1Hour.0.EMPTYTest" - office_id = "SWT" # explicitly format begin and end dates with default timezone as an example timezone = pytz.timezone("UTC") - begin = timezone.localize(datetime(2008, 5, 1, 15, 0, 0)) - end = timezone.localize(datetime(2008, 5, 1, 17, 0, 0)) + begin = timezone.localize(datetime(2024, 5, 1, 15, 0, 0)) + end = timezone.localize(datetime(2024, 5, 1, 17, 0, 0)) data = timeseries.get_timeseries( ts_id=timeseries_id, office_id=office_id, begin=begin, end=end