[ARVADOS] created: b758d48df3373a401cef74b0c8c99f918918afee
Git user
git at public.curoverse.com
Fri Sep 9 15:09:13 EDT 2016
at b758d48df3373a401cef74b0c8c99f918918afee (commit)
commit b758d48df3373a401cef74b0c8c99f918918afee
Author: radhika <radhika at curoverse.com>
Date: Fri Sep 9 15:06:29 2016 -0400
10005: Rename workflow attribute in workflow object as definition.
diff --git a/services/api/app/models/workflow.rb b/services/api/app/models/workflow.rb
index ea3e985..f786914 100644
--- a/services/api/app/models/workflow.rb
+++ b/services/api/app/models/workflow.rb
@@ -3,27 +3,27 @@ class Workflow < ArvadosModel
include KindAndEtag
include CommonApiTemplate
- validate :validate_workflow
+ validate :validate_definition
before_save :set_name_and_description
api_accessible :user, extend: :common do |t|
t.add :name
t.add :description
- t.add :workflow
+ t.add :definition
end
- def validate_workflow
+ def validate_definition
begin
- @workflow_yaml = YAML.load self.workflow if !workflow.nil?
+ @definition_yaml = YAML.load self.definition if !definition.nil?
rescue => e
- errors.add :workflow, "is not valid yaml: #{e.message}"
+ errors.add :definition, "is not valid yaml: #{e.message}"
end
end
def set_name_and_description
old_wf = {}
begin
- old_wf = YAML.load self.workflow_was if !self.workflow_was.nil?
+ old_wf = YAML.load self.definition_was if !self.definition_was.nil?
rescue => e
logger.warn "set_name_and_description error: #{e.message}"
return
@@ -33,7 +33,7 @@ class Workflow < ArvadosModel
if !self.changes.include?(a)
v = self.read_attribute(a)
if !v.present? or v == old_wf[a]
- val = @workflow_yaml[a] if self.workflow and @workflow_yaml
+ val = @definition_yaml[a] if self.definition and @definition_yaml
self[a] = val
end
end
diff --git a/services/api/db/migrate/20160909181442_rename_workflow_to_definition.rb b/services/api/db/migrate/20160909181442_rename_workflow_to_definition.rb
new file mode 100644
index 0000000..a5471ac
--- /dev/null
+++ b/services/api/db/migrate/20160909181442_rename_workflow_to_definition.rb
@@ -0,0 +1,10 @@
+class RenameWorkflowToDefinition < ActiveRecord::Migration
+ def up
+ rename_column :workflows, :workflow, :definition
+ end
+
+ def down
+ rename_column :workflows, :definition, :workflow
+ end
+end
+
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 1573db2..1c7363d 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -1069,7 +1069,7 @@ CREATE TABLE workflows (
modified_by_user_uuid character varying(255),
name character varying(255),
description text,
- workflow text,
+ definition text,
updated_at timestamp without time zone NOT NULL
);
@@ -2410,7 +2410,7 @@ CREATE INDEX virtual_machines_search_index ON virtual_machines USING btree (uuid
-- Name: workflows_full_text_search_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
-CREATE INDEX workflows_full_text_search_idx ON workflows USING gin (to_tsvector('english'::regconfig, (((((((((((((' '::text || (COALESCE(uuid, ''::character varying))::text) || ' '::text) || (COALESCE(owner_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_client_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_user_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(name, ''::character varying))::text) || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || COALESCE(workflow, ''::text))));
+CREATE INDEX workflows_full_text_search_idx ON workflows USING gin (to_tsvector('english'::regconfig, (((((((((((((' '::text || (COALESCE(uuid, ''::character varying))::text) || ' '::text) || (COALESCE(owner_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_client_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(modified_by_user_uuid, ''::character varying))::text) || ' '::text) || (COALESCE(name, ''::character varying))::text) || ' '::text) || COALESCE(description, ''::text)) || ' '::text) || COALESCE(definition, ''::text))));
--
@@ -2688,4 +2688,6 @@ INSERT INTO schema_migrations (version) VALUES ('20160819195557');
INSERT INTO schema_migrations (version) VALUES ('20160819195725');
-INSERT INTO schema_migrations (version) VALUES ('20160901210110');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20160901210110');
+
+INSERT INTO schema_migrations (version) VALUES ('20160909181442');
\ No newline at end of file
diff --git a/services/api/test/fixtures/workflows.yml b/services/api/test/fixtures/workflows.yml
index e124cf8..20e8ed8 100644
--- a/services/api/test/fixtures/workflows.yml
+++ b/services/api/test/fixtures/workflows.yml
@@ -1,12 +1,12 @@
-workflow_with_workflow_yml:
+workflow_with_definition_yml:
uuid: zzzzz-7fd4e-validworkfloyml
owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
name: Valid workflow with name and desc
description: this workflow has a valid workflow yaml
- workflow: "name: foo\ndesc: bar"
+ definition: "name: foo\ndesc: bar"
created_at: 2016-08-15 12:00:00
-workflow_with_no_workflow_yml:
+workflow_with_no_definition_yml:
uuid: zzzzz-7fd4e-validbutnoyml00
owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
name: Valid workflow with no workflow yaml
@@ -16,7 +16,7 @@ workflow_with_no_workflow_yml:
workflow_with_no_name_and_desc:
uuid: zzzzz-7fd4e-validnonamedesc
owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
- workflow: this is valid yaml
+ definition: this is valid yaml
created_at: 2016-08-15 12:00:01
workflow_with_input_specifications:
@@ -25,7 +25,7 @@ workflow_with_input_specifications:
name: Workflow with input specifications
description: this workflow has inputs specified
created_at: <%= 1.minute.ago.to_s(:db) %>
- workflow:
+ definition:
cwlVersion: v1.0
class: CommandLineTool
baseCommand:
diff --git a/services/api/test/unit/workflow_test.rb b/services/api/test/unit/workflow_test.rb
index ac8df47..c7c5288 100644
--- a/services/api/test/unit/workflow_test.rb
+++ b/services/api/test/unit/workflow_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
class WorkflowTest < ActiveSupport::TestCase
- test "create workflow with no workflow yaml" do
+ test "create workflow with no definition yaml" do
set_user_from_auth :active
wf = {
@@ -12,36 +12,36 @@ class WorkflowTest < ActiveSupport::TestCase
assert_not_nil w.uuid
end
- test "create workflow with valid workflow yaml" do
+ test "create workflow with valid definition yaml" do
set_user_from_auth :active
wf = {
name: "test name",
- workflow: "k1:\n v1: x\n v2: y"
+ definition: "k1:\n v1: x\n v2: y"
}
w = Workflow.create!(wf)
assert_not_nil w.uuid
end
- test "create workflow with simple string as workflow" do
+ test "create workflow with simple string as definition" do
set_user_from_auth :active
wf = {
name: "test name",
- workflow: "this is valid yaml"
+ definition: "this is valid yaml"
}
w = Workflow.create!(wf)
assert_not_nil w.uuid
end
- test "create workflow with invalid workflow yaml" do
+ test "create workflow with invalid definition yaml" do
set_user_from_auth :active
wf = {
name: "test name",
- workflow: "k1:\n v1: x\n v2: y"
+ definition: "k1:\n v1: x\n v2: y"
}
assert_raises(ActiveRecord::RecordInvalid) do
@@ -49,75 +49,75 @@ class WorkflowTest < ActiveSupport::TestCase
end
end
- test "update workflow with invalid workflow yaml" do
+ test "update workflow with invalid definition yaml" do
set_user_from_auth :active
- w = Workflow.find_by_uuid(workflows(:workflow_with_workflow_yml).uuid)
- wf = "k1:\n v1: x\n v2: y"
+ w = Workflow.find_by_uuid(workflows(:workflow_with_definition_yml).uuid)
+ definition = "k1:\n v1: x\n v2: y"
assert_raises(ActiveRecord::RecordInvalid) do
- w.update_attributes!(workflow: wf)
+ w.update_attributes!(definition: definition)
end
end
test "update workflow and verify name and description" do
set_user_from_auth :active
- # Workflow name and desc should be set with values from workflow yaml
+ # Workflow name and desc should be set with values from definition yaml
# when it does not already have custom values for these fields
w = Workflow.find_by_uuid(workflows(:workflow_with_no_name_and_desc).uuid)
- wf = "name: test name 1\ndescription: test desc 1\nother: some more"
- w.update_attributes!(workflow: wf)
+ definition = "name: test name 1\ndescription: test desc 1\nother: some more"
+ w.update_attributes!(definition: definition)
w.reload
assert_equal "test name 1", w.name
assert_equal "test desc 1", w.description
- # Workflow name and desc should be set with values from workflow yaml
+ # Workflow name and desc should be set with values from definition yaml
# when it does not already have custom values for these fields
- wf = "name: test name 2\ndescription: test desc 2\nother: some more"
- w.update_attributes!(workflow: wf)
+ definition = "name: test name 2\ndescription: test desc 2\nother: some more"
+ w.update_attributes!(definition: definition)
w.reload
assert_equal "test name 2", w.name
assert_equal "test desc 2", w.description
- # Workflow name and desc should be set with values from workflow yaml
+ # Workflow name and desc should be set with values from definition yaml
# even if it means emptying them out
- wf = "more: etc"
- w.update_attributes!(workflow: wf)
+ definition = "more: etc"
+ w.update_attributes!(definition: definition)
w.reload
assert_equal nil, w.name
assert_equal nil, w.description
- # Workflow name and desc set using workflow yaml should be cleared
- # if workflow yaml is cleared
- wf = "name: test name 2\ndescription: test desc 2\nother: some more"
- w.update_attributes!(workflow: wf)
+ # Workflow name and desc set using definition yaml should be cleared
+ # if definition yaml is cleared
+ definition = "name: test name 2\ndescription: test desc 2\nother: some more"
+ w.update_attributes!(definition: definition)
w.reload
- wf = nil
- w.update_attributes!(workflow: wf)
+ definition = nil
+ w.update_attributes!(definition: definition)
w.reload
assert_equal nil, w.name
assert_equal nil, w.description
# Workflow name and desc should be set to provided custom values
- wf = "name: test name 3\ndescription: test desc 3\nother: some more"
- w.update_attributes!(name: "remains", description: "remains", workflow: wf)
+ definition = "name: test name 3\ndescription: test desc 3\nother: some more"
+ w.update_attributes!(name: "remains", description: "remains", definition: definition)
w.reload
assert_equal "remains", w.name
assert_equal "remains", w.description
# Workflow name and desc should retain provided custom values
# and should not be overwritten by values from yaml
- wf = "name: test name 4\ndescription: test desc 4\nother: some more"
- w.update_attributes!(workflow: wf)
+ definition = "name: test name 4\ndescription: test desc 4\nother: some more"
+ w.update_attributes!(definition: definition)
w.reload
assert_equal "remains", w.name
assert_equal "remains", w.description
# Workflow name and desc should retain provided custom values
- # and not be affected by the clearing of the workflow yaml
- wf = nil
- w.update_attributes!(workflow: wf)
+ # and not be affected by the clearing of the definition yaml
+ definition = nil
+ w.update_attributes!(definition: definition)
w.reload
assert_equal "remains", w.name
assert_equal "remains", w.description
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list