Skip to content

Commit

Permalink
Update object selectors (#62)
Browse files Browse the repository at this point in the history
* update deprecated ObjectSelector to Selector
fix styles

* python 12 compatibility

* python 12 compatibility
  • Loading branch information
sdc50 authored Sep 17, 2024
1 parent 32ba67d commit 99da215
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions uit/gui_tools/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def panel(self):

class HpcConnect(param.Parameterized):
uit_client = param.ClassSelector(Client)
system = param.ObjectSelector()
login_node = param.ObjectSelector(default=None, objects=[None], label='Login Node')
system = param.Selector()
login_node = param.Selector(default=None, objects=[None], label='Login Node')
exclude_nodes = param.ListSelector(default=list(), objects=[], label='Exclude Nodes')
connected = param.Boolean(default=False, allow_None=True)
connect_btn = param.Action(lambda self: self.connect(), label='Connect')
Expand Down
11 changes: 6 additions & 5 deletions uit/gui_tools/file_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ class FileTransfer(param.Parameterized):
precedence=-1
)

from_location = param.ObjectSelector(
from_location = param.Selector(
default='local',
objects=['local'],
precedence=0.21
)
from_directory = param.String(
precedence=0.22
)
to_location = param.ObjectSelector(
to_location = param.Selector(
default='local',
objects=['local'],
precedence=0.31
Expand Down Expand Up @@ -395,9 +395,10 @@ def __new__(cls, *args, is_dir=None, uit_client=None):
self = super().__new__(cls, *args)
self._init(is_dir=is_dir, uit_client=uit_client)
return self

def __truediv__(self, key):
new_path = super().__truediv__(key)
new_path.__init__(uit_client=self.uit_client)
new_path.__initialize__(uit_client=self.uit_client)
return new_path

def _ensure_connected(method):
Expand All @@ -418,7 +419,7 @@ def ls(self):
@property
def parent(self):
parent = super().parent
parent.__init__(is_dir=True, uit_client=self.uit_client)
parent.__initialize__(is_dir=True, uit_client=self.uit_client)
return parent

@_ensure_connected
Expand Down Expand Up @@ -623,7 +624,7 @@ def __init__(self, **params):
class FileViewer(param.Parameterized):
update_btn = param.Action(lambda self: self.get_file_contents(), label='Update', precedence=5)
n = param.Integer(default=500, bounds=(0, 10_000), precedence=2)
cmd = param.ObjectSelector(default='head', objects=['head', 'tail', 'grep'], label='Command', precedence=1)
cmd = param.Selector(default='head', objects=['head', 'tail', 'grep'], label='Command', precedence=1)
line_wrap = param.Boolean(label='Line Wrap', precedence=3)
wrap_length = param.Integer(default=100, label='Wrap Length', precedence=4)
file_select = param.ClassSelector(FileSelector, default=FileSelector())
Expand Down
11 changes: 7 additions & 4 deletions uit/gui_tools/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@


class PbsScriptInputs(param.Parameterized):
hpc_subproject = param.ObjectSelector(default=None, label='HPC Subproject', precedence=3)
hpc_subproject = param.Selector(default=None, label='HPC Subproject', precedence=3)
subproject_usage = param.DataFrame(precedence=3.1)
workdir = param.String(default='', precedence=4)
node_type = param.ObjectSelector(default='', objects=[], label='Node Type', precedence=5)
node_type = param.Selector(default='', objects=[], label='Node Type', precedence=5)
nodes = param.Integer(default=1, bounds=(1, 1000), precedence=5.1)
processes_per_node = param.ObjectSelector(default=1, objects=[], label='Processes per Node', precedence=5.2)
processes_per_node = param.Selector(default=1, objects=[], label='Processes per Node', precedence=5.2)
wall_time = param.String(default='01:00:00', label='Wall Time', precedence=6)
wall_time_alert = pn.pane.Alert(visible=False)
node_alert = pn.pane.Alert(visible=False)
queue = param.ObjectSelector(default=QUEUES[0], objects=QUEUES, precedence=7)
queue = param.Selector(default=QUEUES[0], objects=QUEUES, precedence=7)
max_wall_time = param.String(default='Not Found', label='Max Wall Time', precedence=7.1)
max_nodes = param.String(default='Not Found', label='Max Processes', precedence=7.2)
submit_script_filename = param.String(default='run.pbs', precedence=8)
Expand Down Expand Up @@ -141,6 +141,7 @@ def pbs_options_view(self):
title='Subproject Usage Summary',
sizing_mode='stretch_width',
collapsed=True,
margin=(10, 0),
)
),
pn.Column(
Expand Down Expand Up @@ -290,6 +291,7 @@ def environment_variables_view(self):
self.file_browser_col,
title='Environment Variables',
sizing_mode='stretch_width',
margin=(10, 0),
)

def advanced_options_view(self):
Expand All @@ -303,6 +305,7 @@ def advanced_options_view(self):
title='Modules',
sizing_mode='stretch_width',
collapsed=True,
margin=(10, 0),
),
name='Environment',
)
Expand Down
12 changes: 5 additions & 7 deletions uit/gui_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class PbsJobTabbedViewer(HpcWorkspaces):
title = param.String()
jobs = param.List()
tabs = param.List()
selected_job = param.ObjectSelector(default=None, label='Job')
selected_sub_job = param.ObjectSelector(label='Experiment Point', precedence=0.1)
selected_job = param.Selector(default=None, label='Job')
selected_sub_job = param.Selector(label='Experiment Point', precedence=0.1)
active_job = param.Parameter()
custom_logs = param.List(default=[])
ready = param.Boolean()
Expand Down Expand Up @@ -142,8 +142,7 @@ def is_array(self):
def update_selected_job(self):
if not self.environment_variables:
self.update_configurable_hpc_parameters()
self.param.selected_job.names = {j.job_id: j for j in self.jobs}
self.param.selected_job.objects = self.jobs
self.param.selected_job.objects = {j.job_id: j for j in self.jobs}
self.selected_job = self.jobs[0] if self.jobs else None
self.param.selected_job.precedence = 1 if len(self.jobs) > 1 else -1

Expand All @@ -159,8 +158,7 @@ def update_selected_job_dependencies(self):

def update_selected_sub_job(self):
objects = [j for j in self.selected_job.sub_jobs]
self.param.selected_sub_job.names = {j.job_id: j for j in objects}
self.param.selected_sub_job.objects = objects
self.param.selected_sub_job.objects = {j.job_id: j for j in objects}
if objects:
self.selected_sub_job = objects[0]

Expand Down Expand Up @@ -245,7 +243,7 @@ def panel(self):

class LogsTab(TabView):
title = param.String(default='Logs')
log = param.ObjectSelector(objects=[], label='Log File', precedence=0.2)
log = param.Selector(objects=[], label='Log File', precedence=0.2)
log_content = param.String()
custom_logs = param.List(default=[])
num_log_lines = param.Integer(default=100, label='n')
Expand Down

0 comments on commit 99da215

Please sign in to comment.