mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	added migration step to create initial classifier, silences consumption warnings
This commit is contained in:
		
							parent
							
								
									28ba634e6a
								
							
						
					
					
						commit
						ebac10bdfb
					
				@ -41,6 +41,21 @@ def restore_filenames(apps, schema_editor):
 | 
				
			|||||||
                pass
 | 
					                pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def initialize_document_classifier(apps, schema_editor):
 | 
				
			||||||
 | 
					    try:
 | 
				
			||||||
 | 
					        print("Initalizing document classifier...")
 | 
				
			||||||
 | 
					        from documents.classifier import DocumentClassifier
 | 
				
			||||||
 | 
					        classifier = DocumentClassifier()
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            classifier.train()
 | 
				
			||||||
 | 
					            classifier.save_classifier()
 | 
				
			||||||
 | 
					        except Exception as e:
 | 
				
			||||||
 | 
					            print("Classifier error: {}".format(e))
 | 
				
			||||||
 | 
					    except ImportError:
 | 
				
			||||||
 | 
					        print("Document classifier not found, skipping")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Migration(migrations.Migration):
 | 
					class Migration(migrations.Migration):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    dependencies = [
 | 
					    dependencies = [
 | 
				
			||||||
@ -50,6 +65,7 @@ class Migration(migrations.Migration):
 | 
				
			|||||||
    operations = [
 | 
					    operations = [
 | 
				
			||||||
        migrations.RunPython(make_index, migrations.RunPython.noop),
 | 
					        migrations.RunPython(make_index, migrations.RunPython.noop),
 | 
				
			||||||
        migrations.RunPython(restore_filenames),
 | 
					        migrations.RunPython(restore_filenames),
 | 
				
			||||||
 | 
					        migrations.RunPython(initialize_document_classifier, migrations.RunPython.noop),
 | 
				
			||||||
        migrations.RemoveField(
 | 
					        migrations.RemoveField(
 | 
				
			||||||
            model_name='document',
 | 
					            model_name='document',
 | 
				
			||||||
            name='filename',
 | 
					            name='filename',
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user