當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。