本文整理汇总了Python中aleph.model.Collection.all方法的典型用法代码示例。如果您正苦于以下问题:Python Collection.all方法的具体用法?Python Collection.all怎么用?Python Collection.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aleph.model.Collection
的用法示例。
在下文中一共展示了Collection.all方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: analyze
# 需要导入模块: from aleph.model import Collection [as 别名]
# 或者: from aleph.model.Collection import all [as 别名]
def analyze(foreign_id=None):
"""Re-analyze documents in the given collection (or throughout)."""
if foreign_id:
collection = Collection.by_foreign_id(foreign_id)
if collection is None:
raise ValueError("No such collection: %r" % foreign_id)
analyze_collection.delay(collection.id)
else:
for collection in Collection.all():
analyze_collection.delay(collection.id)
示例2: test_load_csv
# 需要导入模块: from aleph.model import Collection [as 别名]
# 或者: from aleph.model.Collection import all [as 别名]
def test_load_csv(self):
count = Collection.all().count()
assert 0 == count, count
db_uri = 'file://' + self.get_fixture_path('experts.csv')
os.environ['ALEPH_TEST_BULK_CSV'] = db_uri
yml_path = self.get_fixture_path('experts.yml')
config = load_config_file(yml_path)
bulk_load(config)
coll = Collection.by_foreign_id('experts')
assert coll.category == 'scrape', coll.category
_, headers = self.login(is_admin=True)
count = Collection.all().count()
assert 1 == count, count
url = '/api/2/entities?filter:schemata=Thing&q=Greenfield'
res = self.client.get(url, headers=headers)
assert res.status_code == 200, res
assert res.json['total'] == 1, res.json
示例3: test_load_sqlite
# 需要导入模块: from aleph.model import Collection [as 别名]
# 或者: from aleph.model.Collection import all [as 别名]
def test_load_sqlite(self):
count = Collection.all().count()
assert 0 == count, count
db_uri = 'sqlite:///' + self.get_fixture_path('kek.sqlite')
os.environ['ALEPH_TEST_BULK_DATABASE_URI'] = db_uri
yml_path = self.get_fixture_path('kek.yml')
config = load_config_file(yml_path)
bulk_load(config)
count = Collection.all().count()
assert 1 == count, count
coll = Collection.by_foreign_id('kek')
assert coll.category == 'scrape', coll.category
_, headers = self.login(is_admin=True)
url = '/api/2/entities?filter:schemata=Thing&q=friede+springer'
res = self.client.get(url, headers=headers)
assert res.status_code == 200, res
assert res.json['total'] == 1, res.json
res0 = res.json['results'][0]
key = '9895ccc1b3d6444ccc6371ae239a7d55c748a714'
assert res0['id'].startswith(key), res0
示例4: collections
# 需要导入模块: from aleph.model import Collection [as 别名]
# 或者: from aleph.model.Collection import all [as 别名]
def collections():
"""List all collections."""
for collection in Collection.all():
print collection.id, collection.foreign_id, collection.label
示例5: index_collections
# 需要导入模块: from aleph.model import Collection [as 别名]
# 或者: from aleph.model.Collection import all [as 别名]
def index_collections(entities=False, refresh=False):
q = Collection.all(deleted=True)
q = q.order_by(Collection.updated_at.desc())
for collection in q:
index_collection(collection, entities=entities, refresh=refresh)
示例6: load_collections
# 需要导入模块: from aleph.model import Collection [as 别名]
# 或者: from aleph.model.Collection import all [as 别名]
def load_collections():
tx = get_graph().begin()
for collection in Collection.all():
log.info("Index collection: %s", collection.label)
load_collection(tx, collection)
tx.commit()