<commit_before># Python script to upgrade the content of an existing COG installation
import sys, os

sys.path.append( os.path.abspath(os.path.dirname('.')) )
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from cog.models import Project, create_upload_directory, Doc
from cog.models.logged_event import log_instance_event
from django.db.models.signals import post_save

print 'Upgrading COG'

for project in Project.objects.all():
    create_upload_directory(project)
    
# assign is_private=False to all documents
# must first disconnect the signal sent when saving a Doc object (to avoid spurious signals for all Docs)
post_save.disconnect(log_instance_event, sender=Doc, dispatch_uid="log_doc_event")
for doc in Doc.objects.all():
    print 'doc=%s' % doc
    if not doc.is_private:
        # explicitly assign
        doc.is_private = False
        doc.save()<commit_msg>Initializing path for existing documents.<commit_after># Python script to upgrade the content of an existing COG installation
import sys, os

sys.path.append( os.path.abspath(os.path.dirname('.')) )
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from cog.models import Project, create_upload_directory, Doc
from cog.models.logged_event import log_instance_event
from django.db.models.signals import post_save

print 'Upgrading COG'

for project in Project.objects.all():
    create_upload_directory(project)
    
# assign is_private=False to all documents
# must first disconnect the signal sent when saving a Doc object (to avoid spurious signals for all Docs)
post_save.disconnect(log_instance_event, sender=Doc, dispatch_uid="log_doc_event")
for doc in Doc.objects.all():
    print 'doc=%s' % doc
    if not doc.is_private:
        # explicitly assign
        doc.is_private = False
        doc.save()
    doc.path = doc.file.name
    doc.save()
    
{'fraction_non_alphanumeric': 0.08818726183995645, 'fraction_numerical': 0.0, 'mean_word_length': 4.454005934718101, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6017677', 'n_tokens_mistral': 555, 'n_tokens_neox': 552, 'n_words': 170}