-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #284 from Ilhasoft/feature/refact_botdata
Refact bot_data, sending file to aws s3
- Loading branch information
Showing
10 changed files
with
159 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 2.1.5 on 2019-09-02 14:55 | ||
|
||
from django.db import migrations, models | ||
from bothub.utils import send_bot_data_file_aws | ||
from bothub.common.models import RepositoryUpdate | ||
|
||
|
||
def update_repository(apps, schema_editor): | ||
for update in RepositoryUpdate.objects.all().exclude(bot_data__exact=''): | ||
url = send_bot_data_file_aws(update.pk, update.bot_data) | ||
repository_update = RepositoryUpdate.objects.get(pk=update.pk) | ||
repository_update.bot_data = url | ||
repository_update.save( | ||
update_fields=[ | ||
'bot_data', | ||
]) | ||
print('Updating bot_data repository_update {}'.format(str(update.pk))) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('common', '0034_repository_nlp_server'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_repository), | ||
migrations.AlterField( | ||
model_name='repositoryupdate', | ||
name='bot_data', | ||
field=models.URLField(blank=True, verbose_name='bot data'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
from django.shortcuts import get_object_or_404 | ||
from django.http import HttpResponse | ||
from django.http import HttpResponseRedirect | ||
from django.core.exceptions import ValidationError | ||
from django.contrib.admin.views.decorators import staff_member_required | ||
from .models import RepositoryUpdate | ||
|
||
|
||
@staff_member_required | ||
def download_bot_data(self, update_id): # pragma: no cover | ||
update = get_object_or_404(RepositoryUpdate, id=update_id) | ||
update = get_object_or_404(RepositoryUpdate, pk=update_id) | ||
if not update.trained_at: | ||
raise ValidationError('Update #{} not trained at.'.format(update.id)) | ||
response = HttpResponse( | ||
update.get_bot_data(), | ||
content_type='application/gzip') | ||
response['Content-Disposition'] = 'inline; filename={}.tar.gz'.format( | ||
update.id) | ||
raise ValidationError(f'Update #{update.pk} not trained at.') | ||
response = HttpResponseRedirect(update.get_bot_data()) | ||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters