diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f80fe294..cd29e0f14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ Changes are grouped as follows - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [0.85.0] - 2024-02-11 +### Added +* List of SHOP versions in CDF + ## [0.84.0] - 2024-02-11 ### Added * Setup v1 Data Models generated with `pygen` diff --git a/cognite/powerops/_version.py b/cognite/powerops/_version.py index 3047a3805..52a511a33 100644 --- a/cognite/powerops/_version.py +++ b/cognite/powerops/_version.py @@ -1 +1 @@ -__version__ = "0.84.0" +__version__ = "0.85.0" diff --git a/cognite/powerops/client/shop/shop_run_api.py b/cognite/powerops/client/shop/shop_run_api.py index c448adf5c..3b3bad748 100644 --- a/cognite/powerops/client/shop/shop_run_api.py +++ b/cognite/powerops/client/shop/shop_run_api.py @@ -304,6 +304,19 @@ def list( ).get_filters() return self._load_cdf_event_shop_runs(extra_filters=extra_filters, limit=limit) + def versions(self, py_version: str = "3.9") -> list[str]: + """List the available version of SHOP remotely in CDF. Does not include versions in CogShop Image. + SHOP releases should have the following format: + 'SHOP-${{VERSION}}-pyshop-python{py_version}.linux.zip' + """ + files = self._cdf.files.list(metadata={"shop:type": "shop-release"}, limit=-1) + remote_versions = [] + for file in files: + name_parts = file.name.split("-") + if f"python{py_version}" in name_parts: + remote_versions.append("-".join(name_parts[:2])) + return remote_versions + @overload def _create(self, shop_run: SHOPRun | Sequence[SHOPRun]) -> SHOPRun | Sequence[SHOPRun]: ... diff --git a/docs/tutorials/trigger_shop_run.ipynb b/docs/tutorials/trigger_shop_run.ipynb index 3eb14500c..5a048bc83 100644 --- a/docs/tutorials/trigger_shop_run.ipynb +++ b/docs/tutorials/trigger_shop_run.ipynb @@ -39,7 +39,22 @@ "start_time": "2023-10-31T16:50:15.150704Z" } }, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/katrineholm/powerOps/power-ops-sdk/.venv/lib/python3.9/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_template\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n", + "/home/katrineholm/powerOps/power-ops-sdk/.venv/lib/python3.9/site-packages/pydantic/_internal/_fields.py:151: UserWarning: Field \"model_file\" has conflict with protected namespace \"model_\".\n", + "\n", + "You may be able to resolve this warning by setting `model_config['protected_namespaces'] = ()`.\n", + " warnings.warn(\n" + ] + } + ], "source": [ "# You can control which setting files are loaded through the environmental variable below.\n", "# In this case, the setting files are located two levels above, in the root of the repository.\n", @@ -68,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 6, "id": "8032c27e87713244", "metadata": { "ExecuteTime": { @@ -87,7 +102,7 @@ "" ] }, - "execution_count": 2, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -100,7 +115,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 7, "id": "f5d0caf5-eb6d-44b5-87bf-229a284b87a6", "metadata": { "ExecuteTime": { @@ -140,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "id": "cb059ff0-88c5-46ae-8c6c-268a8c19f5b8", "metadata": { "ExecuteTime": { @@ -169,7 +184,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "id": "6e0e5f9dd5a31345", "metadata": { "ExecuteTime": { @@ -271,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 16, "id": "8566523ea1d8332", "metadata": { "ExecuteTime": { @@ -287,10 +302,10 @@ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 6, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -301,9 +316,89 @@ "case_1" ] }, + { + "cell_type": "markdown", + "id": "38f9a94e", + "metadata": {}, + "source": [ + "### SHOP version\n", + "There are some versions of SHOP which are already loaded in COGSHOP, the image tag `cogshop_version` in `settings.toml`. \n", + "As of February 2024, the following SHOP versions for python version `3.9` are in the image:\n", + "* `SHOP-15.4.1.1`\n", + "* `SHOP-15.4.1.0`\n", + "* `SHOP-15.3.3.2`\n", + "* `SHOP-15.1.1.1`\n", + "* `SHOP-15.1.0.1`\n", + "* `SHOP-15.0.1.0`\n", + "* `SHOP-15.0.0.4`\n", + "* `SHOP-14.5.1.0`\n", + "* `SHOP-14.5.0.6`\n", + "* `SHOP-14.4.3.0`\n", + "* `SHOP-14.4.2.4`\n", + "* `SHOP-14.4.2.1`\n", + "* `SHOP-14.4.1.3`\n", + "* `SHOP-14.4.0.5`\n", + "* `SHOP-14.3.5.3`\n" + ] + }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 17, + "id": "c6bb6434", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'14.4.3.0'" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# See which version a case has\n", + "case_1.shop_version" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "fab35a12", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['SHOP-15.4.0.0', 'SHOP-15.4.1.1']" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# See which additional versions are available remotely\n", + "powerops.shop.versions(py_version=\"3.9\")" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "dff936c3", + "metadata": {}, + "outputs": [], + "source": [ + "# Changing the SHOP version for a shop run can be done like so:\n", + "case_1.shop_version = \"15.3.3.2\" " + ] + }, + { + "cell_type": "code", + "execution_count": 31, "id": "ea6cfe5b-25a0-4007-b8cd-015719a7d092", "metadata": { "ExecuteTime": { @@ -318,20 +413,20 @@ "" ] }, - "execution_count": 7, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Run SHOP by triggering the new case.\n", - "shop_run_1 = powerops.shop.trigger_case(case_1)\n", + "shop_run_1 = powerops.shop.trigger_single_casefile(case_1)\n", "shop_run_1.check_status()" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 32, "id": "2058d00ad136b94a", "metadata": { "ExecuteTime": { @@ -348,7 +443,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "..............................DONE\n" + ".....................................DONE\n" ] }, { @@ -357,7 +452,7 @@ "" ] }, - "execution_count": 8, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -1018,7 +1113,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.17" + "version": "3.9.12" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index 884c23905..04ea1deac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cognite-power-ops" -version = "0.84.0" +version = "0.85.0" description = "SDK for power markets operations on Cognite Data Fusion" readme = "README.md" authors = ["Cognite "]