Browse Source

Add repository factory

pull/1310/head
Hironsan 3 years ago
parent
commit
1462b7b23b
1 changed files with 14 additions and 0 deletions
  1. 14
      app/api/views/download/factory.py

14
app/api/views/download/factory.py

@ -0,0 +1,14 @@
from ...models import DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING
from . import repositories
def create_repository(project) -> repositories.BaseRepository:
mapping = {
DOCUMENT_CLASSIFICATION: repositories.TextClassificationRepository,
SEQUENCE_LABELING: repositories.SequenceLabelingRepository,
SEQ2SEQ: repositories.Seq2seqRepository,
}
if project.project_type not in mapping:
ValueError(f'Invalid project type: {project.project_type}')
repository = mapping.get(project.project_type)(project)
return repository
Loading…
Cancel
Save