Skip to content

Commit f827aa7

Browse files
committed
switch USE_PORTAL to be false by default
Signed-off-by: Lance-Drane <Lance-Drane@users.noreply.github.com>
1 parent 9cf5957 commit f827aa7

3 files changed

Lines changed: 27 additions & 22 deletions

File tree

doc/user_guides/portal_guides.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ To use the portal on your local cluster, include the following variables in your
2121

2222
.. code-block:: text
2323
24+
# make sure to set this if you actually want to use the portal
25+
USE_PORTAL = true
2426
# stable version
2527
PORTAL_URL = http://lb.ipsportal.production.svc.spin.nersc.org
2628
# or, for the latest version
2729
# PORTAL_URL = http://lb.ipsportal.development.svc.spin.nersc.org
2830
# The API key is required for certain interactions with the portal, and will eventually become mandatory. This key should generally be set as an environment variable, and not saved to version control.
2931
PORTAL_API_KEY = "YOUR_PORTAL_API_KEY" # change this
30-
# To disable the portal even if PORTAL_URL is set, uncomment the next line.
31-
# USE_PORTAL = false
3232
3333
NOTE: On shared clusters, i.e. Perlmutter, there will generally be specific files that you can source in Slurm scripts which will automatically configure the Portal credentials for you, so you can skip settings these variables yourself. Please see the appropriate project documentation for information on how to configure this.
3434

ipsframework/configurationManager.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,15 @@ def _initialize_fwk_components(self):
357357
self.fwk_components.append(runspace_component_id)
358358

359359
# SIMYAN: set up The Portal bridge, allowing for an absence of a portal
360-
use_portal = True
361-
# If users explicitly disable the Portal via 'USE_PORTAL=false', or do not include a PORTAL_URL, assume the no-portal workflow.
362-
# Otherwise, always initialize the Portal workflow
360+
use_portal = False
361+
# Users must set USE_PORTAL and include a PORTAL_URL in order to enable the portal
363362
if 'PORTAL_URL' not in self.sim_map[self.fwk_sim_name].sim_conf:
364363
use_portal = False
365364
elif 'USE_PORTAL' in self.sim_map[self.fwk_sim_name].sim_conf:
366365
use_portal = self.sim_map[self.fwk_sim_name].sim_conf['USE_PORTAL']
367-
if use_portal.lower() == 'false':
366+
if isinstance(use_portal, str) and use_portal.lower().strip() == 'true':
367+
use_portal = True
368+
else:
368369
use_portal = False
369370

370371
fwk_components = [('local_logging_bridge', 'LocalLoggingBridge', lambda _config: None)]

ipsframework/services.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,8 +1927,21 @@ def setMonitorURL(self, url: str = '') -> None:
19271927
self.monitor_url = url
19281928
self._send_monitor_event(eventType='IPS_SET_MONITOR_URL', comment='SUCCESS')
19291929

1930-
def _get_jupyter_runid(self) -> int:
1931-
"""Get the runid Jupyter will associate with this run.
1930+
def _should_use_portal(self) -> bool:
1931+
"""Return True if we want to use the portal, False if not"""
1932+
use_portal_config = self.get_config_param('USE_PORTAL', silent=True)
1933+
1934+
if isinstance(use_portal_config, str):
1935+
return use_portal_config.strip().lower() == 'true'
1936+
elif use_portal_config is None:
1937+
return False
1938+
else:
1939+
# Because USE_PORTAL was not set in config file, or was mistakenly set as a dictionary.
1940+
self.warning('Unusual value for USE_PORTAL: %s', use_portal_config)
1941+
return False
1942+
1943+
def _get_portal_runid(self) -> int:
1944+
"""Get the runid Jupyter and the Portal will associate with this run.
19321945
Generally this will be the runid that the portal emits, but we will try to allow for fallbacks in certain cases.
19331946
19341947
If value is < 0, we were unable to get the portal runid.
@@ -1943,8 +1956,7 @@ def _get_jupyter_runid(self) -> int:
19431956
return -2
19441957

19451958
# first, check to see if we even want to use the portal
1946-
use_portal = self.get_config_param('USE_PORTAL', silent=True)
1947-
if use_portal and use_portal.lower() == 'false':
1959+
if not self._should_use_portal():
19481960
self.warning('web portal disabled')
19491961
self._portal_runid = -2
19501962
return -2
@@ -2000,7 +2012,7 @@ def initialize_jupyter_notebook(
20002012
:param source_notebook_path: location you want to load the source notebook from. This can be either an absolute path, or an IPS-appropriate relative path.
20012013
:param dest_notebook_name: (optional, default None) filename of the notebook to use when saving it to the IPS Portal. If not provided, this will defauly to the filename of the source notebook.
20022014
"""
2003-
portal_runid = self._get_jupyter_runid()
2015+
portal_runid = self._get_portal_runid()
20042016
if portal_runid < 0:
20052017
return
20062018

@@ -2038,7 +2050,7 @@ def add_analysis_data_files(self, current_data_file_paths: list[str], timestamp:
20382050
:param replace: If True, replace the last data file added with the new data file. If False, simply append the new data file. (default: False)
20392051
Note that if replace is not True but you attempt to overwrite it, a ValueError will be thrown.
20402052
"""
2041-
portal_runid = self._get_jupyter_runid()
2053+
portal_runid = self._get_portal_runid()
20422054
if portal_runid < 0:
20432055
return
20442056

@@ -2396,15 +2408,7 @@ def run_ensemble(
23962408
# ensemble
23972409
portal_ensemble_id = str(uuid.uuid4())
23982410

2399-
# (get_config_param() will return a string of a whatever the user set
2400-
# or None)
2401-
use_portal = self.get_config_param('USE_PORTAL', silent=True)
2402-
2403-
if use_portal is None:
2404-
# Because USE_PORTAL was not set in config file.
2405-
use_portal = False
2406-
elif type(use_portal) == str:
2407-
use_portal = "true" == use_portal.strip().lower()
2411+
use_portal = self._should_use_portal()
24082412

24092413
self.debug(f'use portal = {use_portal!s}')
24102414

@@ -2573,7 +2577,7 @@ def send_ensemble_instance_to_portal(ensemble_name: str, data_path: Path) -> Non
25732577
return
25742578

25752579
# ensure that the portal is initialized
2576-
portal_runid = self._get_jupyter_runid()
2580+
portal_runid = self._get_portal_runid()
25772581
if portal_runid < 0:
25782582
return
25792583

0 commit comments

Comments
 (0)