Skip to content

Commit b0b500a

Browse files
committed
added logic for getting the latest runtime ver
1 parent d215583 commit b0b500a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

update_items.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import traceback
2222

2323
import nbformat
24+
import requests
2425
import yaml
2526
from arcgis.gis import GIS
2627
from nbconvert import HTMLExporter
@@ -55,6 +56,8 @@ def _main():
5556
if args.version:
5657
NB_ITEM_PROPERTIES_RUNTIME_STAMP_ADVANCED["notebookRuntimeVersion"] = args.version
5758
NB_ITEM_PROPERTIES_RUNTIME_STAMP_STANDARD["notebookRuntimeVersion"] = args.version
59+
else:
60+
_get_current_runtime(gis)
5861
items_metadata_yaml = _read_items_metadata_yaml()
5962
if args.replace_profiles:
6063
_replace_profiles()
@@ -110,6 +113,16 @@ def _setup_logging(args):
110113
log.debug("args passed in => {}".format(args))
111114

112115

116+
def _get_current_runtime(gis):
117+
ntbk_svr = gis.notebook_server[0]
118+
rest = ntbk_svr._url.replace("/admin", "/rest")
119+
rest_info = requests.get(f"{rest}/info?f=json", timeout=5, verify=False)
120+
version = rest_info.json()["currentRuntimeVersion"]
121+
NB_ITEM_PROPERTIES_RUNTIME_STAMP_ADVANCED["notebookRuntimeVersion"] = version
122+
NB_ITEM_PROPERTIES_RUNTIME_STAMP_STANDARD["notebookRuntimeVersion"] = version
123+
return version
124+
125+
113126
def _read_items_metadata_yaml():
114127
"""Returns the items_metadata.yaml file as a dict"""
115128
with open(ITEMS_METADATA_YAML_PATH) as f:

0 commit comments

Comments
 (0)