mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Small changes in the contribution package
This commit is contained in:
		@@ -10,7 +10,7 @@ from wtforms import (
 | 
			
		||||
    ValidationError
 | 
			
		||||
)
 | 
			
		||||
from wtforms.validators import InputRequired, Length
 | 
			
		||||
from app.models import TesseractOCRPipelineModel
 | 
			
		||||
from app.models import TesseractOCRPipelineModel, SpaCyNLPPipelineModel
 | 
			
		||||
from . import SERVICES
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -73,11 +73,11 @@ class CreateTesseractOCRPipelineJobForm(CreateJobBaseForm):
 | 
			
		||||
                if 'disabled' in self.binarization.render_kw:
 | 
			
		||||
                    del self.binarization.render_kw['disabled']
 | 
			
		||||
        models = [
 | 
			
		||||
            x for x in TesseractOCRPipelineModel.query.filter().all()
 | 
			
		||||
            x for x in TesseractOCRPipelineModel.query.order_by(TesseractOCRPipelineModel.title).all()
 | 
			
		||||
            if version in x.compatible_service_versions and (x.shared == True or x.user == current_user)
 | 
			
		||||
        ]
 | 
			
		||||
        self.model.choices = [('', 'Choose your option')]
 | 
			
		||||
        self.model.choices += [(x.hashid, x.title) for x in models]
 | 
			
		||||
        self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in models]
 | 
			
		||||
        self.model.default = ''
 | 
			
		||||
        self.version.choices = [(x, x) for x in service_manifest['versions']]
 | 
			
		||||
        self.version.data = version
 | 
			
		||||
@@ -127,7 +127,7 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
 | 
			
		||||
    encoding_detection = BooleanField('Encoding detection', render_kw={'disabled': True})
 | 
			
		||||
    txt = FileField('File', validators=[FileRequired()])
 | 
			
		||||
    model = SelectField('Model', validators=[InputRequired()])
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    def validate_encoding_detection(self, field):
 | 
			
		||||
        service_info = SERVICES['spacy-nlp-pipeline']['versions'][self.version.data]
 | 
			
		||||
        if field.data:
 | 
			
		||||
@@ -153,8 +153,12 @@ class CreateSpacyNLPPipelineJobForm(CreateJobBaseForm):
 | 
			
		||||
            if 'encoding_detection' in service_info['methods']:
 | 
			
		||||
                if 'disabled' in self.encoding_detection.render_kw:
 | 
			
		||||
                    del self.encoding_detection.render_kw['disabled']
 | 
			
		||||
        models = [
 | 
			
		||||
            x for x in SpaCyNLPPipelineModel.query.order_by(SpaCyNLPPipelineModel.title).all()
 | 
			
		||||
            if version in x.compatible_service_versions and (x.shared == True or x.user == current_user)
 | 
			
		||||
        ]
 | 
			
		||||
        self.model.choices = [('', 'Choose your option')]
 | 
			
		||||
        self.model.choices += [(x, y) for x, y in service_info['models'].items()]  # noqa
 | 
			
		||||
        self.model.choices += [(x.hashid, f'{x.title} [{x.version}]') for x in models]
 | 
			
		||||
        self.model.default = ''
 | 
			
		||||
        self.version.choices = [(x, x) for x in service_manifest['versions']]
 | 
			
		||||
        self.version.data = version
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,8 @@ from app.models import (
 | 
			
		||||
    Job,
 | 
			
		||||
    JobInput,
 | 
			
		||||
    JobStatus,
 | 
			
		||||
    TesseractOCRPipelineModel
 | 
			
		||||
    TesseractOCRPipelineModel,
 | 
			
		||||
    SpaCyNLPPipelineModel
 | 
			
		||||
)
 | 
			
		||||
from . import bp, SERVICES
 | 
			
		||||
from .forms import (
 | 
			
		||||
@@ -172,6 +173,7 @@ def spacy_nlp_pipeline():
 | 
			
		||||
    if version not in service_manifest['versions']:
 | 
			
		||||
        abort(404)
 | 
			
		||||
    form = CreateSpacyNLPPipelineJobForm(prefix='create-job-form', version=version)
 | 
			
		||||
    spacy_nlp_pipeline_models = SpaCyNLPPipelineModel.query.all()
 | 
			
		||||
    if form.is_submitted():
 | 
			
		||||
        if not form.validate():
 | 
			
		||||
            response = {'errors': form.errors}
 | 
			
		||||
@@ -202,6 +204,7 @@ def spacy_nlp_pipeline():
 | 
			
		||||
    return render_template(
 | 
			
		||||
        'services/spacy_nlp_pipeline.html.j2',
 | 
			
		||||
        form=form,
 | 
			
		||||
        spacy_nlp_pipeline_models=spacy_nlp_pipeline_models,
 | 
			
		||||
        title=service_manifest['name']
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user