Skip to content

Commit

Permalink
add list remote SHOP versions (#301)
Browse files Browse the repository at this point in the history
* add list remote SHOP versions

* changelog

---------

Co-authored-by: Katrine Holm <[email protected]>
  • Loading branch information
katrilh and Katrine Holm authored Feb 13, 2024
1 parent 7c8a417 commit c0cfbee
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion cognite/powerops/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.84.0"
__version__ = "0.85.0"
13 changes: 13 additions & 0 deletions cognite/powerops/client/shop/shop_run_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...

Expand Down
127 changes: 111 additions & 16 deletions docs/tutorials/trigger_shop_run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -68,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"id": "8032c27e87713244",
"metadata": {
"ExecuteTime": {
Expand All @@ -87,7 +102,7 @@
"<SHOPRunStatus.SUCCESS: 'success'>"
]
},
"execution_count": 2,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -100,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "f5d0caf5-eb6d-44b5-87bf-229a284b87a6",
"metadata": {
"ExecuteTime": {
Expand Down Expand Up @@ -140,7 +155,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"id": "cb059ff0-88c5-46ae-8c6c-268a8c19f5b8",
"metadata": {
"ExecuteTime": {
Expand Down Expand Up @@ -169,7 +184,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"id": "6e0e5f9dd5a31345",
"metadata": {
"ExecuteTime": {
Expand Down Expand Up @@ -271,7 +286,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 16,
"id": "8566523ea1d8332",
"metadata": {
"ExecuteTime": {
Expand All @@ -287,10 +302,10 @@
{
"data": {
"text/plain": [
"<cognite.powerops.client.shop.shop_case.SHOPCase at 0x11c6f0a60>"
"<cognite.powerops.client.shop.shop_case.SHOPCase at 0x7fd6e32a1df0>"
]
},
"execution_count": 6,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -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": {
Expand All @@ -318,20 +413,20 @@
"<SHOPRunStatus.IN_PROGRESS: 'in_progress'>"
]
},
"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": {
Expand All @@ -348,7 +443,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"..............................DONE\n"
".....................................DONE\n"
]
},
{
Expand All @@ -357,7 +452,7 @@
"<SHOPRunStatus.SUCCESS: 'success'>"
]
},
"execution_count": 8,
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -1018,7 +1113,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down

0 comments on commit c0cfbee

Please sign in to comment.