Project

General

Profile

Actions

Feature #4561

closed

[SDKs] Refactor run-command so it can be used as an SDK by scripts in a git tree

Added by Tom Clegg about 10 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assigned To:
-
Category:
SDKs
Target version:
-
Story points:
2.0

Description

Currently you have two main options for running a job:
  1. Put the program you need in a docker image. Use run-command from the arvados tree to wrap it as a crunch job.
  2. Write a native crunch script in your git tree.

The first option forces you to save a new docker image in order to run a new version of your program. Unacceptable!

There are several features of run-command that make it convenient and attractive to beginners. However, it forces you to use a totally different approach to developing and running scripts, an approach which prevents you from doing some important things:
  • Keeping your code in revision control,
  • Using the same code in more than one pipeline template,
  • Writing jobs in the programming language of your choice.

There is no migration path from a simple run-command job to a non-trivial program, so the developer is forced to choose: live with run-command's custom JSON-based programming language, or abandon the existing pipelines and all of run-command's advantages, and rewrite everything in a normal language like Python.

This can be addressed by refactoring run-command as a set of utilities and features, rather than a programming language that can only be used inside crunch jobs.
  • The "run-command language" interpreter should be runnable like other interpreters (#!whatever-the-language-is-to-be-called).
  • Convenience features like "store output dir contents in Keep and set success=true at end of task" should be ported to other SDKs too (most obviously bash), so authors can migrate from the JSON language to a normal language.
  • It should be possible to provide a crunch script in any language by copying the script itself into the job record. (This makes it possible to run jobs without touching git.)
    • The whole point of the run-command language is to already be JSON-encoded, which means it should be provided in a serialized attribute like script_parameters. (Other languages are just text, but that can also fit in a serialized field.)
    • The name of the "script" attribute already suggests that you can put a script in it. This could change type (from varchar(255) to text) and become a serialized field capable of containing a string or a hash. This means we can't rely on "script" to be a short name suitable for displaying in UI (a problem we already have with run-command jobs: the program has no name, so we display the name of the language instead).
    • We could support passing the name of an interpreter in "script" (e.g., "run-command" or "python") and passing the program itself in script_parameters[stdin]. We would have to treat string and hash/array cases differently: if stdin is a string, pass the string value, but if stdin is a hash or array, pass its JSON encoding.
  • It should be possible to move your run-command program into a git tree and run it from there.
    • Currently, this can be done awkwardly by copying some version of run-command into your own git tree.
    • With #4027, we can make run-command's features available through the SDK.
    • Then we just need #!whatever-the-language-is-called to work, or some other way to invoke run-command from the installed SDK, rather than requiring it to be in $CRUNCH_SRC/crunch_scripts/.

Related issues 3 (0 open3 closed)

Related to Arvados - Bug #4562: [Documentation] Wiki page: explain appropriate use cases for arv-run vs. run-command vs. writing your own crunch script.ResolvedBrett Smith01/16/2015Actions
Related to Arvados - Idea #3820: [Crunch] Jobs need code from multiple git repositoriesClosed09/05/2014Actions
Related to Arvados - Idea #3603: [Crunch] Design good Crunch task API, including considerations about "jobs-within-jobs" and "reusable tasks" ideasClosed08/27/2014Actions
Actions

Also available in: Atom PDF