Skip to content

Commit

Permalink
Merge pull request #754 from cortex-lab/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
oliche authored Sep 13, 2022
2 parents 25427b0 + 6357e7a commit d4fe648
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 5 deletions.
2 changes: 1 addition & 1 deletion alyx/alyx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.3.0'
__version__ = '1.4.0'
VERSION = __version__ # synonym
20 changes: 20 additions & 0 deletions alyx/jobs/migrations/0008_task_data_repository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.0.6 on 2022-09-13 16:06

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('data', '0012_alter_datasettype_filename_pattern_and_more'),
('jobs', '0007_remove_task_unique_task_name_per_session_and_more'),
]

operations = [
migrations.AddField(
model_name='task',
name='data_repository',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tasks', to='data.datarepository'),
),
]
2 changes: 2 additions & 0 deletions alyx/jobs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Task(models.Model):
symmetrical=False)
datetime = models.DateTimeField(auto_now=True)
arguments = models.JSONField(blank=True, null=True, help_text="dictionary of input arguments")
data_repository = models.ForeignKey('data.DataRepository', null=True, blank=True,
related_name='tasks', on_delete=models.CASCADE)

def __str__(self):
return self.name + ' ' + str(self.session) + ' ' + self.get_status_display()
Expand Down
5 changes: 5 additions & 0 deletions alyx/jobs/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rest_framework import serializers
from actions.models import Session
from jobs.models import Task
from data.models import DataRepository
from alyx.base import BaseSerializerEnumField


Expand All @@ -13,6 +14,10 @@ class TaskSerializer(serializers.ModelSerializer):
read_only=False, required=False, slug_field='id', many=False,
queryset=Session.objects.all()
)
data_repository = serializers.SlugRelatedField(
read_only=False, required=False, slug_field='name', many=False,
queryset=DataRepository.objects.all()
)
status = BaseSerializerEnumField(required=False)

class Meta:
Expand Down
34 changes: 34 additions & 0 deletions alyx/jobs/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from django.contrib.auth import get_user_model
from django.urls import reverse
from django.core.management import call_command

from actions.models import Session
from alyx.base import BaseTests
from data.models import DataRepository


class APISubjectsTests(BaseTests):

def setUp(self):
call_command('loaddata', 'experiments/fixtures/experiments.probemodel.json', verbosity=0)
call_command('loaddata', 'experiments/fixtures/experiments.brainregion.json', verbosity=0)
self.superuser = get_user_model().objects.create_superuser('test', 'test', 'test')
self.client.login(username='test', password='test')
self.session = Session.objects.first()
self.session.task_protocol = 'ephys'
self.session.save()
self.dict_insertion = {'session': str(self.session.id),
'name': 'probe_00',
'model': '3A'}
self.data_repository = DataRepository.objects.create(name='myrepo')

def test_brain_regions_rest_filter(self):
# test the custom filters get_descendants and get_ancestors
task_dict = {'executable': 'exec', 'priority': 90,
'io_charge': 40, 'gpu': 0, 'cpu': 1,
'ram': 40, 'module': 'mod', 'parents': [],
'level': 0, 'time_out_sec': 2, 'session': self.session.id,
'status': 'Waiting', 'log': None, 'name': 'mytask', 'graph': 'mygraph',
'arguments': {'titi': 'toto', 'tata': 'tutu'}, 'data_repository': 'myrepo'}
rep = self.post(reverse('tasks-list'), task_dict)
self.assertEqual(rep.status_code, 201)
8 changes: 4 additions & 4 deletions requirements_frozen.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
asgiref==3.5.2
backports.zoneinfo==0.2.1
boto3==1.24.66
botocore==1.27.66
certifi==2022.6.15
boto3==1.24.71
botocore==1.27.71
certifi==2022.6.15.1
cffi==1.15.1
charset-normalizer==2.1.1
click==8.1.3
Expand Down Expand Up @@ -49,7 +49,7 @@ MarkupSafe==2.1.1
matplotlib==3.5.3
mccabe==0.7.0
numba==0.56.2
numpy==1.23.2
numpy==1.23.3
ONE-api==1.14.0
packaging==21.3
pandas==1.4.4
Expand Down

0 comments on commit d4fe648

Please sign in to comment.