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


Python connection.SearchConnection类代码示例

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


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

示例1: test_shards_constrain

    def test_shards_constrain(self):
        # Test that a file-context constrains the shard list
        conn = SearchConnection(self.test_service, distrib=True)

        ctx = conn.new_context(project='CMIP5')
        results = ctx.search()

        r1 = results[0]
        f_ctx = r1.file_context()

        # !TODO: white-box test.  Refactor.
        query_dict = f_ctx._build_query()
        full_query = f_ctx.connection._build_query(query_dict,
                                                   shards=f_ctx.shards)

        # !TODO: Force fail to see whether shards is passed through.
        # NOTE: 'shards' is NOT even a key in this dictionary. Needs rewrite!!!
        q_shard = full_query['shards']
        # Check it isn't a ',' separated list
        assert ',' not in q_shard
        q_shard_host = q_shard.split(':')[0]
        assert q_shard_host == r1.json['index_node']

        # Now make the query to make sure it returns data from
        # the right index_node
        f_results = f_ctx.search()
        f_r1 = f_results[0]
        assert f_r1.json['index_node'] == r1.json['index_node']
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:28,代码来源:test_results.py

示例2: test_context_facets1

def test_context_facets1():
    conn = SearchConnection(TEST_SERVICE)
    context = conn.new_context(project='CMIP5')

    context2 = context.constrain(model="IPSL-CM5A-LR")
    assert context2.facet_constraints['project'] == 'CMIP5'
    assert context2.facet_constraints['model'] == 'IPSL-CM5A-LR'
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:7,代码来源:test_context.py

示例3: test_passed_cached_session

 def test_passed_cached_session(self):
     import requests_cache
     td = datetime.timedelta(hours=1)
     session = requests_cache.core.CachedSession(self.cache,
                                                 expire_after=td)
     conn = SearchConnection(self.test_service, session=session)
     context = conn.new_context(project='cmip5')
     assert context.facet_constraints['project'] == 'cmip5'
开发者ID:bird-house,项目名称:esgf-pyclient,代码行数:8,代码来源:test_connection.py

示例4: test_get_shard_list

def test_get_shard_list():
    conn = SearchConnection(TEST_SERVICE, distrib=True)
    shards = conn.get_shard_list()
    #!NOTE: the exact shard list will change depending on the shard replication configuration
    #    on the test server
    assert 'esgf-index2.ceda.ac.uk' in shards
    # IPSL now replicates all non-local shards.  Just check it has a few shards
    assert len(shards['esgf-index2.ceda.ac.uk']) > 3
开发者ID:coecms,项目名称:esgf-pyclient,代码行数:8,代码来源:test_connection.py

示例5: test_result1

def test_result1():
    conn = SearchConnection(TEST_SERVICE, distrib=False)

    ctx = conn.new_context(project='CMIP5')
    results = ctx.search()

    r1 = results[0]
    assert r1.dataset_id == 'cmip5.output1.IPSL.IPSL-CM5A-LR.1pctCO2.3hr.atmos.3hr.r1i1p1.v20110427|vesg.ipsl.fr'
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:8,代码来源:test_results.py

示例6: test_context_facet_multivalue2

def test_context_facet_multivalue2():
    conn = SearchConnection(TEST_SERVICE)
    context = conn.new_context(project='CMIP5', model='IPSL-CM5A-MR')
    assert context.facet_constraints.getall('model') == ['IPSL-CM5A-MR']

    
    context2 = context.constrain(model=['IPSL-CM5A-MR', 'IPSL-CM5A-LR'])
    assert sorted(context2.facet_constraints.getall('model')) == ['IPSL-CM5A-LR', 'IPSL-CM5A-MR']
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:8,代码来源:test_context.py

示例7: test_result1

def test_result1():
    conn = SearchConnection(TEST_SERVICE, distrib=False)

    ctx = conn.new_context(project='CMIP5')
    results = ctx.search()

    r1 = results[0]
    assert re.match(r'cmip5\.output1\.IPSL\..\|vesg.ipsl.fr', r1.dataset_id)
开发者ID:bnlawrence,项目名称:esgf-pyclient,代码行数:8,代码来源:test_results.py

示例8: test_constrain_freetext

def test_constrain_freetext():
    conn = SearchConnection(TEST_SERVICE)

    context = conn.new_context(project='CMIP5', query='humidity')
    assert context.freetext_constraint == 'humidity'

    context = context.constrain(experiment='historical')
    assert context.freetext_constraint == 'humidity'
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:8,代码来源:test_context.py

示例9: test_facet_count

def test_facet_count():
    conn = SearchConnection(TEST_SERVICE)
    
    context = conn.new_context(project='CMIP5')
    context2 = context.constrain(model="IPSL-CM5A-LR")

    counts = context2.facet_counts
    assert counts['model'].keys() == ['IPSL-CM5A-LR']
    assert counts['project'].keys() == ['CMIP5']
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py

示例10: test_context_facets_multivalue

def test_context_facets_multivalue():
    conn = SearchConnection(TEST_SERVICE)
    context = conn.new_context(project='CMIP5')

    context2 = context.constrain(model=['IPSL-CM5A-LR', 'IPSL-CM5A-MR'])
    assert context2.hit_count > 0
    
    assert context2.facet_constraints['project'] == 'CMIP5'
    assert sorted(context2.facet_constraints.getall('model')) == ['IPSL-CM5A-LR', 'IPSL-CM5A-MR']
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py

示例11: test_download_url

def test_download_url():
    conn = SearchConnection(CEDA_SERVICE, distrib=False)

    ctx = conn.new_context()
    results = ctx.search(drs_id='GeoMIP.output1.MOHC.HadGEM2-ES.G1.day.atmos.day.r1i1p1')
    files = results[0].file_context().search()

    download_url = files[0].download_url
    assert re.match(r'http://.*\.nc', download_url)
开发者ID:bnlawrence,项目名称:esgf-pyclient,代码行数:9,代码来源:test_util.py

示例12: test_constrain

def test_constrain():
    conn = SearchConnection(TEST_SERVICE)
    
    context = conn.new_context(project='CMIP5')
    count1 = context.hit_count
    context = context.constrain(model="IPSL-CM5A-LR")
    count2 = context.hit_count

    assert count1 > count2
开发者ID:kterry,项目名称:esgf-pyclient,代码行数:9,代码来源:test_context.py

示例13: test_index_node

    def test_index_node(self):
        conn = SearchConnection(self.test_service, distrib=False)

        ctx = conn.new_context(project='CMIP5')
        results = ctx.search()

        r1 = results[0]
        service = urlparse(self.test_service)

        assert r1.index_node == service.hostname
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:10,代码来源:test_results.py

示例14: test_download_url

    def test_download_url(self):
        conn = SearchConnection(self.test_service, distrib=False)

        ctx = conn.new_context()
        results = ctx.search(drs_id=('GeoMIP.output.MOHC.HadGEM2-ES.G1.day.'
                                     'atmos.day.r1i1p1'))
        files = results[0].file_context().search()

        download_url = files[0].download_url
        assert re.match(r'http://.*\.nc', download_url)
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:10,代码来源:test_util.py

示例15: test_file_context

    def test_file_context(self):
        conn = SearchConnection(self.test_service, distrib=False)

        ctx = conn.new_context(project='CMIP5')
        results = ctx.search()

        r1 = results[0]
        f_ctx = r1.file_context()

        assert f_ctx.facet_constraints['dataset_id'] == r1.dataset_id
开发者ID:ESGF,项目名称:esgf-pyclient,代码行数:10,代码来源:test_results.py


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