abid 0.3.0.pre.alpha.4 → 0.3.0.pre.alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1596801ffb3b1eb65f3afcabef8320657e25b53a
4
- data.tar.gz: d1eca9882b7e33183b8c7fe1664249e10e7823f6
3
+ metadata.gz: aa7a38773bdfcb607b2640de85df8f0c3039ee2b
4
+ data.tar.gz: 876354c5246cbf418d99fc88d9a32d7ab2b628d3
5
5
  SHA512:
6
- metadata.gz: 08fd18e4a5280106ee3e23a2e422692428b211f3f35de959512f9bf1a4cde6b75408dbfdbd7ba32d37db6c56177a891bd105fbf25ff05a76865a8975fecef5ad
7
- data.tar.gz: 0df0a4df266bf2e69f755a1aff2458b2bbbb7d94f3fffc106ae476c2bff241e1f86d336158cb03de19ed0698700f5f43e7b1ca8e4272b945a630ced6cfc30ae2
6
+ metadata.gz: c03979c2d34b3f12819d47a8f7f28fce29fae3b56f03ede95f203a30ead441abb9e6a78f7cc1fdfc6a249c4d5dff29ae2a2c438c6d110dd373b31a8246838f47
7
+ data.tar.gz: 9b530b8336df34055d30ec0b83bff880db5c8573f6c36d5a92fc6f05a4586262b652cf41aaf13bca31eb814b1569592bcb7c7c084f9dc9de97be436ba4909dc2
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1.0
4
4
  before_install: gem install bundler -v 1.10.6
5
- before_script: bundle exec abidsc migrate -C test/abid.yml
5
+ before_script: bundle exec abidsc upgrade -C test/abid.yml
data/README.md CHANGED
@@ -26,7 +26,7 @@ Abid is a simple Workflow Engine based on Rake.
26
26
 
27
27
  2. Setup a database.
28
28
 
29
- $ bundle exec abidsc migrate
29
+ $ bundle exec abidsc init
30
30
 
31
31
  ## Usage
32
32
 
@@ -352,7 +352,8 @@ $ abidsc list --after='2000-01-01 00:00:00" --before="2000=01-02 00:00:00" # Di
352
352
  $ abidsc revoke STATE_ID # remove the job history # Remove the play recored from DB.
353
353
  $ abidsc assume TASK_NAME date=2000-01-01 # Insert a record that the play successed into DB.
354
354
 
