Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error improvements #587

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

error improvements #587

wants to merge 6 commits into from

Conversation

mr-c
Copy link
Member

@mr-c mr-c commented Nov 16, 2023

  • address some deprecations
  • detect non-Workflow CWL documents and give a better error message

Description

When the use provides a path to a CWL document that is not class: Workflow or a $graph containing a class: Workflow, we need a better error message than Error: The workflow could not be found within the repository

Motivation and Context

Fixes #582

How Has This Been Tested?

I tested locally with the provided Git repository URL, branch, and path in the original issue.

Screenshots (if appropriate):

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@mr-c
Copy link
Member Author

mr-c commented Nov 16, 2023

@kinow Could you add a test? I'm not familiar with the testing framework

@mr-c mr-c force-pushed the error_improvements branch 2 times, most recently from b21c655 to d4b2d3e Compare November 16, 2023 17:42
@kinow
Copy link
Member

kinow commented Nov 16, 2023

@kinow Could you add a test? I'm not familiar with the testing framework

Sorry, saw this comment before approving. Let me take a look…

found = true;
} else if (found && (extractProcess(cwlFile) != CWLProcess.WORKFLOW)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, @mr-c. I tried writing a unit test for this, but I couldn't make the service to reach this line. The found starts as false. And unless it's set before, it will not enter this else if block.

To make it eval to true, I packed the CommandLineTool,

cwlVersion: v1.2
$graph:
- id: echo
  class: CommandLineTool
  baseCommand: echo
  inputs: []
  outputs: []

but that still results in false since the code above already checks if it is a packed workflow, and only sets found to true in that case.

Did you reach this part of the code testing with the application running?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with

cwlVersion: v1.2

# What type of CWL process we have in this document.
class: CommandLineTool

label: Process DL0 to DL3

doc: >
    This tool (must become a workflow) 
    processes DL0 to DL3 simulated data.

baseCommand: echo

inputs:
    metadata_queue:
        type: File
        inputBinding: 
            prefix: --metadata-queue
            position: 1
    
outputs:
    dl3:
        type: File[]
        outputBinding:
            glob: '*.txt'
    dl3_metadata:
        type: stdout
    irfs:
        type: File[]
        outputBinding:
            glob: '*.txt'
    irfs_metadata:
        type: stdout

stdout: output.txt

And it still couldn't reach that part of the code. Here's the test:

diff --git a/src/test/java/org/commonwl/view/cwl/CWLServiceTest.java b/src/test/java/org/commonwl/view/cwl/CWLServiceTest.java
index 384fcd4..fe6993d 100644
--- a/src/test/java/org/commonwl/view/cwl/CWLServiceTest.java
+++ b/src/test/java/org/commonwl/view/cwl/CWLServiceTest.java
@@ -442,4 +442,24 @@ public class CWLServiceTest {
       assertEquals(CWLProcess.COMMANDLINETOOL, steps.get("lobSTR").getRunType());
     }
   }
+
+  @Test
+  public void testExceptionRaisedForCommandLineTool() {
+    Exception thrown =
+            Assertions.assertThrows(
+                    CWLNotAWorkflowException.class,
+                    () -> {
+                      CWLService cwlService =
+                              new CWLService(
+                                      Mockito.mock(RDFService.class),
+                                      Mockito.mock(CWLTool.class),
+                                      Mockito.mock(GitConfig.class).licenseVocab(),
+                                      999999);
+                      cwlService.parseWorkflowNative(
+                              Paths.get("src/test/resources/cwl/invalid_is_a_packed_command_line.cwl"), "");
+                    });
+    assertEquals(
+            "File 'lobSTR-workflow.cwl' is over singleFileSizeLimit - 2 KB/0 bytes",
+            thrown.getMessage());
+  }
 }

Just create the CWL file at src/test/resources/cwl/invalid_is_a_packed_command_line.cwl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(WIP test, I copied another test and was modifying it, slowly altering and re-running it)

@kinow
Copy link
Member

kinow commented Jun 8, 2024

(Clicked on Update branch -- forgot to check if there was an option to rebase...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need better error message when a CommandLineTool is submitted
2 participants