[ARVADOS] created: 9aa83ad7b4de05dd2818885ed34111d4dcf322ea

Git user git at public.curoverse.com
Wed Apr 19 22:16:55 EDT 2017


        at  9aa83ad7b4de05dd2818885ed34111d4dcf322ea (commit)


commit 9aa83ad7b4de05dd2818885ed34111d4dcf322ea
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Apr 19 22:12:42 2017 -0400

    11470: Fix identifiers to conventional Go.

diff --git a/sdk/go/crunchrunner/crunchrunner.go b/sdk/go/crunchrunner/crunchrunner.go
index 36343d3..999a193 100644
--- a/sdk/go/crunchrunner/crunchrunner.go
+++ b/sdk/go/crunchrunner/crunchrunner.go
@@ -3,9 +3,6 @@ package main
 import (
 	"encoding/json"
 	"fmt"
-	"git.curoverse.com/arvados.git/sdk/go/arvados"
-	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
-	"git.curoverse.com/arvados.git/sdk/go/keepclient"
 	"io"
 	"io/ioutil"
 	"log"
@@ -14,6 +11,10 @@ import (
 	"os/signal"
 	"strings"
 	"syscall"
+
+	"git.curoverse.com/arvados.git/sdk/go/arvados"
+	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	"git.curoverse.com/arvados.git/sdk/go/keepclient"
 )
 
 type TaskDef struct {
@@ -34,17 +35,17 @@ type Tasks struct {
 }
 
 type Job struct {
-	Script_parameters Tasks `json:"script_parameters"`
+	ScriptParameters Tasks `json:"script_parameters"`
 }
 
 type Task struct {
-	Job_uuid                 string  `json:"job_uuid"`
-	Created_by_job_task_uuid string  `json:"created_by_job_task_uuid"`
-	Parameters               TaskDef `json:"parameters"`
-	Sequence                 int     `json:"sequence"`
-	Output                   string  `json:"output"`
-	Success                  bool    `json:"success"`
-	Progress                 float32 `json:"sequence"`
+	JobUUID              string  `json:"job_uuid"`
+	CreatedByJobTaskUUID string  `json:"created_by_job_task_uuid"`
+	Parameters           TaskDef `json:"parameters"`
+	Sequence             int     `json:"sequence"`
+	Output               string  `json:"output"`
+	Success              bool    `json:"success"`
+	Progress             float32 `json:"sequence"`
 }
 
 type IArvadosClient interface {
@@ -52,7 +53,7 @@ type IArvadosClient interface {
 	Update(resourceType string, uuid string, parameters arvadosclient.Dict, output interface{}) (err error)
 }
 
-func setupDirectories(crunchtmpdir, taskUuid string, keepTmp bool) (tmpdir, outdir string, err error) {
+func setupDirectories(crunchtmpdir, taskUUID string, keepTmp bool) (tmpdir, outdir string, err error) {
 	tmpdir = crunchtmpdir + "/tmpdir"
 	err = os.Mkdir(tmpdir, 0700)
 	if err != nil {
@@ -228,7 +229,7 @@ func getKeepTmp(outdir string) (manifest string, err error) {
 
 func runner(api IArvadosClient,
 	kc IKeepClient,
-	jobUuid, taskUuid, crunchtmpdir, keepmount string,
+	jobUUID, taskUUID, crunchtmpdir, keepmount string,
 	jobStruct Job, taskStruct Task) error {
 
 	var err error
@@ -237,22 +238,23 @@ func runner(api IArvadosClient,
 	// If this is task 0 and there are multiple tasks, dispatch subtasks
 	// and exit.
 	if taskStruct.Sequence == 0 {
-		if len(jobStruct.Script_parameters.Tasks) == 1 {
-			taskp = jobStruct.Script_parameters.Tasks[0]
+		if len(jobStruct.ScriptParameters.Tasks) == 1 {
+			taskp = jobStruct.ScriptParameters.Tasks[0]
 		} else {
-			for _, task := range jobStruct.Script_parameters.Tasks {
+			for _, task := range jobStruct.ScriptParameters.Tasks {
 				err := api.Create("job_tasks",
 					map[string]interface{}{
-						"job_task": Task{Job_uuid: jobUuid,
-							Created_by_job_task_uuid: taskUuid,
-							Sequence:                 1,
-							Parameters:               task}},
+						"job_task": Task{
+							JobUUID:              jobUUID,
+							CreatedByJobTaskUUID: taskUUID,
+							Sequence:             1,
+							Parameters:           task}},
 					nil)
 				if err != nil {
 					return TempFail{err}
 				}
 			}
-			err = api.Update("job_tasks", taskUuid,
+			err = api.Update("job_tasks", taskUUID,
 				map[string]interface{}{
 					"job_task": map[string]interface{}{
 						"output":   "",
@@ -264,7 +266,7 @@ func runner(api IArvadosClient,
 	}
 
 	var tmpdir, outdir string
-	tmpdir, outdir, err = setupDirectories(crunchtmpdir, taskUuid, taskp.KeepTmpOutput)
+	tmpdir, outdir, err = setupDirectories(crunchtmpdir, taskUUID, taskp.KeepTmpOutput)
 	if err != nil {
 		return TempFail{err}
 	}
@@ -370,7 +372,7 @@ func runner(api IArvadosClient,
 	}
 
 	// Set status
-	err = api.Update("job_tasks", taskUuid,
+	err = api.Update("job_tasks", taskUUID,
 		map[string]interface{}{
 			"job_task": Task{
 				Output:   manifest,
@@ -394,19 +396,19 @@ func main() {
 		log.Fatal(err)
 	}
 
-	jobUuid := os.Getenv("JOB_UUID")
-	taskUuid := os.Getenv("TASK_UUID")
+	jobUUID := os.Getenv("JOB_UUID")
+	taskUUID := os.Getenv("TASK_UUID")
 	tmpdir := os.Getenv("TASK_WORK")
 	keepmount := os.Getenv("TASK_KEEPMOUNT")
 
 	var jobStruct Job
 	var taskStruct Task
 
-	err = api.Get("jobs", jobUuid, nil, &jobStruct)
+	err = api.Get("jobs", jobUUID, nil, &jobStruct)
 	if err != nil {
 		log.Fatal(err)
 	}
-	err = api.Get("job_tasks", taskUuid, nil, &taskStruct)
+	err = api.Get("job_tasks", taskUUID, nil, &taskStruct)
 	if err != nil {
 		log.Fatal(err)
 	}
@@ -418,7 +420,7 @@ func main() {
 	}
 
 	syscall.Umask(0022)
-	err = runner(api, kc, jobUuid, taskUuid, tmpdir, keepmount, jobStruct, taskStruct)
+	err = runner(api, kc, jobUUID, taskUUID, tmpdir, keepmount, jobStruct, taskStruct)
 
 	if err == nil {
 		os.Exit(0)
diff --git a/sdk/go/crunchrunner/crunchrunner_test.go b/sdk/go/crunchrunner/crunchrunner_test.go
index f4c8193..fcc7709 100644
--- a/sdk/go/crunchrunner/crunchrunner_test.go
+++ b/sdk/go/crunchrunner/crunchrunner_test.go
@@ -1,8 +1,6 @@
 package main
 
 import (
-	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
-	. "gopkg.in/check.v1"
 	"io"
 	"io/ioutil"
 	"log"
@@ -10,6 +8,9 @@ import (
 	"syscall"
 	"testing"
 	"time"
+
+	"git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+	. "gopkg.in/check.v1"
 )
 
 // Gocheck boilerplate
@@ -53,7 +54,7 @@ func (s *TestSuite) TestSimpleRun(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"echo", "foo"}}}}},
 		Task{Sequence: 0})
 	c.Check(err, IsNil)
@@ -88,7 +89,7 @@ func (s *TestSuite) TestSimpleRunSubtask(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{
+		Job{ScriptParameters: Tasks{[]TaskDef{
 			{Command: []string{"echo", "bar"}},
 			{Command: []string{"echo", "foo"}}}}},
 		Task{Parameters: TaskDef{
@@ -118,7 +119,7 @@ func (s *TestSuite) TestRedirect(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"cat"},
 			Stdout:  "output.txt",
 			Stdin:   tmpfile.Name()}}}},
@@ -140,7 +141,7 @@ func (s *TestSuite) TestEnv(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"/bin/sh", "-c", "echo $BAR"},
 			Stdout:  "output.txt",
 			Env:     map[string]string{"BAR": "foo"}}}}},
@@ -161,7 +162,7 @@ func (s *TestSuite) TestEnvSubstitute(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"foo\n",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"/bin/sh", "-c", "echo $BAR"},
 			Stdout:  "output.txt",
 			Env:     map[string]string{"BAR": "$(task.keep)"}}}}},
@@ -182,7 +183,7 @@ func (s *TestSuite) TestEnvReplace(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"/bin/sh", "-c", "echo $PATH"},
 			Stdout:  "output.txt",
 			Env:     map[string]string{"PATH": "foo"}}}}},
@@ -211,14 +212,14 @@ func (t SubtaskTestClient) Update(resourceType string, uuid string, parameters a
 func (s *TestSuite) TestScheduleSubtask(c *C) {
 
 	api := SubtaskTestClient{c, []Task{
-		{Job_uuid: "zzzz-8i9sb-111111111111111",
-			Created_by_job_task_uuid: "zzzz-ot0gb-111111111111111",
-			Sequence:                 1,
+		{JobUUID: "zzzz-8i9sb-111111111111111",
+			CreatedByJobTaskUUID: "zzzz-ot0gb-111111111111111",
+			Sequence:             1,
 			Parameters: TaskDef{
 				Command: []string{"echo", "bar"}}},
-		{Job_uuid: "zzzz-8i9sb-111111111111111",
-			Created_by_job_task_uuid: "zzzz-ot0gb-111111111111111",
-			Sequence:                 1,
+		{JobUUID: "zzzz-8i9sb-111111111111111",
+			CreatedByJobTaskUUID: "zzzz-ot0gb-111111111111111",
+			Sequence:             1,
 			Parameters: TaskDef{
 				Command: []string{"echo", "foo"}}}},
 		0}
@@ -233,7 +234,7 @@ func (s *TestSuite) TestScheduleSubtask(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{
+		Job{ScriptParameters: Tasks{[]TaskDef{
 			{Command: []string{"echo", "bar"}},
 			{Command: []string{"echo", "foo"}}}}},
 		Task{Sequence: 0})
@@ -252,7 +253,7 @@ func (s *TestSuite) TestRunFail(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"/bin/sh", "-c", "exit 1"}}}}},
 		Task{Sequence: 0})
 	c.Check(err, FitsTypeOf, PermFail{})
@@ -269,7 +270,7 @@ func (s *TestSuite) TestRunSuccessCode(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command:      []string{"/bin/sh", "-c", "exit 1"},
 			SuccessCodes: []int{0, 1}}}}},
 		Task{Sequence: 0})
@@ -287,7 +288,7 @@ func (s *TestSuite) TestRunFailCode(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command:            []string{"/bin/sh", "-c", "exit 0"},
 			PermanentFailCodes: []int{0, 1}}}}},
 		Task{Sequence: 0})
