当前位置: 首页>>代码示例>>Python>>正文


Python session.Session类代码示例

本文整理汇总了Python中bokeh.session.Session的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_plot

def init_plot(crawl_name):
    session = Session()
    document = Document()
    session.use_doc(crawl_name)
    session.load_document(document)

    if document.context.children:
        plot = document.context.children[0]
    else:
        output_server(crawl_name)
        # TODO: Remove these when Bokeh is upgraded
        # placeholders or Bokeh can't inject properly
        current = np.datetime64(datetime.now())
        xdr = Range1d(current, current + 1)
        ydr = ["urls"]

        # styling suggested by Bryan
        plot = figure(title="Crawler Monitor", tools="hover",
                      x_axis_type="datetime", y_axis_location="right", x_range=xdr, y_range=ydr,
                      width=1200, height=600)
        plot.toolbar_location = None
        plot.xgrid.grid_line_color = None

    document.add(plot)
    session.store_document(document)
    script = autoload_server(plot, session)

    #TODO: Looks like a Bokeh bug, probably not repeatable with current code
    script = script.replace("'modelid': u'", "'modelid': '")
    return script
开发者ID:vuquangtin,项目名称:memex-explorer,代码行数:30,代码来源:stream.py

示例2: test_register

 def test_register(self):
     #create a dummy config file
     config = tempfile.mkdtemp()
     #create server
     server = Session(name="foo", root_url="http://localhost:5006/",
                     configdir=config
                     )
     assert server.userapikey == "nokey"
     #register a user
     server.register("testuser", "fluffy")
     assert server.userapikey and server.userapikey != "nokey"
     #create a second server configuration
     #make sure it loads the proper api key
     server2 = Session(name="foo",
                      configdir=config
                      )
     assert server2.userapikey == server.userapikey
     assert server2.root_url == server.root_url
开发者ID:Afey,项目名称:bokeh,代码行数:18,代码来源:multiuser_auth_test.py

示例3: wrapper

        def wrapper(*args, **kwargs):
            document = Document()
            session = Session(name=url, root_url=url)
            session.use_doc(document.docid)
            session.load_document(document)
            session.publish()
            document.autoadd = False
            document.autostore = False

            obj = func(*args, **kwargs)
            obj._docid = session.docid
            obj._root_url = session.root_url

            document.add(obj)
            session.store_document(document)
            return obj
开发者ID:DataVizi,项目名称:pycon_2015_bokeh_talk,代码行数:16,代码来源:utils.py

示例4: __init__

 def __init__(self, document_name, server_url=None, start_server=False,
              clear_document=True, **kwargs):
     self.document_name = document_name
     self.server_url = (config.bokeh_server if server_url is None
                        else server_url)
     self.start_server = start_server
     self.sub = self._start_server_process() if self.start_server else None
     self.session = Session(root_url=self.server_url)
     self.document = Document()
     self._setup_document(clear_document)
     super(PlottingExtension, self).__init__(**kwargs)
开发者ID:MLDL,项目名称:blocks-extras,代码行数:11,代码来源:plot.py

示例5: __init__

    def __init__(self):
        from bokeh.objects import ColumnDataSource
        from bokeh.document import Document
        from bokeh.session import Session
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = Session()
        self.session.use_doc('population_reveal')
        self.session.load_document(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())
开发者ID:HyperionAnalytics,项目名称:bokeh,代码行数:13,代码来源:app_reveal.py

示例6: __init__

    def __init__(self):
        from bokeh.models import ColumnDataSource
        from bokeh.document import Document
        from bokeh.session import Session
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = Session()
        self.session.use_doc('population_reveal')
        self.session.load_document(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())

        # just render at the initialization
        self._render()
开发者ID:Wombatpm,项目名称:bokeh,代码行数:16,代码来源:app_reveal.py