355
- $ abidsc migrate # Initialize or upgrade DB schema.
355
+ $ abidsc init # Initialize DB schema.
356
+ $ abidsc upgrade # Upgrade DB schema.
356
357
  ```
357
358
 
358
359
  ## Development
data/bin/setup CHANGED
@@ -7,4 +7,4 @@ bundle install
7
7
  # Do any other automated setup that you need to do here
8
8
 
9
9
  # Initialize database
10
- bundle exec abidsc migrate -C test/abid.yml
10
+ bundle exec abidsc init -C test/abid.yml
@@ -15,6 +15,7 @@ module Abid
15
15
  class Application < Rake::Application
16
16
  def initialize(env)
17
17
  super()
18
+ @name = 'abid'
18
19
  @rakefiles = %w(abidfile Abidfile abidfile.rb Abidfile.rb)
19
20
  @env = env
20
21
  @global_params = {}
@@ -24,7 +25,7 @@ module Abid
24
25
  end
25
26
  attr_reader :global_params, :global_mixin, :job_manager, :after_all_actions
26
27
 
27
- def init
28
+ def init(app_name = 'abid')
28
29
  super
29
30
  @env.config.load(options.config_file)
30
31
  end
@@ -32,6 +33,8 @@ module Abid
32
33
  def top_level
33
34
  if options.show_tasks || options.show_prereqs
34
35
  super
36
+ elsif options.show_job_preqs
37
+ display_job_prerequisites
35
38
  else
36
39
  run_with_engine { invoke_top_level_tasks }
37
40
  end
@@ -57,6 +60,24 @@ module Abid
57
60
  call_after_all_actions
58
61
  end
59
62
 
63
+ # Display the job prerequisites
64
+ def display_job_prerequisites
65
+ from = parse_job_string(options.show_job_preqs)
66
+ to = parse_job_string(options.show_job_preqs_to) \
67
+ if options.show_job_preqs_to
68
+ @job_manager.collect_prerequisites(from, to).each do |job|
69
+ puts "#{name} #{job}"
70
+ end
71
+ end
72
+
73
+ def parse_job_string(job_string)
74
+ require 'shellwords'
75
+ args = Shellwords.split(job_string)
76
+ params, tasks = ParamsFormat.collect_params(args)
77
+ name, = parse_task_string(tasks.first)
78
+ @job_manager[name, params]
79
+ end
80
+
60
81
  def standard_rake_options
61
82
  super.each do |opt|
62
83
  case opt.first
@@ -95,7 +116,17 @@ module Abid
95
116
  end],
96
117
  ['--[no-]logging',
97
118
  'Enable logging. (default: on)',
98
- proc { |v| options.logging = v }]
119
+ proc { |v| options.logging = v }],
120
+ ['--force',
121
+ 'Force execute the task without regard to dependencies and the' \
122
+ ' task state.',
123
+ proc { options.force = true }],
124
+ ['--job-prereqs JOB', '-J',
125
+ 'Display the job dependencies, then exit',
126
+ proc { |v| options.show_job_preqs = v }],
127
+ ['--to JOB',
128
+ 'Show only the job dependencies which depends on this job',
129
+ proc { |v| options.show_job_preqs_to = v }]
99
130
  ]
100
131
  )
101
132
  end
data/lib/abid/cli.rb CHANGED
@@ -15,10 +15,14 @@ module Abid
15
15
  puts @env.config.to_yaml
16
16
  end
17
17
 
18
- desc 'migrate', 'Run database migration'
19
- def migrate
20
- require 'abid/cli/migrate'
21
- Migrate.new(@env, options).run
18
+ desc 'init', 'Create new abid project'
19
+ def init
20
+ migrate
21
+ end
22
+
23
+ desc 'upgrade', 'Upgrade current abid project'
24
+ def upgrade
25
+ migrate
22
26
  end
23
27
 
24
28
  desc 'assume TASK [TASKS..] [PARAMS]', 'Assume the job to be SUCCESSED'
@@ -50,5 +54,12 @@ module Abid
50
54
  Revoke.new(@env, options, [job_id, *rest_args]).run
51
55
  end
52
56
  map rm: :revoke
57
+
58
+ private
59
+
60
+ def migrate
61
+ require 'abid/cli/migrate'
62
+ Migrate.new(@env, options).run
63
+ end
53
64
  end
54
65
  end
@@ -48,6 +48,29 @@ module Abid
48
48
  raise "#{task.name}: param #{key} is not specified"
49
49
  end
50
50
  private :fetch_param
51
+
52
+ # @param job [Job] collect prerequisites of the job.
53
+ # @param target_job [Job] collect only prerequisites depending on
54
+ # `target_job` if specified.
55
+ # @return [Array<Job>]
56
+ def collect_prerequisites(job, target_job = nil)
57
+ collect_prerequisites_iter(job, {}, target_job).keys
58
+ end
59
+
60
+ def collect_prerequisites_iter(job, checked, target_job = nil)
61
+ return {} if checked.include?(job)
62
+ checked[job] = nil
63
+
64
+ return { job => nil } if target_job == job
65
+
66
+ found = {}
67
+ job.prerequisites.each do |preq|
68
+ found.update(collect_prerequisites_iter(preq, checked, target_job))
69
+ end
70
+ found[job] = nil if target_job.nil? || !found.empty?
71
+ found
72
+ end
73
+ private :collect_prerequisites_iter
51
74
  end
52
75
  end
53
76
  end
@@ -54,6 +54,7 @@ module Abid
54
54
  # Skip the job if it should be.
55
55
  # @return [Boolean] true if skipped
56
56
  def precheck_to_skip
57
+ return false if @job.options.force
57
58
  return @process.skip unless @job.concerned?
58
59
 
59
60
  return false if @job.repair? && !@prerequisites.empty?
@@ -74,6 +74,7 @@ module Abid
74
74
  attr_reader :state_service
75
75
 
76
76
  def prerequisites
77
+ return [] if @job.options.force
77
78
  @job.prerequisites.map { |preq| @engine.process_manager[preq] }
78
79
  end
79
80
 
data/lib/abid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Abid
2
- VERSION = '0.3.0-alpha.4'
2
+ VERSION = '0.3.0-alpha.5'
3
3
  end
@@ -0,0 +1,9 @@
1
+ Sequel.migration do
2
+ change do
3
+ alter_table(:states) do
4
+ add_index :name
5
+ add_index :state
6
+ add_index :start_time
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.alpha.4
4
+ version: 0.3.0.pre.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hikaru Ojima
@@ -195,6 +195,7 @@ files:
195
195
  - lib/abid/status.rb
196
196
  - lib/abid/version.rb
197
197
  - migrations/01_create_state_table.rb
198
+ - migrations/02_create_state_table_index.rb
198
199
  homepage: https://github.com/ojima-h/abid
199
200
  licenses:
200
201
  - MIT