Merge branch '2411-check-copyright'
authorTom Clegg <tom@curoverse.com>
Thu, 29 Jun 2017 11:51:32 +0000 (07:51 -0400)
committerTom Clegg <tom@curoverse.com>
Thu, 29 Jun 2017 11:51:32 +0000 (07:51 -0400)
refs #2411

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curoverse.com>

1  2 
doc/user/cwl/cwl-extensions.html.textile.liquid
sdk/cwl/arvados_cwl/__init__.py
sdk/cwl/arvados_cwl/arv-cwl-schema.yml
sdk/cwl/arvados_cwl/arvcontainer.py
sdk/cwl/arvados_cwl/arvjob.py
sdk/cwl/tests/arvados-tests.yml
sdk/cwl/tests/test_container.py
sdk/cwl/tests/test_job.py

index 0ba104567075a93bac4992eab503d6ad322b94cc,8e224f0305455a9f5eda3720d9aa71f399830030..95422b6bd32206019a8703e8a94a6c57735b92dd
@@@ -3,6 -3,11 +3,11 @@@ layout: defaul
  navsection: userguide
  title: Arvados CWL Extensions
  ...
+ {% comment %}
+ Copyright (C) The Arvados Authors. All rights reserved.
+ SPDX-License-Identifier: CC-BY-SA-3.0
+ {% endcomment %}
  
  Arvados provides several extensions to CWL for workflow optimization, site-specific configuration, and to enable access the Arvados API.
  
@@@ -14,7 -19,7 +19,7 @@@ $namespaces
    cwltool: "http://commonwl.org/cwltool#"
  </pre>
  
 -Arvados extensions should go into the @hints@ section, for example:
 +For portability, Arvados extensions should go into the @hints@ section of your CWL file, for example:
  
  <pre>
  hints:
      loadListing: shallow_listing
    arv:IntermediateOutput:
      outputTTL: 3600
 +  arv:ReuseRequirement:
 +    enableReuse: false
  </pre>
  
 +The one exception to this is @arv:APIRequirement@, see note below.
 +
  h2. arv:RunInSingleContainer
  
  Indicates that a subworkflow should run in a single container and not be scheduled as separate steps.
@@@ -88,11 -89,3 +93,11 @@@ table(table table-bordered table-conden
  |_. Field |_. Type |_. Description |
  |outputTTL|int|If the value is greater than zero, consider intermediate output collections to be temporary and should be automatically trashed. Temporary collections will be trashed @outputTTL@ seconds after creation.  A value of zero means intermediate output should be retained indefinitely (this is the default behavior).
  Note: arvados-cwl-runner currently does not take workflow dependencies into account when setting the TTL on an intermediate output collection. If the TTL is too short, it is possible for a collection to be trashed before downstream steps that consume it are started.  The recommended minimum value for TTL is the expected duration of the entire the workflow.|
 +
 +h2. arv:ReuseRequirement
 +
 +Enable/disable work reuse for current process.  Default true (work reuse enabled).
 +
 +table(table table-bordered table-condensed).
 +|_. Field |_. Type |_. Description |
 +|enableReuse|boolean|Enable/disable work reuse for current process.  Default true (work reuse enabled).|
index 64ec4e2ef2813851607fb2dc0726838fda9cc110,b79c453cfbeb115eae736f5fbd621453950d1a05..4584d955e6fcc6080d56dfe9a5dd277c7f6bb414
@@@ -1,4 -1,7 +1,7 @@@
  #!/usr/bin/env python
+ # Copyright (C) The Arvados Authors. All rights reserved.
+ #
+ # SPDX-License-Identifier: Apache-2.0
  
  # Implement cwl-runner interface for submitting and running work on Arvados, using
  # either the Crunch jobs API or Crunch containers API.
@@@ -685,8 -688,7 +688,8 @@@ def add_arv_hints()
          "http://arvados.org/cwl#PartitionRequirement",
          "http://arvados.org/cwl#APIRequirement",
          "http://commonwl.org/cwltool#LoadListingRequirement",
 -        "http://arvados.org/cwl#IntermediateOutput"
 +        "http://arvados.org/cwl#IntermediateOutput",
 +        "http://arvados.org/cwl#ReuseRequirement"
      ])
  
  def main(args, stdout, stderr, api_client=None, keep_client=None):
