mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-22 20:58:28 +00:00
Merge branch 'feature/spec_files_wthout_db' of github.com:sartography/cr-connect-workflow into feature/spec_files_wthout_db
This commit is contained in:
commit
1d7ecad51f
@ -9,7 +9,6 @@ from crc.models.study import StudyModel, WorkflowMetadata, StudyStatus
|
||||
from crc.models.task_event import TaskEventModel, TaskEvent, TaskEventSchema
|
||||
from crc.models.task_log import TaskLogModelSchema, TaskLogQuery, TaskLogQuerySchema
|
||||
from crc.models.workflow import WorkflowModel
|
||||
from crc.services import workflow_spec_service
|
||||
from crc.services.error_service import ValidationErrorService
|
||||
from crc.services.lookup_service import LookupService
|
||||
from crc.services.spec_file_service import SpecFileService
|
||||
@ -20,20 +19,20 @@ from crc.services.workflow_processor import WorkflowProcessor
|
||||
from crc.services.workflow_service import WorkflowService
|
||||
from crc.services.workflow_spec_service import WorkflowSpecService
|
||||
|
||||
workflow_spec_service = WorkflowSpecService()
|
||||
spec_service = WorkflowSpecService()
|
||||
|
||||
def all_specifications(libraries=False,standalone=False):
|
||||
if libraries and standalone:
|
||||
raise ApiError('inconceivable!', 'You should specify libraries or standalone, but not both')
|
||||
|
||||
if libraries:
|
||||
return workflow_spec_service.get_libraries()
|
||||
return spec_service.get_libraries()
|
||||
|
||||
if standalone:
|
||||
return workflow_spec_service.get_standalones()
|
||||
return spec_service.get_standalones()
|
||||
|
||||
# return standard workflows (not library, not standalone)
|
||||
categories = workflow_spec_service.get_categories()
|
||||
categories = spec_service.get_categories()
|
||||
workflows = []
|
||||
for cat in categories:
|
||||
workflows.extend(cat.workflows)
|
||||
@ -49,14 +48,14 @@ def add_workflow_specification(body):
|
||||
if body['library'] is True or body['standalone'] is True:
|
||||
body['category_id'] = None
|
||||
|
||||
new_spec = workflow_spec_service.add_spec(body)
|
||||
new_spec = spec_service.add_spec(body)
|
||||
return new_spec
|
||||
|
||||
|
||||
def get_workflow_specification(spec_id):
|
||||
if spec_id is None:
|
||||
raise ApiError('unknown_spec', 'Please provide a valid Workflow Specification ID.')
|
||||
spec = workflow_spec_service.get_spec(spec_id)
|
||||
spec = spec_service.get_spec(spec_id)
|
||||
|
||||
if spec is None:
|
||||
raise ApiError('unknown_spec', 'The Workflow Specification "' + spec_id + '" is not recognized.')
|
||||
@ -69,8 +68,8 @@ def validate_spec_and_library(spec_id,library_id):
|
||||
if library_id is None:
|
||||
raise ApiError('unknown_spec', 'Please provide a valid Library Specification ID.')
|
||||
|
||||
spec = workflow_spec_service.get_spec(spec_id)
|
||||
library = workflow_spec_service.get_library(library_id);
|
||||
spec = spec_service.get_spec(spec_id)
|
||||
library = spec_service.get_library(library_id);
|
||||
if spec is None:
|
||||
raise ApiError('unknown_spec', 'The Workflow Specification "' + spec_id + '" is not recognized.')
|
||||
if library is None:
|
||||
@ -81,27 +80,27 @@ def validate_spec_and_library(spec_id,library_id):
|
||||
|
||||
def add_workflow_spec_library(spec_id, library_id):
|
||||
validate_spec_and_library(spec_id, library_id)
|
||||
libraries: workflow_spec_service.get_libraries()
|
||||
libraries: spec_service.get_libraries()
|
||||
libraryids = [x.library_spec_id for x in libraries]
|
||||
if library_id in libraryids:
|
||||
raise ApiError('unknown_spec', 'The Library Specification "' + library_id + '" is already attached.')
|
||||
|
||||
spec = workflow_spec_service.get_spec(spec_id)
|
||||
library = workflow_spec_service.get_spec(library_id)
|
||||
spec = spec_service.get_spec(spec_id)
|
||||
library = spec_service.get_spec(library_id)
|
||||
spec.libraries.push(library)
|
||||
workflow_spec_service.update_spec(spec_id)
|
||||
spec_service.update_spec(spec_id)
|
||||
return spec
|
||||
|
||||
|
||||
def drop_workflow_spec_library(spec_id, library_id):
|
||||
validate_spec_and_library(spec_id, library_id)
|
||||
spec = workflow_spec_service.get_spec(spec_id)
|
||||
spec = spec_service.get_spec(spec_id)
|
||||
|
||||
# heres a piece of code that certainly wont work
|
||||
library = workflow_spec_service.get_spec(library_id)
|
||||
library = spec_service.get_spec(library_id)
|
||||
if library in spec.libraries:
|
||||
spec.libraries.pop(library)
|
||||
workflow_spec_service.update_spec(spec_id)
|
||||
spec_service.update_spec(spec_id)
|
||||
return spec
|
||||
|
||||
|
||||
@ -120,7 +119,7 @@ def validate_workflow_specification(spec_id, study_id=None, test_until=None):
|
||||
def update_workflow_specification(spec_id, body):
|
||||
if spec_id is None:
|
||||
raise ApiError('unknown_spec', 'Please provide a valid Workflow Spec ID.')
|
||||
spec = workflow_spec_service.get_spec(spec_id)
|
||||
spec = spec_service.get_spec(spec_id)
|
||||
|
||||
if spec is None:
|
||||
raise ApiError('unknown_study', 'The spec "' + spec_id + '" is not recognized.')
|
||||
@ -133,7 +132,7 @@ def update_workflow_specification(spec_id, body):
|
||||
if body['library'] is True or body['standalone'] is True:
|
||||
body['category_id'] = None
|
||||
|
||||
spec = workflow_spec_service.update_spec(spec_id, body)
|
||||
spec = spec_service.update_spec(spec_id, body)
|
||||
return spec
|
||||
|
||||
|
||||
@ -141,7 +140,7 @@ def delete_workflow_specification(spec_id):
|
||||
if spec_id is None:
|
||||
raise ApiError('unknown_spec', 'Please provide a valid Workflow Specification ID.')
|
||||
|
||||
spec = workflow_spec_service.get_spec(spec_id)
|
||||
spec = spec_service.get_spec(spec_id)
|
||||
|
||||
if spec is None:
|
||||
raise ApiError('unknown_spec', 'The Workflow Specification "' + spec_id + '" is not recognized.')
|
||||
@ -157,7 +156,7 @@ def delete_workflow_specification(spec_id):
|
||||
WorkflowService.delete_workflow_spec_task_events(spec_id)
|
||||
|
||||
# .delete() doesn't work when we need a cascade. Must grab the record, and explicitly delete
|
||||
workflow_spec_service.delete_spec(spec_id)
|
||||
spec_service.delete_spec(spec_id)
|
||||
|
||||
# Reorder the remaining specs
|
||||
WorkflowService.cleanup_workflow_spec_display_order(spec.category_id)
|
||||
@ -167,9 +166,9 @@ def reorder_workflow_specification(spec_id, direction):
|
||||
if direction not in ('up', 'down'):
|
||||
raise ApiError(code='bad_direction',
|
||||
message='The direction must be `up` or `down`.')
|
||||
spec = workflow_spec_service.get_spec(spec_id)
|
||||
spec = spec_service.get_spec(spec_id)
|
||||
if spec:
|
||||
ordered_specs = workflow_spec_service.reorder_spec(spec, direction)
|
||||
ordered_specs = spec_service.reorder_spec(spec, direction)
|
||||
else:
|
||||
raise ApiError(code='bad_spec_id',
|
||||
message=f'The spec_id {spec_id} did not return a specification. Please check that it is valid.')
|
||||
@ -323,22 +322,22 @@ def __update_task(processor, task, data, user):
|
||||
|
||||
|
||||
def list_workflow_spec_categories():
|
||||
return workflow_spec_service.get_workflow_categories()
|
||||
return spec_service.get_categories()
|
||||
|
||||
|
||||
def get_workflow_spec_category(cat_id):
|
||||
return workflow_spec_service.get_workflow_category(cat_id)
|
||||
return spec_service.get_category(cat_id)
|
||||
|
||||
|
||||
def add_workflow_spec_category(body):
|
||||
return workflow_spec_service.add_category(body)
|
||||
return spec_service.add_category(body)
|
||||
|
||||
|
||||
def update_workflow_spec_category(cat_id, body):
|
||||
if cat_id is None:
|
||||
raise ApiError('unknown_category', 'Please provide a valid Workflow Spec Category ID.')
|
||||
|
||||
category = workflow_spec_service.update_category(cat_id, body)
|
||||
category = spec_service.update_category(cat_id, body)
|
||||
|
||||
if category is None:
|
||||
raise ApiError('unknown_category', 'The category "' + cat_id + '" is not recognized.')
|
||||
@ -351,7 +350,7 @@ def update_workflow_spec_category(cat_id, body):
|
||||
|
||||
|
||||
def delete_workflow_spec_category(cat_id):
|
||||
workflow_spec_service.delete_category(cat_id)
|
||||
spec_service.delete_category(cat_id)
|
||||
|
||||
|
||||
def reorder_workflow_spec_category(cat_id, direction):
|
||||
@ -359,9 +358,9 @@ def reorder_workflow_spec_category(cat_id, direction):
|
||||
raise ApiError(code='bad_direction',
|
||||
message='The direction must be `up` or `down`.')
|
||||
WorkflowService.cleanup_workflow_spec_category_display_order()
|
||||
category = workflow_spec_service.get_category(cat_id)
|
||||
category = spec_service.get_category(cat_id)
|
||||
if category:
|
||||
ordered_categories = workflow_spec_service.reorder_workflow_spec_category(category, direction)
|
||||
ordered_categories = spec_service.reorder_workflow_spec_category(category, direction)
|
||||
return ordered_categories
|
||||
else:
|
||||
raise ApiError(code='bad_category_id',
|
||||
|
@ -78,9 +78,6 @@ class WorkflowSpecService(FileSystemService):
|
||||
spec_list.sort(key=lambda w: w.display_order)
|
||||
return spec_list
|
||||
|
||||
def get_standalones(self) -> List[WorkflowSpecInfo]:
|
||||
pass
|
||||
|
||||
def get_categories(self) -> List[WorkflowSpecCategory]:
|
||||
"""Returns the categories as a list in display order"""
|
||||
cat_list = list(self.categories.values())
|
||||
|
Loading…
x
Reference in New Issue
Block a user