Skip to content

Commit

Permalink
Merge pull request #684 from neuroscout/add-nc-to-full
Browse files Browse the repository at this point in the history
Show NV collections in full analysis route
  • Loading branch information
adelavega committed Nov 8, 2019
2 parents d9bce50 + f451adc commit fba6542
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
2 changes: 2 additions & 0 deletions neuroscout/models/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Analysis(db.Model):
predictors = db.relationship('Predictor', secondary=analysis_predictor,
backref='analysis')
runs = db.relationship('Run', secondary='analysis_run')
neurovault_collections = db.relationship(
'NeurovaultCollection')

@hybrid_property
def task_name(self):
Expand Down
6 changes: 3 additions & 3 deletions neuroscout/resources/analysis/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ...database import db
from ...worker import celery_app
from ...schemas.analysis import (
ReportSchema, AnalysisCompiledSchema, NeurovaultCollectionSchema)
ReportSchema, AnalysisCompiledSchema, NeurovaultCollectionSchemaStatus)
from ...utils.db import put_record
from ..utils import owner_required, abort, fetch_analysis
from ...api_spec import FileField
Expand Down Expand Up @@ -158,7 +158,7 @@ def _create_collection(analysis, force=False):
class AnalysisUploadResource(MethodResource):
@doc(summary='Upload fitlins analysis results. ',
consumes=['multipart/form-data', 'application/x-www-form-urlencoded'])
@marshal_with(NeurovaultCollectionSchema)
@marshal_with(NeurovaultCollectionSchemaStatus)
@use_kwargs({
"validation_hash": wa.fields.Str(required=True),
"image_file": FileField(required=False),
Expand Down Expand Up @@ -209,7 +209,7 @@ def post(self, analysis, validation_hash, collection_id=None,

return upload

@marshal_with(NeurovaultCollectionSchema(many=True))
@marshal_with(NeurovaultCollectionSchemaStatus(many=True))
@doc(summary='Get uploads for analyses.')
@fetch_analysis
def get(self, analysis):
Expand Down
49 changes: 28 additions & 21 deletions neuroscout/schemas/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,6 @@ class Meta:
strict = True


class AnalysisFullSchema(AnalysisSchema):
""" Analysis schema, with additional nested fields """
runs = fields.Nested(
RunSchema, many=True, description='Runs associated with analysis',
exclude=['dataset_id', 'task'], dump_only=True)

predictors = fields.Nested(
PredictorSchema, many=True, only=['id', 'name'],
description='Predictor id(s) associated with analysis', dump_only=True)


class AnalysisResourcesSchema(Schema):
""" Schema for Analysis resources. """
preproc_address = fields.Nested(
Expand All @@ -120,15 +109,6 @@ class AnalysisCompiledSchema(Schema):
description='Traceback of compilation error.')


class ReportSchema(Schema):
""" Schema for report results """
generated_at = fields.Time(description='Time report was generated')
result = fields.Dict(description='Links to report resources')
status = fields.Str(description='Report status')
traceback = fields.Str(
description='Traceback of generation error.')


class NeurovaultFileUploadSchema(Schema):
level = fields.Str(
description='Image analysis level'
Expand All @@ -140,13 +120,40 @@ class NeurovaultFileUploadSchema(Schema):

class NeurovaultCollectionSchema(Schema):
""" Schema for report results """
uploaded_at = fields.Time(description='Time collectio was created')
uploaded_at = fields.Time(description='Time collections was created')
collection_id = fields.Dict(description='NeuroVault collection id')


class NeurovaultCollectionSchemaStatus(NeurovaultCollectionSchema):
files = fields.Nested(
NeurovaultFileUploadSchema, many=True)


class AnalysisFullSchema(AnalysisSchema):
""" Analysis schema, with additional nested fields """
runs = fields.Nested(
RunSchema, many=True, description='Runs associated with analysis',
exclude=['dataset_id', 'task'], dump_only=True)

predictors = fields.Nested(
PredictorSchema, many=True, only=['id', 'name'],
description='Predictor id(s) associated with analysis', dump_only=True)

neurovault_collections = fields.Nested(
NeurovaultCollectionSchema, many=True,
description="Neurovault Collections of analysis results"
)


class ReportSchema(Schema):
""" Schema for report results """
generated_at = fields.Time(description='Time report was generated')
result = fields.Dict(description='Links to report resources')
status = fields.Str(description='Report status')
traceback = fields.Str(
description='Traceback of generation error.')


class BibliographySchema(Schema):
""" Schema for analysis bibliographies """
tools = fields.List(
Expand Down

0 comments on commit fba6542

Please sign in to comment.