Repository: common-workflow-language/cwltool

Issue:
removal of warning due to updatable inputs feature
```
unrecognized extension field `http://commonwl.org/cwltool#generation`.  Did you include a $schemas section?
```
Very cool feature, but no need to print this warning

Presumably related to https://github.com/common-workflow-language/cwltool/pull/317 


Discussion:
Hi @mr-c  I am looking at this issue. This arises because here https://github.com/common-workflow-language/cwltool/blob/master/cwltool/draft2tool.py#L540 we are setting generation in the datum, and later validating the schema in line [547](https://github.com/common-workflow-language/cwltool/blob/master/cwltool/draft2tool.py#L547) In validation step this `generation` field is checked if it is present in `expected_scheme` [here](https://github.com/common-workflow-language/schema_salad/blob/master/schema_salad/validate.py#L293) and as it is not present in scheme it throws this warning.
I can think of two ways to solve this:
1. somehow add the `generation` field to the `expected_scheme`, so that it goes for validation and passes.
2. Add generation field to datum after validation is done so that this field never go for validation.
I tested second method and its working fine. Should we go with second method?
Let's try number 2, also we should filter it out of the output object
@mr-c  do you mean it should not be present in output like here
```
[jolb rev] completed success
[joyb rev] {
    "output": {
        "checksum": "sha1$97fe1b50b4582cebc7d853796ebd62e3e163aa3f", 
        "basename": "output.txt", 
        "nameext": ".txt", 
        "nameroot": "output", 
        "http://commonwl.org/cwltool#generation": 0, 
        "location": "file:///C:/users/kapilk%7E1/appdata/local/temp/tmpygovsh/output.txt", 
        "class": "File", 
        "size": 1111
    }
}
```
I asked this because the reason we are having this warning is that we are adding `generation` field while collecting output. In this case solution would simply be to avoid setting generation by removing these 2 lines here https://github.com/common-workflow-language/cwltool/blob/master/cwltool/draft2tool.py#L540 
Should we do this.
It should be removed from the final output object, the intermediate ones are fine for now.

Resolving patch:
diff --git a/cwltool/draft2tool.py b/cwltool/draft2tool.py
--- a/cwltool/draft2tool.py
+++ b/cwltool/draft2tool.py
@@ -534,8 +534,6 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True, jo
                 visit_class(ret, ("File", "Directory"), cast(Callable[[Any], Any], revmap))
                 visit_class(ret, ("File", "Directory"), remove_path)
                 normalizeFilesDirs(ret)
-                if builder.mutation_manager:
-                    adjustFileObjs(ret, builder.mutation_manager.set_generation)
                 visit_class(ret, ("File", "Directory"), partial(check_valid_locations, fs_access))
 
                 if compute_checksum:
@@ -543,6 +541,8 @@ def collect_output_ports(self, ports, builder, outdir, compute_checksum=True, jo
 
             validate.validate_ex(self.names.get_name("outputs_record_schema", ""), ret,
                                  strict=False, logger=_logger_validation_warnings)
+            if ret is not None and builder.mutation_manager is not None:
+                adjustFileObjs(ret, builder.mutation_manager.set_generation)
             return ret if ret is not None else {}
         except validate.ValidationException as e:
             raise WorkflowException("Error validating output record. " + Text(e) + "\n in " + json.dumps(ret, indent=4))
diff --git a/cwltool/main.py b/cwltool/main.py
--- a/cwltool/main.py
+++ b/cwltool/main.py
@@ -915,6 +915,9 @@ def locToPath(p):
 
                 visit_class(out, ("File", "Directory"), locToPath)
 
+                # Unsetting the Generation fron final output object
+                visit_class(out,("File",), MutationManager().unset_generation)
+
                 if isinstance(out, six.string_types):
                     stdout.write(out)
                 else:
diff --git a/cwltool/mutation.py b/cwltool/mutation.py
--- a/cwltool/mutation.py
+++ b/cwltool/mutation.py
@@ -67,3 +67,7 @@ def set_generation(self, obj):
         loc = obj["location"]
         current = self.generations.get(loc, MutationState(0,[], ""))
         obj[_generation] = current.generation
+
+    def unset_generation(self, obj):
+        # type: (Dict) -> None
+        obj.pop(_generation, None)


Test patch: