Skip to content

Commit

Permalink
Remove debug print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
reisingerf committed Oct 11, 2024
1 parent fd3f2a3 commit 0fd10f1
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ def retrieve(self, request, *args, **kwargs):
Since we have custom orcabus_id prefix for each model, we need to remove the prefix before retrieving it.
"""
pk = self.kwargs.get('pk')
print("DEBUG: pk")
print(pk)
if pk and pk.startswith(self.orcabus_id_prefix):
pk = pk[len(self.orcabus_id_prefix):]

print("DEBUG: self.queryset")
print(self.queryset)
print(self.get_queryset())
obj = get_object_or_404(self.get_queryset(), pk=pk)
serializer = self.serializer_class(obj)
return Response(serializer.data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ def list(self, request, *args, **kwargs):

def get_queryset(self):
query_params = self.get_query_params()
print("DEBUG: query_params")
print(query_params)
return Payload.objects.get_by_keyword(self.queryset, **query_params)
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ def exclude_params(params):
def ongoing(self, request):
self.serializer_class = WorkflowRunSerializer # use simple view for record listing
# Get all books marked as favorite
print(request)
print(self.request.query_params)
ordering = self.request.query_params.get('ordering', '-orcabus_id')

if "status" in self.request.query_params.keys():
print("found status!")
status = self.request.query_params.get('status')
result_set = WorkflowRun.objects.get_by_keyword(states__status=status).order_by(ordering)
else:
Expand All @@ -126,8 +123,6 @@ def ongoing(self, request):
@action(detail=False, methods=['GET'])
def unresolved(self, request):
# Get all books marked as favorite
print(request)
print(self.request.query_params)
ordering = self.request.query_params.get('ordering', '-id')

result_set = WorkflowRun.objects.get_by_keyword(states__status="FAILED").order_by(ordering)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import workflow_manager_proc.domain.executionservice.workflowrunstatechange as srv
import workflow_manager_proc.domain.workflowmanager.workflowrunstatechange as wfm
from workflow_manager_proc.services import emit_workflow_run_state_change, create_workflow_run_state
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

def handler(event, context):
"""
Expand All @@ -18,7 +21,7 @@ def handler(event, context):
- create new State for WorkflowRun if required
- relay the state change as WorkflowManager WRSC event if applicable
"""
print(f"Processing {event}, {context}")
logger.info(f"Processing {event}, {context}")

# remove the AWSEvent wrapper from our WRSC event
input_event: srv.AWSEvent = srv.Marshaller.unmarshall(event, srv.AWSEvent)
Expand All @@ -28,10 +31,10 @@ def handler(event, context):
out_wrsc = create_workflow_run_state.handler(srv.Marshaller.marshall(input_wrsc), None)
if out_wrsc:
# new state resulted in state transition, we can relay the WRSC
print("Emitting WRSC.")
logger.info("Emitting WRSC.")
emit_workflow_run_state_change.handler(wfm.Marshaller.marshall(out_wrsc), None)
else:
# ignore - state has not been updated
print(f"WorkflowRun state not updated. No event to emit.")
logger.info(f"WorkflowRun state not updated. No event to emit.")

print(f"{__name__} done.")
logger.info(f"{__name__} done.")
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
from workflow_manager.models.workflow_run import WorkflowRun
import workflow_manager_proc.domain.executionservice.workflowrunstatechange as srv
import workflow_manager_proc.domain.workflowmanager.workflowrunstatechange as wfm
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


def handler(event, context):
"""event will be a workflowmanager.WorkflowRunStateChange event"""
print(f"Processing {event}, {context}")
logger.info(f"Processing {event}, {context}")

input_event: wfm.AWSEvent = wfm.Marshaller.unmarshall(event, wfm.AWSEvent)
input_wrsc: wfm.WorkflowRunStateChange = input_event.detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from typing import List

from workflow_manager.models import Analysis, AnalysisRun, AnalysisContext, Library
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

# TODO: get list of libraries (+ required metadata) from list of library IDs
# TODO: switch pairing based on subject to pairing based on Case (creating a case is someone else's responsibility)
Expand Down Expand Up @@ -73,7 +76,7 @@ def create_wgs_analysis(libraries: List[dict]) -> List[AnalysisRun]:
normal_lib_record: Library = Library.objects.get(library_id=pairing[sbj]['normal'][0]['library_id'])

if not tumor_lib_record or not normal_lib_record:
print("Not a valid pairing.")
logger.info("Not a valid pairing.")
break

workflow = pairing[sbj]['tumor'][0]['workflow']
Expand All @@ -92,7 +95,7 @@ def create_wgs_analysis(libraries: List[dict]) -> List[AnalysisRun]:
ar_wgs.libraries.add(normal_lib_record)
analysis_runs.append(ar_wgs)
else:
print(f"No pairing for {sbj}.")
logger.info(f"No pairing for {sbj}.")

return analysis_runs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import json
import workflow_manager_proc.domain.workflowmanager.workflowrunstatechange as wfm
from workflow_manager_proc.domain.workflowmanager.workflowrunstatechange import WorkflowRunStateChange
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

client = boto3.client('events')
source = "orcabus.workflowmanager"
Expand All @@ -13,7 +17,7 @@ def handler(event, context):
"""
event has to be JSON conform to workflowmanager.WorkflowRunStateChange
"""
print(f"Processing {event}, {context}")
logger.info(f"Processing {event}, {context}")

response = client.put_events(
Entries=[
Expand All @@ -26,7 +30,7 @@ def handler(event, context):
],
)

print(f"Sent a WRSC event to event bus {event_bus_name}:")
print(event)
print(f"{__name__} done.")
logger.info(f"Sent a WRSC event to event bus {event_bus_name}:")
logger.info(event)
logger.info(f"{__name__} done.")
return response
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,5 @@ def test_get_last_state(self):
t1 = s1.timestamp
t2 = s2.timestamp
delta = t1 - t2 # = 2 days
print(f"delta sec: {abs(delta.total_seconds())}")
window = timedelta(hours=1)
print(f"window sec: {window.total_seconds()}")
self.assertTrue(delta > window, "delta > 1h")

0 comments on commit 0fd10f1

Please sign in to comment.