index 3107628958b3aa1101f419a1943949be2e7340c0,dc056ef18c3094c79e757b3d8a5730ded1363099..7ae2239e2e81dd4f9345e4b2a47743eb585987e9
@@@ -1,3 -1,7 +1,7 @@@
+ # Copyright (C) The Arvados Authors. All rights reserved.
+ #
+ # SPDX-License-Identifier: Apache-2.0
  $base: "http://arvados.org/cwl#"
  $namespaces:
    cwl: "https://w3id.org/cwl/cwl#"
@@@ -149,19 -153,3 +153,19 @@@ $graph
          be trashed before downstream steps that consume it are started.  The
          recommended minimum value for TTL is the expected duration of the
          entire the workflow.
 +
 +- name: ReuseRequirement
 +  type: record
 +  extends: cwl:ProcessRequirement
 +  inVocab: false
 +  doc: |
 +    Enable/disable work reuse for current process.  Default true (work reuse enabled).
 +  fields:
 +    - name: class
 +      type: string
 +      doc: "Always 'arv:ReuseRequirement'"
 +      jsonldPredicate:
 +        _id: "@type"
 +        _type: "@vocab"
 +    - name: enableReuse
 +      type: boolean
index bf4aab52fb4b637d2e48161422828f5f5545a021,d3bc7ae944c523f29f0f6857244b654d4b561f83..4ab65d9d8774708613787b3a694f64bf876004da
@@@ -1,3 -1,7 +1,7 @@@
+ # Copyright (C) The Arvados Authors. All rights reserved.
+ #
+ # SPDX-License-Identifier: Apache-2.0
  import logging
  import json
  import os
@@@ -184,15 -188,9 +188,15 @@@ class ArvadosContainer(object)
          container_request["output_ttl"] = self.output_ttl
          container_request["mounts"] = mounts
          container_request["runtime_constraints"] = runtime_constraints
 -        container_request["use_existing"] = kwargs.get("enable_reuse", True)
          container_request["scheduling_parameters"] = scheduling_parameters
  
 +        enable_reuse = kwargs.get("enable_reuse", True)
 +        if enable_reuse:
 +            reuse_req, _ = get_feature(self, "http://arvados.org/cwl#ReuseRequirement")
 +            if reuse_req:
 +                enable_reuse = reuse_req["enableReuse"]
 +        container_request["use_existing"] = enable_reuse
 +
          if kwargs.get("runnerjob", "").startswith("arvwf:"):
              wfuuid = kwargs["runnerjob"][6:kwargs["runnerjob"].index("#")]
              wfrecord = self.arvrunner.api.workflows().get(uuid=wfuuid).execute(num_retries=self.arvrunner.num_retries)
index 877f4238a33e8f41952f37793c4d1c168da89ca0,aa55cac4b75f5d14bc3f3817dc57b12e20ffb76e..64cd2aa04e562ded1d081ab71c56088cae54edb3
@@@ -1,3 -1,7 +1,7 @@@
+ # Copyright (C) The Arvados Authors. All rights reserved.
+ #
+ # SPDX-License-Identifier: Apache-2.0
  import logging
  import re
  import copy
@@@ -124,12 -128,6 +128,12 @@@ class ArvadosJob(object)
          if not self.arvrunner.ignore_docker_for_reuse:
              filters.append(["docker_image_locator", "in docker", runtime_constraints["docker_image"]])
  
 +        enable_reuse = kwargs.get("enable_reuse", True)
 +        if enable_reuse:
 +            reuse_req, _ = get_feature(self, "http://arvados.org/cwl#ReuseRequirement")
 +            if reuse_req:
 +                enable_reuse = reuse_req["enableReuse"]
 +
          try:
              with Perf(metrics, "create %s" % self.name):
                  response = self.arvrunner.api.jobs().create(
                          "runtime_constraints": runtime_constraints
                      },
                      filters=filters,
 -                    find_or_create=kwargs.get("enable_reuse", True)
 +                    find_or_create=enable_reuse
                  ).execute(num_retries=self.arvrunner.num_retries)
  
              self.arvrunner.processes[response["uuid"]] = self