@@ -305,7 +306,7 @@ func (s *TestSuite) TestRunTempFailCode(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command:            []string{"/bin/sh", "-c", "exit 1"},
 			TemporaryFailCodes: []int{1}}}}},
 		Task{Sequence: 0})
@@ -329,7 +330,7 @@ func (s *TestSuite) TestVwd(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"ls", "output.txt"},
 			Vwd: map[string]string{
 				"output.txt": tmpfile.Name()}}}}},
@@ -361,7 +362,7 @@ func (s *TestSuite) TestSubstitutionStdin(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		keepmount,
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"cat"},
 			Stdout:  "output.txt",
 			Stdin:   "$(task.keep)/file1.txt"}}}},
@@ -389,7 +390,7 @@ func (s *TestSuite) TestSubstitutionCommandLine(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		keepmount,
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"cat", "$(task.keep)/file1.txt"},
 			Stdout:  "output.txt"}}}},
 		Task{Sequence: 0})
@@ -417,7 +418,7 @@ func (s *TestSuite) TestSignal(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"sleep", "4"}}}}},
 		Task{Sequence: 0})
 	c.Check(err, FitsTypeOf, PermFail{})
@@ -437,7 +438,7 @@ func (s *TestSuite) TestQuoting(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command: []string{"echo", "foo"},
 			Stdout:  "s ub:dir/:e vi\nl"}}}},
 		Task{Sequence: 0})
