Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
fix breadcrumbes in file path to organize results and logs by run
Browse files Browse the repository at this point in the history
  • Loading branch information
nhammond committed Aug 17, 2017
1 parent 6d33ef2 commit 2b58970
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 1 addition & 2 deletions loomengine/master/api/models/data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def initialize(cls, **kwargs):
kwargs.get('filename'),
kwargs.get('source_type'),
kwargs.get('data_object'),
kwargs.get('task_attempt')
kwargs.pop('task_attempt', None)
))
file_resource = cls(**kwargs)
return file_resource
Expand Down Expand Up @@ -232,7 +232,6 @@ def _get_breadcrumbs(cls, source_type, data_object, task_attempt):
"""Create a path for a given file, in such a way
that files end up being organized and browsable by run
"""

# We cannot generate the path unless connect to a TaskAttempt
# and a run
if not task_attempt:
Expand Down
3 changes: 2 additions & 1 deletion loomengine/master/api/serializers/data_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def update(self, instance, validated_data):
raise serializers.ValidationError('Update to existing data not allowed')
data_node_serializer = DataNodeSerializer(
data=data,
context = {'type': instance.type})
context = {'type': instance.type,
'task_attempt': instance.task_attempt})
data_node_serializer.is_valid(raise_exception=True)
data_node = data_node_serializer.save()
instance.setattrs_and_save_with_retries({
Expand Down
11 changes: 9 additions & 2 deletions loomengine/master/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,12 @@ def get_queryset(self):
serializer_class=rest_framework.serializers.Serializer)
def create_data_object(self, request, uuid=None):
try:
task_attempt_log_file = models.TaskAttemptLogFile.objects.get(uuid=uuid)
task_attempt_log_file = models\
.TaskAttemptLogFile\
.objects\
.select_related('task_attempt')\
.select_related('data_object')\
.get(uuid=uuid)
except ObjectDoesNotExist:
raise rest_framework.exceptions.NotFound()
if task_attempt_log_file.data_object:
Expand All @@ -568,7 +573,9 @@ def create_data_object(self, request, uuid=None):
s = serializers.DataObjectSerializer(
task_attempt_log_file.data_object, data=data, context={
'request': request,
'task_attempt_log_file': task_attempt_log_file})
'task_attempt_log_file': task_attempt_log_file,
'task_attempt': task_attempt_log_file.task_attempt,
})
s.is_valid(raise_exception=True)
data_object = s.save()
return JsonResponse(s.data, status=201)
Expand Down

0 comments on commit 2b58970

Please sign in to comment.