index c38fb0b90e490210271d4871c08ae389102ec6f4,e8c708a1684362059f7e842efe2659991646b90e..d3bdefcd03f3d95fe585ae555ae8703e5588f312
@@@ -1,3 -1,7 +1,7 @@@
+ # Copyright (C) The Arvados Authors. All rights reserved.
+ #
+ # SPDX-License-Identifier: Apache-2.0
  - job: dir-job.yml
    output:
      "outlist": {
@@@ -82,8 -86,3 +86,8 @@@
    }
    tool: wf/listing_deep.cwl
    doc: test deep directory listing
 +
 +- job: null
 +  output: {}
 +  tool: noreuse.cwl
 +  doc: "Test arv:ReuseRequirement"
index b1f5bfe901bb2365192ea1dc810263bcfc076c2e,cec0848ccd4697de3088048beb8189862320e5da..c516d7b35340b15ac1f4eaac1a7fcbc645b95eda
@@@ -1,3 -1,7 +1,7 @@@
+ # Copyright (C) The Arvados Authors. All rights reserved.
+ #
+ # SPDX-License-Identifier: Apache-2.0
  import arvados_cwl
  from arvados_cwl.arvdocker import arv_docker_clear_cache
  import logging
@@@ -116,9 -120,6 +120,9 @@@ class TestContainer(unittest.TestCase)
              }, {
                  "class": "http://arvados.org/cwl#IntermediateOutput",
                  "outputTTL": 7200
 +            }, {
 +                "class": "http://arvados.org/cwl#ReuseRequirement",
 +                "enableReuse": False
              }],
              "baseCommand": "ls"
          })
          arvtool.formatgraph = None
          for j in arvtool.job({}, mock.MagicMock(), basedir="", name="test_resource_requirements",
                               make_fs_access=make_fs_access, tmpdir="/tmp"):
 -            j.run()
 +            j.run(enable_reuse=True)
  
          call_args, call_kwargs = runner.api.container_requests().create.call_args
  
                  'keep_cache_ram': 536870912,
                  'API': True
              },
 -            'use_existing': True,
 +            'use_existing': False,
              'priority': 1,
              'mounts': {
                  '/tmp': {'kind': 'tmp',
index d64381b62cca44c01f47d20e5a96f8fe13e9b27f,fa7a134755aabaa89be5d748dae736ed9ec6b586..5d140ba6b9d56a052f3a75eb0f4697f29b8dad79
@@@ -1,3 -1,7 +1,7 @@@
+ # Copyright (C) The Arvados Authors. All rights reserved.
+ #
+ # SPDX-License-Identifier: Apache-2.0
  import functools
  import json
  import logging
@@@ -14,7 -18,7 +18,7 @@@ from arvados.errors import ApiErro
  from schema_salad.ref_resolver import Loader
  from schema_salad.sourceline import cmap
  from .mock_discovery import get_rootDesc
- from .matcher import JsonDiffMatcher
+ from .matcher import JsonDiffMatcher, StripYAMLComments
  
  if not os.getenv('ARVADOS_DEBUG'):
      logging.getLogger('arvados.cwl-runner').setLevel(logging.WARN)
@@@ -133,10 -137,6 +137,10 @@@ class TestJob(unittest.TestCase)
                  "outputDirType": "keep_output_dir"
              }, {
                  "class": "http://arvados.org/cwl#APIRequirement",
 +            },
 +            {
 +                "class": "http://arvados.org/cwl#ReuseRequirement",
 +                "enableReuse": False
              }],
              "baseCommand": "ls"
          }
                                                   make_fs_access=make_fs_access, loader=Loader({}))
          arvtool.formatgraph = None
          for j in arvtool.job({}, mock.MagicMock(), basedir="", make_fs_access=make_fs_access):
 -            j.run()
 +            j.run(enable_reuse=True)
          runner.api.jobs().create.assert_called_with(
              body=JsonDiffMatcher({
                  'owner_uuid': 'zzzzz-8i9sb-zzzzzzzzzzzzzzz',
                      'keep_cache_mb_per_task': 512
                  }
              }),
 -            find_or_create=True,
 +            find_or_create=False,
              filters=[['repository', '=', 'arvados'],
                       ['script', '=', 'crunchrunner'],
                       ['script_version', 'in git', 'a3f2cb186e437bfce0031b024b2157b73ed2717d'],
@@@ -337,7 -337,7 +341,7 @@@ class TestWorkflow(unittest.TestCase)
          it.next().run()
  
          with open("tests/wf/scatter2_subwf.cwl") as f:
-             subwf = f.read()
+             subwf = StripYAMLComments(f.read())
  
          runner.api.jobs().create.assert_called_with(
              body=JsonDiffMatcher({