@@ -464,7 +465,7 @@ func (s *TestSuite) TestKeepTmp(c *C) {
 		"zzzz-ot0gb-111111111111111",
 		tmpdir,
 		"",
-		Job{Script_parameters: Tasks{[]TaskDef{{
+		Job{ScriptParameters: Tasks{[]TaskDef{{
 			Command:       []string{"echo", "foo"},
 			KeepTmpOutput: true}}}},
 		Task{Sequence: 0})

commit 3c34e713aa343d56c7cea00a9c998b06dbf411d6
Author: Tom Clegg <tom at curoverse.com>
Date:   Wed Apr 19 22:09:45 2017 -0400

    11470: Fix accidentally cleared fields during job_task update.
    
    Updating with a Task struct had the effect of clearing job_uuid,
    created_by_job_task_uuid, and parameters fields, and resetting
    sequence to 0.

diff --git a/sdk/go/crunchrunner/crunchrunner.go b/sdk/go/crunchrunner/crunchrunner.go
index 5d7e10b..36343d3 100644
--- a/sdk/go/crunchrunner/crunchrunner.go
+++ b/sdk/go/crunchrunner/crunchrunner.go
@@ -254,10 +254,10 @@ func runner(api IArvadosClient,
 			}
 			err = api.Update("job_tasks", taskUuid,
 				map[string]interface{}{
-					"job_task": Task{
-						Output:   "",
-						Success:  true,
-						Progress: 1.0}},
+					"job_task": map[string]interface{}{
+						"output":   "",
+						"success":  true,
+						"progress": 1.0}},
 				nil)
 			return nil
 		}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list