mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-10-31 02:32:45 +00:00 
			
		
		
		
	Add create corpus form to dashboard.
This commit is contained in:
		| @@ -18,32 +18,29 @@ def ocr(): | ||||
|         id = hashlib.md5( | ||||
|             (current_user.username + '_' + datetime.now().isoformat()).encode() | ||||
|         ).hexdigest() | ||||
|         ''' | ||||
|         ' TODO: Implement a Job class. For now a dictionary representation | ||||
|         '       is enough. | ||||
|         ''' | ||||
|         job = {'creator': current_user.id, | ||||
|                'id': id, | ||||
|                'requested_cpus': 2, | ||||
|                'requested_memory': 2048, | ||||
|                'service': 'ocr', | ||||
|                'service_args': {'lang': ocr_job_form.language.data, | ||||
|                                 'version': 'latest' | ||||
|                                 }, | ||||
|                'status': 'queued' | ||||
|                } | ||||
|         dir = os.path.join(app.config['OPAQUE_FILES'], 'jobs', id) | ||||
|  | ||||
|         try: | ||||
|             os.mkdir(dir) | ||||
|         except FileExistsError: | ||||
|             # Possible MD5 hash collision occurred. | ||||
|             flash('Internal error occurred, please try again!') | ||||
|             os.makedirs(dir) | ||||
|         except OSError: | ||||
|             flash('OSError!') | ||||
|         else: | ||||
|             file = ocr_job_form.file.data | ||||
|             file.save(os.path.join(dir, file.filename)) | ||||
|  | ||||
|             ''' | ||||
|             ' TODO: Implement a Job class. For now a dictionary representation | ||||
|             '       is enough. | ||||
|             ''' | ||||
|             job = {'worker': None, | ||||
|                    'creator': current_user.id, | ||||
|                    'id': id, | ||||
|                    'requested_cpus': 2, | ||||
|                    'requested_memory': 2048, | ||||
|                    'service': 'ocr', | ||||
|                    'service_args': {'lang': ocr_job_form.language.data, | ||||
|                                     'version': 'latest' | ||||
|                                     }, | ||||
|                    'status': 'queued' | ||||
|                    } | ||||
|             ''' | ||||
|             ' TODO: Let the scheduler run this job in the background. | ||||
|             ' | ||||
| @@ -52,6 +49,7 @@ def ocr(): | ||||
|             ''' | ||||
|             thread = Thread(target=swarm.run, args=(job,)) | ||||
|             thread.start() | ||||
|             flash('Job created!') | ||||
|         return redirect(url_for('services.ocr')) | ||||
|  | ||||
|     return render_template( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user