-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Generic object added to Dataset model * Migration file; nullable fields * force change to filename_pattern field (previous migration failed to apply correctly) * Fix migrations in tests * added subjectTrials fixture * Fix REST tests * timezone.utc -> datetime.utcnow * Fix test * bump version number * GitHub Actions generated requirements_frozen.txt * rephrase password differences explitely * GitHub Actions generated requirements_frozen.txt --------- Co-authored-by: Miles Wells <[email protected]> Co-authored-by: github-actions <[email protected]>
- Loading branch information
1 parent
661e137
commit a4e3787
Showing
13 changed files
with
203 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = __version__ = '1.8.0' | ||
VERSION = __version__ = '1.9.0' |
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
48 changes: 48 additions & 0 deletions
48
alyx/data/migrations/0013_dataset_content_type_dataset_object_id.py
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,48 @@ | ||
# Generated by Django 4.1.5 on 2023-01-31 12:34 | ||
|
||
from django.db import migrations, transaction, models | ||
import django.db.models.deletion | ||
|
||
|
||
def forwards(apps, _): | ||
"""Go through the datasets and assign the session field to the content_object field""" | ||
Dataset = apps.get_model('data', 'Dataset') | ||
with transaction.atomic(): | ||
for dataset in Dataset.objects.filter(session__isnull=False).iterator(): | ||
if dataset.content_object is None: | ||
dataset.content_object = dataset.session | ||
dataset.save() | ||
|
||
|
||
def backwards(apps, _): | ||
Dataset = apps.get_model('data', 'Dataset') | ||
with transaction.atomic(): | ||
for dataset in Dataset.objects.filter(session__isnull=False).iterator(): | ||
if dataset.content_object is not None: | ||
dataset.content_object = None | ||
dataset.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('contenttypes', '0002_remove_content_type_name'), | ||
('data', '0012_alter_datasettype_filename_pattern_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='dataset', | ||
name='content_type', | ||
field=models.ForeignKey(null=True, blank=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype'), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='dataset', | ||
name='object_id', | ||
field=models.UUIDField( | ||
null=True, blank=True, help_text='UUID, an object of content_type with this ID must already exist to attach a note.'), | ||
preserve_default=False, | ||
), | ||
# migrations.RunPython(forwards, backwards) | ||
] |
44 changes: 44 additions & 0 deletions
44
alyx/data/migrations/0014_alter_datasettype_filename_pattern.py
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,44 @@ | ||
# Generated by Django 4.1.5 on 2023-02-01 15:32 | ||
# NB: The previous migrations (0011 and 0012) somehow failed to set the filename_pattern field as | ||
# nullable. Migrations 0014 and 0015 reverse and remake this change which apparently fixed this | ||
# issue. | ||
|
||
import alyx.base | ||
from django.db import migrations, transaction | ||
|
||
PATTERN = '$$$' | ||
|
||
|
||
def fix_null_fields(apps, _): | ||
"""Populate null filename_pattern fields before making column not null""" | ||
DatasetType = apps.get_model('data', 'DatasetType') | ||
assert not DatasetType.objects.filter(filename_pattern__startswith=PATTERN).count() | ||
with transaction.atomic(): | ||
for dtype in DatasetType.objects.filter(filename_pattern__isnull=True).iterator(): | ||
dtype.filename_pattern = PATTERN + dtype.name | ||
dtype.save() | ||
|
||
|
||
def null_fields(apps, _): | ||
"""Reset previously null filename_pattern fields""" | ||
DatasetType = apps.get_model('data', 'DatasetType') | ||
with transaction.atomic(): | ||
for dtype in DatasetType.objects.filter(filename_pattern__startswith=PATTERN).iterator(): | ||
dtype.filename_pattern = None | ||
dtype.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('data', '0013_dataset_content_type_dataset_object_id'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(fix_null_fields, null_fields), | ||
migrations.AlterField( | ||
model_name='datasettype', | ||
name='filename_pattern', | ||
field=alyx.base.CharNullField(blank=True, help_text="File name pattern (with wildcards) for this file in ALF naming convention. E.g. 'spikes.times.*' or '*.timestamps.*', or 'spikes.*.*' for a DataCollection, which would include all files starting with the word 'spikes'. NB: Case-insensitive matching.If null, the name field must match the object.attribute part of the filename.", max_length=255, unique=True), | ||
), | ||
] |
44 changes: 44 additions & 0 deletions
44
alyx/data/migrations/0015_alter_datasettype_filename_pattern.py
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,44 @@ | ||
# Generated by Django 4.1.5 on 2023-02-01 15:33 | ||
# NB: The previous migrations (0011 and 0012) somehow failed to set the filname_pattern field as | ||
# nullable. Migrations 0014 and 0015 reverse and remake this change which apparently fixed this | ||
# issue. | ||
|
||
import alyx.base | ||
from django.db import migrations, transaction | ||
|
||
PATTERN = '$$$' | ||
|
||
|
||
def fix_null_fields(apps, _): | ||
"""Populate null filename_pattern fields before making column not null""" | ||
DatasetType = apps.get_model('data', 'DatasetType') | ||
assert not DatasetType.objects.filter(filename_pattern__startswith=PATTERN).count() | ||
with transaction.atomic(): | ||
for dtype in DatasetType.objects.filter(filename_pattern__isnull=True).iterator(): | ||
dtype.filename_pattern = PATTERN + dtype.name | ||
dtype.save() | ||
|
||
|
||
def null_fields(apps, _): | ||
"""Reset previously null filename_pattern fields""" | ||
DatasetType = apps.get_model('data', 'DatasetType') | ||
with transaction.atomic(): | ||
for dtype in DatasetType.objects.filter(filename_pattern__startswith=PATTERN).iterator(): | ||
dtype.filename_pattern = None | ||
dtype.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('data', '0014_alter_datasettype_filename_pattern'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='datasettype', | ||
name='filename_pattern', | ||
field=alyx.base.CharNullField(blank=True, help_text="File name pattern (with wildcards) for this file in ALF naming convention. E.g. 'spikes.times.*' or '*.timestamps.*', or 'spikes.*.*' for a DataCollection, which would include all files starting with the word 'spikes'. NB: Case-insensitive matching.If null, the name field must match the object.attribute part of the filename.", max_length=255, null=True, unique=True), | ||
), | ||
migrations.RunPython(null_fields, fix_null_fields), | ||
] |
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
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
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
Oops, something went wrong.