[ARVADOS] updated: 6137770472ef5b55fd604f87d303d6e07c7e3f2f
git at public.curoverse.com
git at public.curoverse.com
Thu Sep 18 15:17:25 EDT 2014
Summary of changes:
apps/workbench/app/assets/javascripts/tab_panes.js | 8 ++
.../app/controllers/projects_controller.rb | 75 +++++++++++++----
.../app/views/application/_content.html.erb | 58 +++++++------
.../workbench/app/views/application/destroy.js.erb | 1 +
.../app/views/projects/remove_items.js.erb | 7 +-
.../workbench/app/views/projects/tab_counts.js.erb | 3 +
apps/workbench/config/routes.rb | 1 +
apps/workbench/test/integration/projects_test.rb | 7 ++
.../app/controllers/arvados/v1/jobs_controller.rb | 10 ++-
services/api/app/models/job.rb | 96 ++++++++++++++++++++++
services/api/app/models/node.rb | 16 ++--
services/api/config/routes.rb | 1 +
.../20140918153541_add_properties_to_node.rb | 9 ++
.../db/migrate/20140918153705_add_state_to_job.rb | 22 +++++
services/api/db/structure.sql | 16 ++--
.../functional/arvados/v1/jobs_controller_test.rb | 28 +++++--
.../functional/arvados/v1/nodes_controller_test.rb | 7 +-
services/api/test/unit/node_test.rb | 8 +-
18 files changed, 299 insertions(+), 74 deletions(-)
create mode 100644 apps/workbench/app/views/projects/tab_counts.js.erb
create mode 100644 services/api/db/migrate/20140918153541_add_properties_to_node.rb
create mode 100644 services/api/db/migrate/20140918153705_add_state_to_job.rb
via 6137770472ef5b55fd604f87d303d6e07c7e3f2f (commit)
via 58ccc8f13d66fc3da1aecb392a6698a29958e203 (commit)
via 4c8ec1b2166a81b05b2b6cf5a6fae5b839876802 (commit)
via 403d9f6b700f38cd3caf067445233b5ead99466c (commit)
via 355b679d30f9d3f7f7b1619a4b807d18daaf9483 (commit)
via 274ca7a6c2f1f600de4242eee6cb4e8465d4440c (commit)
via 26f139f761174328ea43114a3ef9cb9ad873149a (commit)
via 4cf16efd4dc5097b59e900d84eef3bf98d80b16f (commit)
via 3ef64886e9646804ab1c7e06cb5f3b24bbcba651 (commit)
via fc2096f2825082d526a0d98323690a09ea9a5889 (commit)
via 210d762a82c4fe3a2445c641513188fce07436e6 (commit)
via d60536bb1ca0eb6e72388a5287e786725dbdfd9e (commit)
via db9ccbd2fab6edf279408a6869a2cf2409d5f335 (commit)
via b941bb69fdf0bfd2cc2ce0de82f570e70f7af86c (commit)
via 893f659712cd9b742829b17e2cedc822901608ec (commit)
via 451e52c2a7a6ead01e5ebca28e09dd02fcba49da (commit)
via 555c1e920855989e059a4be0503ebb627193f987 (commit)
from 4c80f6b8856accfe6017bab4f66d018353986dbc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 6137770472ef5b55fd604f87d303d6e07c7e3f2f
Author: radhika <radhika at curoverse.com>
Date: Thu Sep 18 15:16:49 2014 -0400
3898: db migration to add state attribute to job.
diff --git a/services/api/app/models/job.rb b/services/api/app/models/job.rb
index e142d8d..a831dd6 100644
--- a/services/api/app/models/job.rb
+++ b/services/api/app/models/job.rb
@@ -11,6 +11,9 @@ class Job < ArvadosModel
before_validation :set_priority
validate :ensure_script_version_is_commit
validate :find_docker_image_locator
+ before_validation :verify_status
+ before_create :set_state_before_save
+ before_save :set_state_before_save
has_many :commit_ancestors, :foreign_key => :descendant, :primary_key => :script_version
@@ -31,6 +34,7 @@ class Job < ArvadosModel
t.add :output
t.add :success
t.add :running
+ t.add :state
t.add :is_locked_by_uuid
t.add :log
t.add :runtime_constraints
@@ -44,6 +48,15 @@ class Job < ArvadosModel
t.add :description
end
+ # Supported states for a job
+ States = [
+ (Queued = 'Queued'),
+ (Running = 'Running'),
+ (Cancelled = 'Cancelled'),
+ (Failed = 'Failed'),
+ (Complete = 'Complete'),
+ ]
+
def assert_finished
update_attributes(finished_at: finished_at || Time.now,
success: success.nil? ? false : success,
@@ -228,4 +241,76 @@ class Job < ArvadosModel
end
end
end
+
+ def verify_status
+ changed_attributes = self.changed
+
+ if new_record?
+ self.state = Queued
+ elsif 'state'.in? changed_attributes
+ case self.state
+ when Queued
+ self.running = false
+ self.success = nil
+ when Running
+ if !self.started_at
+ self.started_at = Time.now
+ end
+ self.running = true
+ self.success = nil
+ when Cancelled
+ if !self.cancelled_at
+ self.cancelled_at = Time.now
+ end
+ self.running = false
+ self.success = false
+ when Failed
+ if !self.finished_at
+ self.finished_at = Time.now
+ end
+ self.running = false
+ self.success = false
+ when Complete
+ if !self.finished_at
+ self.finished_at = Time.now
+ end
+ self.running = false
+ self.success = true
+ end
+ elsif 'running'.in? changed_attributes
+ self.state = Running
+ elsif 'success'.in? changed_attributes
+ if success
+ self.state = Complete
+ else
+ self.state = Failed
+ end
+ elsif 'cancelled_at'.in? changed_attributes
+ self.state = Cancelled
+ end
+ end
+
+ def set_state_before_save
+ if !self.state
+ if self.cancelled_at
+ self.state = Cancelled
+ elsif self.success
+ self.state = Complete
+ elsif (!self.success.nil? && !self.success)
+ self.state = Failed
+ elsif (self.running && self.success.nil? && !self.cencelled_at)
+ self.state = Running
+ elsif !self.started_at && !self.cancelled_at && !self.is_locked_by_uuid && self.success.nil?
+ self.state = Queued
+ end
+ end
+
+ if self.state.in?(States)
+ true
+ else
+ errors.add :state, "'#{state.inspect} must be one of: [#{States.join ', '}]"
+ false
+ end
+ end
+
end
diff --git a/services/api/db/migrate/20140918153705_add_state_to_job.rb b/services/api/db/migrate/20140918153705_add_state_to_job.rb
new file mode 100644
index 0000000..810c3a7
--- /dev/null
+++ b/services/api/db/migrate/20140918153705_add_state_to_job.rb
@@ -0,0 +1,22 @@
+class AddStateToJob < ActiveRecord::Migration
+ def up
+ if !column_exists?(:jobs, :state)
+ add_column :jobs, :state, :string
+ end
+
+ Job.reset_column_information
+
+ act_as_system_user do
+ Job.all.each do |job|
+ # before_save filter will set state based on job status
+ job.save!
+ end
+ end
+ end
+
+ def down
+ if column_exists?(:jobs, :state)
+ remove_column :jobs, :state
+ end
+ end
+end
diff --git a/services/api/db/structure.sql b/services/api/db/structure.sql
index 0d8b9dd..35fc6fa 100644
--- a/services/api/db/structure.sql
+++ b/services/api/db/structure.sql
@@ -431,7 +431,8 @@ CREATE TABLE jobs (
supplied_script_version character varying(255),
docker_image_locator character varying(255),
priority integer DEFAULT 0 NOT NULL,
- description text
+ description text,
+ state character varying(255)
);
@@ -682,9 +683,9 @@ CREATE TABLE pipeline_instances (
properties text,
state character varying(255),
components_summary text,
+ description text,
started_at timestamp without time zone,
- finished_at timestamp without time zone,
- description text
+ finished_at timestamp without time zone
);
@@ -2025,3 +2026,4 @@ INSERT INTO schema_migrations (version) VALUES ('20140918141529');
INSERT INTO schema_migrations (version) VALUES ('20140918153541');
+INSERT INTO schema_migrations (version) VALUES ('20140918153705');
\ No newline at end of file
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list