示例7: __init__

    def __init__(self):
        self.document = Document()
        self.session = Session()
        self.session.use_doc('data_tables_server')
        self.session.load_document(self.document)

        self.manufacturer_filter = None
        self.model_filter = None
        self.transmission_filter = None
        self.drive_filter = None
        self.class_filter = None

        self.source = ColumnDataSource()
        self.update_data()

        self.document.add(self.create())
        self.session.store_document(self.document)
开发者ID:akansal1,项目名称:bokeh,代码行数:17,代码来源:data_tables_server.py

示例8: wrapper

        def wrapper(*args, **kwargs):
            reset_output()
            docname = prefix + str(uuid.uuid4())
            session = Session(name=url, root_url=url)
            session.use_doc(docname)
            session.load_document(curdoc())
            session.publish()
            curdoc().autoadd = False
            curdoc().autostore = False

            obj = func(*args, **kwargs)
            tag = embed.autoload_server(obj, session, public=True)
            obj._tag = tag

            curdoc().add(obj)
            changed = session.store_document(curdoc())

            logger.debug("stored: %s", str(changed))

            return obj
开发者ID:Wombatpm,项目名称:bokeh,代码行数:20,代码来源:pluginutils.py

示例9: __init__

    def __init__(self, path, url):
        self.document = Document()
        self.session = Session(name=url, root_url=url)
        #self.session = Session('load_from_config=False')
        self.session.use_doc('crawler_dashboard')
        self.session.load_document(self.document)

        #self.harvest_source = ColumnDataSource(data=dict())
        #self.domain_relevant_source = ColumnDataSource(data=dict())
        #self.domain_crawled_source = ColumnDataSource(data=dict())
        #self.domain_frontier_source = ColumnDataSource(data=dict())
        #self.handson_source = ColumnDataSource(data=dict())
        #self.termite_source = ColumnDataSource(data=dict())
        self.harvest = Harvest(path)
        self.domain = Domain(path)
        #handson = Handson()
        #self.termite = Termite()

        self.document.add(self.create_layout())
        self.session.store_document(self.document)
开发者ID:ViDA-NYU,项目名称:memex,代码行数:20,代码来源:nyu-dashboard.py

示例10: __init__

    def __init__(self):
        self.document = Document()
        self.session = Session()
        self.session.use_doc('crawler_dashboard')
        self.session.load_document(self.document)

        #self.harvest_source = ColumnDataSource(data=dict())
        #self.domain_relevant_source = ColumnDataSource(data=dict())
        #self.domain_crawled_source = ColumnDataSource(data=dict())
        #self.domain_frontier_source = ColumnDataSource(data=dict())
        #self.handson_source = ColumnDataSource(data=dict())
        #self.termite_source = ColumnDataSource(data=dict())

        self.harvest = Harvest()
        self.domain = Domain()
        #handson = Handson()
        self.termite = Termite()

        self.document.add(self.create_layout())
        self.session.store_document(self.document)
开发者ID:ViDA-NYU,项目名称:memex,代码行数:20,代码来源:app.py

示例11: __init__

    def __init__(self,
            port = BK_SERVER_PORT,
            doc_name = DOC_NAME,
            colors = COLORS,
            show = False,
        ):
        """
        Initialize Bokeh session and document.
        """

        self.document = Document()

        self.port = port
        self.show = show
        self.doc_name = doc_name

        name="http://localhost:{}/".format(port)
        root_url="http://localhost:{}/".format(port)

        # Initialize Session
        self.session = Session(load_from_config=False,
                               name=name,
                               root_url=root_url)

        try:
            self.session.use_doc(doc_name)
        except requests.ConnectionError as e:
            print("\nPlease start bokeh-sever on the command line to launch this dashboard.")
            exit(1)
        self.session.load_document(self.document)

        # Configuration
        self.colors = itertools.cycle(COLORS)


        # Initialize data sources, construct and store dashboard
        self.init_sources()
        self.document.add(self.construct())
开发者ID:kdodia,项目名称:snippets,代码行数:38,代码来源:dashboard_template.py

