Skip to content
Snippets Groups Projects

Retrieve ARKINDEX_CORPUS_ID in create_entity when corpus is None

Merged Eva Bardou requested to merge corpus-create-entity into master
All threads resolved!
2 files
+ 21
4
Compare changes
  • Side-by-side
  • Inline
Files
2
# -*- coding: utf-8 -*-
import os
from enum import Enum
from arkindex_worker import logger
@@ -19,11 +18,16 @@ class EntityType(Enum):
class EntityMixin(object):
def create_entity(self, element, name, type, corpus, metas=None, validated=None):
def create_entity(
self, element, name, type, corpus=None, metas=None, validated=None
):
"""
Create an entity on the given corpus through API
Return the ID of the created entity
"""
if corpus is None:
corpus = os.environ.get("ARKINDEX_CORPUS_ID")
assert element and isinstance(
element, (Element, CachedElement)
), "element shouldn't be null and should be an Element or CachedElement"
Loading