Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usability of %load Edge IDs option #183

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions src/graph_notebook/magics/graph_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def load(self, line='', local_ns: dict = None):
parser.add_argument('-m', '--mode', choices=LOAD_JOB_MODES, default=MODE_AUTO)
parser.add_argument('-q', '--queue-request', action='store_true', default=False)
parser.add_argument('-d', '--dependencies', action='append', default=[])
parser.add_argument('-e', '--edge-ids', action='store_true', default=False)
parser.add_argument('-e', '--no-edge-ids', action='store_true', default=False)
parser.add_argument('-n', '--nopoll', action='store_true', default=False)

args = parser.parse_args(line.split())
Expand Down Expand Up @@ -758,6 +758,11 @@ def load(self, line='', local_ns: dict = None):
layout=widgets.Layout(width=widget_width)
)

if source_format.value.lower() == 'opencypher':
ids_hbox_visibility = 'flex'
else:
ids_hbox_visibility = 'none'

region_box = widgets.Text(
value=region,
placeholder=args.region,
Expand Down Expand Up @@ -795,9 +800,10 @@ def load(self, line='', local_ns: dict = None):

user_provided_edge_ids = widgets.Dropdown(
options=['TRUE', 'FALSE'],
value=str(args.edge_ids).upper(),
value=str(not args.no_edge_ids).upper(),
disabled=False,
layout=widgets.Layout(width=widget_width)
layout=widgets.Layout(display=ids_hbox_visibility,
width=widget_width)
)

queue_request = widgets.Dropdown(
Expand Down Expand Up @@ -887,10 +893,10 @@ def load(self, line='', local_ns: dict = None):
display="flex", justify_content="flex-end"))

dep_hbox = widgets.HBox([dep_hbox_label, dependencies])

ids_hbox_label = widgets.Label('User Provided Edge Ids:',
layout=widgets.Layout(width=label_width,
display="flex",
display=ids_hbox_visibility,
justify_content="flex-end"))

ids_hbox = widgets.HBox([ids_hbox_label, user_provided_edge_ids])
Expand All @@ -902,19 +908,30 @@ def load(self, line='', local_ns: dict = None):

poll_status_hbox = widgets.HBox([poll_status_label, poll_status])

display(source_hbox,
source_format_hbox,
region_hbox,
arn_hbox,
mode_hbox,
fail_hbox,
def update_edge_ids_options(change):
if change.new.lower() == 'opencypher':
ids_hbox_visibility = 'flex'
else:
ids_hbox_visibility = 'none'
user_provided_edge_ids.value = 'TRUE'
user_provided_edge_ids.layout.display = ids_hbox_visibility
ids_hbox_label.layout.display = ids_hbox_visibility

source_format.observe(update_edge_ids_options, names='value')

display(source_hbox,
source_format_hbox,
region_hbox,
arn_hbox,
mode_hbox,
fail_hbox,
parallelism_hbox,
cardinality_hbox,
queue_hbox,
dep_hbox,
cardinality_hbox,
queue_hbox,
dep_hbox,
ids_hbox,
poll_status_hbox,
button,
button,
output)

def on_button_clicked(b):
Expand Down