示例12: __init__

    def __init__(self, crawl_name, num_urls=DEFAULT_NUM_URLS):
        """
        Create a NutchUrlTrails instance for visualizing a running Nutch crawl in real-time using Bokeh
        :param name: The name of the crawl (as identified by the queue)
        :param num_urls: The number of URLs to display in the visualization
        :return: A NutchUrLTrails instance
        """
        self.crawl_name = crawl_name
        self.num_urls = num_urls
        self.open_urls = {}
        self.closed_urls = {}
        self.old_segments = None
        self.old_circles = None
        
        self.session = Session()
        self.session.use_doc(self.crawl_name)
        self.document = Document()

        con = Connection()

        exchange = Exchange(EXCHANGE_NAME, 'direct', durable=False)
        queue = Queue(crawl_name, exchange=exchange, routing_key=crawl_name)
        self.queue = con.SimpleQueue(name=queue)
开发者ID:JonathanBowker,项目名称:memex-explorer,代码行数:23,代码来源:stream.py

示例13: wrapper

        def wrapper(*args, **kwargs):
            docname = prefix + str(uuid.uuid4())
            session = Session(name=url, root_url=url)
            session.use_doc(docname)
            session.load_document(curdoc())
            curdoc().autoadd(False)
            curdoc().autostore(False)

            obj = func(*args, **kwargs)
            tag = embed.autoload_server(obj, session)
            obj.tag = tag

            curdoc().add(obj)
            changed = session.store_document(curdoc())

            logger.debug("stored: %s", str(changed))

            return obj
开发者ID:HyperionAnalytics,项目名称:bokeh,代码行数:18,代码来源:pluginutils.py

示例14: test_login

    def test_login(self):
        #create a server config, register a user
        config1 = tempfile.mkdtemp()
        server = Session(name="foo", root_url="http://localhost:5006/",
                        configdir=config1
                        )
        assert server.userapikey == "nokey"
        server.register("testuser", "fluffy")
        assert server.userapikey and server.userapikey != "nokey"

        #create a separate server config, login a user
        config2 = tempfile.mkdtemp()
        server2 = Session(name="foo", root_url="http://localhost:5006/",
                         configdir=config2
                         )
        assert server2.userapikey == "nokey"
        server2.login("testuser", "fluffy")
        #make sure the userapikeys match
        assert server2.userapikey == server.userapikey
开发者ID:Afey,项目名称:bokeh,代码行数:19,代码来源:multiuser_auth_test.py

示例15: import

from requests.exceptions import ConnectionError
import pandas as pd
from bokeh.models import (Plot, ColumnDataSource, DataRange1d, FactorRange,
                           LinearAxis, CategoricalAxis, Grid, Glyph)
from bokeh.models.widgets import (DateRangeSlider, HBox, VBox, Paragraph,
                                  Select, VBoxModelForm)
from bokeh.glyphs import Rect
from bokeh.document import Document
from bokeh.session import Session

import employment_data_reader as emp
from employment_utils import get_country_for_byte, get_jobtype_for_byte

document = Document()
session = Session()
session.use_doc('employment_server')
session.load_document(document)

days_of_week = {0: "Monday", 1: "Tuesday", 2: "Wednesday", 3: "Thursday",
                4: "Friday", 5: "Saturday", 6: "Sunday"}
bounds_start = datetime.date(2012, 11, 1)
bounds_end = datetime.date(2013, 12, 30)
start = datetime.date(2013, 5, 26)
end = datetime.date(2013, 7, 5)
source_country = ColumnDataSource(data=dict())
source_dow = ColumnDataSource(data=dict())
source_jobtype = ColumnDataSource(data=dict())
source_par = Paragraph()
country_choices = ["Dominican Republic___________________",
                   "Colombia_____________________________",
开发者ID:rebeccabilbro,项目名称:demo,代码行数:30,代码来源:new_demo.py


注:本文中的bokeh.session.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。