コード例 #1
0
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
"""

import functools
import json

from IPython.core.display import HTML, display, clear_output

import ipywidgets as widgets
from graph_notebook.visualization.template_retriever import retrieve_template
from gremlin_python.driver.protocol import GremlinServerError
from requests import HTTPError

error_template = retrieve_template("error.html")


def display_exceptions(func):
    @functools.wraps(func)
    def do_display_exceptions(*args, **kwargs):
        clear_output()
        tab = widgets.Tab()
        try:
            return func(*args, **kwargs)
        except KeyboardInterrupt:
            print('Keyboard interrupt detected.')
            return  # we must return since we have halted the kernel interrupt here. Otherwise the interrupt will not work.
        except HTTPError as http_ex:
            raw_html = http_ex_to_html(http_ex)
        except GremlinServerError as gremlin_ex:
コード例 #2
0
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
"""

import json
import sys
import re
from typing import List
from requests import Response
from graph_notebook.visualization.template_retriever import retrieve_template

pre_container_template = retrieve_template("pre_container.html")


# class for individual metadata metric
class Metric(object):
    def __init__(self,
                 name: str,
                 friendly_name: str,
                 default_value: any = "N/A"):
        self.name = name  # used as key metadata.metrics
        self.friendly_name = friendly_name
        self.value = default_value

    def set_value(self, value: any):
        self.value = value


# class for complete metadata object to output
class Metadata(object):
コード例 #3
0
from graph_notebook.gremlin.status import do_gremlin_status, do_gremlin_cancel
from graph_notebook.sparql.query import get_query_type, do_sparql_query, do_sparql_explain
from graph_notebook.sparql.status import do_sparql_status, do_sparql_cancel
from graph_notebook.system.database_reset import perform_database_reset, initiate_database_reset
from graph_notebook.visualization.template_retriever import retrieve_template
from graph_notebook.gremlin.client_provider.factory import create_client_provider
from graph_notebook.request_param_generator.sparql_request_generator import SPARQLRequestGenerator
from graph_notebook.request_param_generator.factory import create_request_generator
from graph_notebook.loader.load import do_load, get_loader_jobs, get_load_status, cancel_load
from graph_notebook.configuration.get_config import get_config, get_config_from_dict
from graph_notebook.seed.load_query import get_data_sets, get_queries
from graph_notebook.status.get_status import get_status
from graph_notebook.widgets import Force
from graph_notebook.options import OPTIONS_DEFAULT_DIRECTED, vis_options_merge

sparql_table_template = retrieve_template("sparql_table.html")
sparql_explain_template = retrieve_template("sparql_explain.html")
sparql_construct_template = retrieve_template("sparql_construct.html")
gremlin_table_template = retrieve_template("gremlin_table.html")
pre_container_template = retrieve_template("pre_container.html")
loading_wheel_template = retrieve_template("loading_wheel.html")
error_template = retrieve_template("error.html")

loading_wheel_html = loading_wheel_template.render()
DEFAULT_LAYOUT = widgets.Layout(max_height='600px',
                                overflow='scroll',
                                width='100%')

logging.basicConfig()
logger = logging.getLogger("graph_magic")