pione 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/.gitignore +0 -1
  2. data/.travis.yml +3 -0
  3. data/History.txt +15 -0
  4. data/Rakefile +4 -0
  5. data/doc/man/pione-action-list.md +23 -0
  6. data/doc/man/pione-action.md +37 -0
  7. data/doc/man/pione-clean.md +56 -0
  8. data/doc/man/pione-compiler.md +39 -0
  9. data/doc/man/pione-update-package-info.md +38 -0
  10. data/example/DeferredChoice/DeferredChoice.pione +6 -4
  11. data/example/DeferredChoice/pione-package.json +15 -0
  12. data/example/FeatureExample/FeatureExample.pione +2 -0
  13. data/example/FeatureExample/pione-package.json +15 -0
  14. data/example/LoopByTouch/LoopByTouch.pione +2 -0
  15. data/example/LoopByTouch/pione-package.json +18 -0
  16. data/example/LucasNumber/LucasNumber.pione +6 -4
  17. data/example/LucasNumber/pione-package.json +15 -0
  18. data/example/MakePair/MakePair.pione +2 -0
  19. data/example/MakePair/pione-package.json +17 -0
  20. data/example/MakePair/scenario/case1/Scenario.pione +1 -0
  21. data/example/MakePair/scenario/case1/pione-scenario.json +47 -0
  22. data/example/MakePair/scenario/case2/Scenario.pione +1 -0
  23. data/example/MakePair/scenario/case2/pione-scenario.json +22 -0
  24. data/example/MakePair/scenario/case3/Scenario.pione +1 -0
  25. data/example/MakePair/scenario/case3/pione-scenario.json +43 -0
  26. data/example/OddSelector/OddSelector.pione +2 -0
  27. data/example/OddSelector/pione-package.json +15 -0
  28. data/example/OddSelector/scenario/Scenario.pione +1 -0
  29. data/example/OddSelector/{data → scenario/input}/1.i +0 -0
  30. data/example/OddSelector/{data → scenario/input}/10.i +0 -0
  31. data/example/OddSelector/{data → scenario/input}/2.i +0 -0
  32. data/example/OddSelector/{data → scenario/input}/3.i +0 -0
  33. data/example/OddSelector/{data → scenario/input}/4.i +0 -0
  34. data/example/OddSelector/{data → scenario/input}/5.i +0 -0
  35. data/example/OddSelector/{data → scenario/input}/6.i +0 -0
  36. data/example/OddSelector/{data → scenario/input}/7.i +0 -0
  37. data/example/OddSelector/{data → scenario/input}/8.i +0 -0
  38. data/example/OddSelector/{data → scenario/input}/9.i +0 -0
  39. data/example/OddSelector/scenario/output/1.res +0 -0
  40. data/example/OddSelector/scenario/output/3.res +0 -0
  41. data/example/OddSelector/scenario/output/5.res +0 -0
  42. data/example/OddSelector/scenario/output/7.res +0 -0
  43. data/example/OddSelector/scenario/output/9.res +0 -0
  44. data/example/OddSelector/scenario/pione-scenario.json +23 -0
  45. data/example/PegasusWMS/Merge/Merge.pione +3 -1
  46. data/example/PegasusWMS/Merge/pione-package.json +15 -0
  47. data/example/PegasusWMS/Pipeline/Pipeline.pione +2 -0
  48. data/example/PegasusWMS/Pipeline/pione-package.json +15 -0
  49. data/example/PegasusWMS/Split/Split.pione +2 -0
  50. data/example/PegasusWMS/Split/pione-package.json +15 -0
  51. data/example/{AbstractRule/AbstractRule.pione → SelectRuleByParam/SelectRuleByParam.pione} +4 -2
  52. data/example/SelectRuleByParam/pione-package.json +17 -0
  53. data/example/SelectRuleByParam/scenario/a/Scenario.pione +2 -0
  54. data/example/{AbstractRule → SelectRuleByParam}/scenario/a/output/message.txt +0 -0
  55. data/example/SelectRuleByParam/scenario/a/pione-scenario.json +10 -0
  56. data/example/SelectRuleByParam/scenario/b/Scenario.pione +2 -0
  57. data/example/{AbstractRule → SelectRuleByParam}/scenario/b/output/message.txt +0 -0
  58. data/example/SelectRuleByParam/scenario/b/pione-scenario.json +10 -0
  59. data/example/SelectRuleByParam/scenario/c/Scenario.pione +2 -0
  60. data/example/{AbstractRule → SelectRuleByParam}/scenario/c/output/message.txt +0 -0
  61. data/example/SelectRuleByParam/scenario/c/pione-scenario.json +10 -0
  62. data/example/Sum/Sum.pione +23 -21
  63. data/example/Sum/pione-package.json +15 -0
  64. data/example/Sum/scenario/Scenario.pione +1 -0
  65. data/example/Sum/{input → scenario/input}/list.txt +0 -0
  66. data/example/Sum/scenario/output/sum.txt +6 -0
  67. data/example/Sum/scenario/pione-scenario.json +10 -0
  68. data/lib/pione/agent/agent-exception.rb +11 -0
  69. data/lib/pione/agent/process-manager.rb +19 -7
  70. data/lib/pione/agent/task-worker.rb +2 -2
  71. data/lib/pione/command/option.rb +0 -1
  72. data/lib/pione/command/pione-action-list.rb +49 -0
  73. data/lib/pione/command/pione-action.rb +83 -0
  74. data/lib/pione/command/pione-client.rb +34 -10
  75. data/lib/pione/command/pione-compiler.rb +19 -1
  76. data/lib/pione/command/pione-package.rb +2 -0
  77. data/lib/pione/command/pione-task-worker.rb +3 -1
  78. data/lib/pione/command/pione-update-package-info.rb +53 -0
  79. data/lib/pione/command.rb +6 -4
  80. data/lib/pione/global/tuple-space-notifier-variable.rb +1 -1
  81. data/lib/pione/lang/environment.rb +47 -16
  82. data/lib/pione/lang/parameters.rb +6 -0
  83. data/lib/pione/literate-action/document.rb +25 -0
  84. data/lib/pione/literate-action/handler.rb +24 -0
  85. data/lib/pione/literate-action/parser.rb +54 -0
  86. data/lib/pione/literate-action.rb +10 -0
  87. data/lib/pione/location/data-location.rb +11 -3
  88. data/lib/pione/location/dropbox-location.rb +2 -0
  89. data/lib/pione/location/local-location.rb +4 -0
  90. data/lib/pione/package/package-exception.rb +17 -1
  91. data/lib/pione/package/package-handler.rb +13 -4
  92. data/lib/pione/package/scenario-handler.rb +9 -3
  93. data/lib/pione/package/scenario-info.rb +4 -3
  94. data/lib/pione/package/scenario-scanner.rb +11 -7
  95. data/lib/pione/rule-engine/basic-handler.rb +1 -1
  96. data/lib/pione/rule-engine/flow-handler.rb +6 -5
  97. data/lib/pione/test-helper/command-helper.rb +44 -1
  98. data/lib/pione/test-helper/internet-connectivity.rb +10 -0
  99. data/lib/pione/test-helper.rb +11 -10
  100. data/lib/pione/util/digest.rb +1 -1
  101. data/lib/pione/util/id.rb +1 -1
  102. data/lib/pione/util/indentation.rb +1 -1
  103. data/lib/pione/util/last-time.rb +20 -0
  104. data/lib/pione/util/misc.rb +7 -1
  105. data/lib/pione/util/pnml-compiler.rb +84 -13
  106. data/lib/pione/util.rb +1 -0
  107. data/lib/pione/version.rb +1 -1
  108. data/lib/pione.rb +17 -15
  109. data/man/pione-action-list.1 +23 -0
  110. data/man/pione-action.1 +45 -0
  111. data/man/pione-compiler.1 +48 -0
  112. data/man/pione-update-package-info.1 +43 -0
  113. data/pione.gemspec +1 -0
  114. data/test/command/spec_pione-action-list.rb +15 -0
  115. data/test/command/spec_pione-action.rb +24 -0
  116. data/test/command/spec_pione-client.rb +189 -0
  117. data/test/command/spec_pione-compiler.rb +28 -1
  118. data/test/command/spec_pione-update-package-info.rb +66 -0
  119. data/test/lang/data/literal-parser.yml +1 -0
  120. data/test/lang/spec_environment.rb +19 -0
  121. data/test/literate-action/data/D1.md +25 -0
  122. data/test/literate-action/data/HelloWorld.md +11 -0
  123. data/test/literate-action/spec_document.rb +20 -0
  124. data/test/literate-action/spec_handler.rb +28 -0
  125. data/test/literate-action/spec_parser.rb +51 -0
  126. data/test/package/spec_scenario-info.rb +2 -2
  127. data/test/package/spec_scenario-scanner.rb +3 -3
  128. data/test/util/data/pnml/Sequence.pnml +135 -135
  129. data/test/util/spec_pnml-compiler.rb +20 -9
  130. metadata +102 -39
  131. data/example/AbstractRule/package.yml +0 -7
  132. data/example/AbstractRule/scenario/a/scenario.yml +0 -4
  133. data/example/AbstractRule/scenario/b/scenario.yml +0 -4
  134. data/example/AbstractRule/scenario/c/scenario.yml +0 -4
  135. data/example/HelloWorld/package.yml +0 -6
  136. data/example/HelloWorld/scenario/scenario.yml +0 -3
  137. data/example/MakePair/package.yml +0 -8
  138. data/example/MakePair/scenario/case1/scenario.yml +0 -42
  139. data/example/MakePair/scenario/case2/scenario.yml +0 -17
  140. data/example/MakePair/scenario/case3/scenario.yml +0 -39
  141. data/example/PegasusWMS/Merge/package.yml +0 -2
  142. data/example/PegasusWMS/Pipeline/package.yml +0 -2
  143. data/example/PegasusWMS/Split/package.yml +0 -2
  144. data/example/SyntaxError/call_rule_error.pione +0 -6
  145. data/example/SyntaxError/feature_line_error.pione +0 -7
  146. data/example/SyntaxError/flow_block_error.pione +0 -5
  147. data/example/SyntaxError/input_line_error.pione +0 -6
  148. data/example/SyntaxError/invalid_rule_name.pione +0 -6
  149. data/example/SyntaxError/output_line_error.pione +0 -6
  150. data/example/SyntaxError/param_line_error.pione +0 -7
  151. data/example/SyntaxError/variable-binding-error.pione +0 -11
@@ -1,3 +1,5 @@
1
+ .@ PackageName :: "PegasusWMS-Split"
2
+
1
3
  Rule Main
2
4
  output 'count.txt.*'.all
3
5
  Flow
@@ -0,0 +1,15 @@
1
+ {
2
+ "PackageName": "PegasusWMS-Split",
3
+ "Parents": [
4
+
5
+ ],
6
+ "Documents": [
7
+ "Split.pione"
8
+ ],
9
+ "Scenarios": [
10
+
11
+ ],
12
+ "Bins": [
13
+
14
+ ]
15
+ }
@@ -1,3 +1,5 @@
1
+ .@ PackageName :: "SelectRuleByParam"
2
+
1
3
  Rule Main
2
4
  output 'message.txt'
3
5
  param $NAME := "A"
@@ -10,10 +12,10 @@ Flow
10
12
  when "C"
11
13
  $RULE := C
12
14
  end
13
- rule Abstract {R: $RULE}
15
+ rule RuleSelector {R: $RULE}
14
16
  End
15
17
 
16
- Rule Abstract
18
+ Rule RuleSelector
17
19
  output 'message.txt'
18
20
  param $R
19
21
  Flow
@@ -0,0 +1,17 @@
1
+ {
2
+ "PackageName": "SelectRuleByParam",
3
+ "Parents": [
4
+
5
+ ],
6
+ "Documents": [
7
+ "SelectRuleByParam.pione"
8
+ ],
9
+ "Scenarios": [
10
+ "scenario/a",
11
+ "scenario/b",
12
+ "scenario/c"
13
+ ],
14
+ "Bins": [
15
+
16
+ ]
17
+ }
@@ -0,0 +1,2 @@
1
+ .@ ScenarioName :: "Select A"
2
+ .@ ParamSet :: "{NAME: \"A\"}"
@@ -0,0 +1,10 @@
1
+ {
2
+ "ScenarioName": "Select A",
3
+ "ParamSet": "{NAME: \"A\"}",
4
+ "Inputs": [
5
+
6
+ ],
7
+ "Outputs": [
8
+ "output/message.txt"
9
+ ]
10
+ }
@@ -0,0 +1,2 @@
1
+ .@ ScenarioName :: "Select B"
2
+ .@ ParamSet :: "{NAME: \"B\"}"
@@ -0,0 +1,10 @@
1
+ {
2
+ "ScenarioName": "Select B",
3
+ "ParamSet": "{NAME: \"B\"}",
4
+ "Inputs": [
5
+
6
+ ],
7
+ "Outputs": [
8
+ "output/message.txt"
9
+ ]
10
+ }
@@ -0,0 +1,2 @@
1
+ .@ ScenarioName :: "Select C"
2
+ .@ ParamSet :: "{NAME: \"C\"}"
@@ -0,0 +1,10 @@
1
+ {
2
+ "ScenarioName": "Select C",
3
+ "ParamSet": "{NAME: \"C\"}",
4
+ "Inputs": [
5
+
6
+ ],
7
+ "Outputs": [
8
+ "output/message.txt"
9
+ ]
10
+ }
@@ -1,17 +1,19 @@
1
+ .@ PackageName :: "Sum"
2
+
1
3
  Rule Main
2
4
  input 'list.txt'
3
5
  output 'sum.txt'
4
6
  Flow
5
- rule CalcEachLine
6
- rule Aggregation
7
+ rule CalcEachLine
8
+ rule Aggregation
7
9
  End
8
10
 
9
11
  Rule CalcEachLine
10
12
  input 'list.txt'
11
13
  output 'line_sum*.txt'.all
12
14
  Flow
13
- rule MakeHeadTail
14
- rule Sum
15
+ rule MakeHeadTail
16
+ rule Sum
15
17
  End
16
18
 
17
19
  Rule MakeHeadTail
@@ -19,14 +21,14 @@ Rule MakeHeadTail
19
21
  output 'head*.txt'.all
20
22
  output 'tail*.txt'.all
21
23
  Action
22
- #!/usr/bin/env ruby
23
- i = 1
24
- File.readlines('list.txt').each do |line|
25
- head, tail = line.split(',')
26
- File.open("head#{i}.txt", "w+"){|f| f.print head}
27
- File.open("tail#{i}.txt", "w+"){|f| f.print tail}
28
- i += 1
29
- end
24
+ #!/usr/bin/env ruby
25
+ i = 1
26
+ File.readlines('list.txt').each do |line|
27
+ head, tail = line.split(',')
28
+ File.open("head#{i}.txt", "w+"){|f| f.print head}
29
+ File.open("tail#{i}.txt", "w+"){|f| f.print tail}
30
+ i += 1
31
+ end
30
32
  End
31
33
 
32
34
  Rule Sum
@@ -34,19 +36,19 @@ Rule Sum
34
36
  input 'tail{$*}.txt'
35
37
  output 'line_sum{$*}.txt'.stdout
36
38
  Action
37
- expr `cat {$INPUT[1]}` + `cat {$INPUT[2]}`
39
+ expr `cat {$INPUT[1]}` + `cat {$INPUT[2]}`
38
40
  End
39
41
 
40
42
  Rule Aggregation
41
43
  input 'line_sum*.txt'.all
42
44
  output 'sum.txt'.stdout
43
45
  Action
44
- #!/usr/bin/env ruby
45
- sum = 0
46
- '{$INPUT[1]}'.split(':').sort.each do |filename|
47
- n = File.read(filename)
48
- sum += n.to_i
49
- puts n
50
- end
51
- puts "total: #{sum}"
46
+ #!/usr/bin/env ruby
47
+ sum = 0
48
+ '{$INPUT[1]}'.split(' ').sort.each do |filename|
49
+ n = File.read(filename)
50
+ sum += n.to_i
51
+ puts n
52
+ end
53
+ puts "total: #{sum}"
52
54
  End
@@ -0,0 +1,15 @@
1
+ {
2
+ "PackageName": "Sum",
3
+ "Parents": [
4
+
5
+ ],
6
+ "Documents": [
7
+ "Sum.pione"
8
+ ],
9
+ "Scenarios": [
10
+ "scenario"
11
+ ],
12
+ "Bins": [
13
+
14
+ ]
15
+ }
@@ -0,0 +1 @@
1
+ .@ ScenarioName :: "test"
File without changes
@@ -0,0 +1,6 @@
1
+ 45
2
+ 40
3
+ 94
4
+ 86
5
+ 98
6
+ total: 363
@@ -0,0 +1,10 @@
1
+ {
2
+ "ScenarioName": "test",
3
+ "ParamSet": null,
4
+ "Inputs": [
5
+ "input/list.txt"
6
+ ],
7
+ "Outputs": [
8
+ "output/sum.txt"
9
+ ]
10
+ }
@@ -48,5 +48,16 @@ module Pione
48
48
  "input generator method \"%s\" is unknown" % @name
49
49
  end
50
50
  end
51
+
52
+ # JobError is raised when job ends because of something reasons.
53
+ class JobError < StandardError
54
+ def initialize(msg)
55
+ @msg = msg
56
+ end
57
+
58
+ def message
59
+ @msg
60
+ end
61
+ end
51
62
  end
52
63
  end
@@ -10,14 +10,18 @@ module Pione
10
10
 
11
11
  attr_reader :package
12
12
 
13
- def initialize(space, env, package, param_sets, stream)
14
- raise ArgumentError unless env.rule_get!(Lang::RuleExpr.new("Main"))
13
+ def initialize(space, env, package, param_set, stream)
14
+ unless env.rule_get!(Lang::RuleExpr.new("Main"))
15
+ raise JobError.new("Rule `Main` not found in the package.")
16
+ end
17
+
15
18
  super(space)
16
19
  @space = space
17
20
  @env = env
18
21
  @package = package
19
- @param_sets = param_sets
22
+ @param_set = param_set
20
23
  @stream = stream
24
+ @package_id = @env.current_package_id
21
25
  end
22
26
 
23
27
  #
@@ -36,9 +40,17 @@ module Pione
36
40
  #
37
41
 
38
42
  def transit_to_init
43
+ # split parameter set as package toplvel's and main's
44
+ toplevel_variable_names = @env.variable_table.select_names_by(@env, @env.current_package_id)
45
+ toplevel_param_set = @param_set.filter(toplevel_variable_names)
46
+ main_param_set = @param_set.delete_all(toplevel_variable_names)
47
+
48
+ # merge the toplevel parameter set
49
+ @env.merge_param_set(toplevel_param_set, force: true)
50
+
39
51
  # setup root rule
40
- definition = @env.make_root_rule(@param_sets)
41
- @rule_condition = definition.rule_condition_context.eval(@env)
52
+ root_definition = @env.make_root_rule(main_param_set)
53
+ @rule_condition = root_definition.rule_condition_context.eval(@env)
42
54
 
43
55
  # share my environment
44
56
  write(TupleSpace::EnvTuple.new(@env.dumpable)) # need to be dumpable
@@ -55,10 +67,10 @@ module Pione
55
67
  user_message "error: no inputs"
56
68
  terminate
57
69
  else
70
+ # call root rule of the current package
58
71
  list.each do |env, inputs|
59
72
  package_id = @env.current_package_id
60
- param_set = Lang::ParameterSet.new
61
- handler = RuleEngine.make(@space, @env, package_id, "Root", inputs, param_set, 'root', nil)
73
+ handler = RuleEngine.make(@space, @env, package_id, "Root", inputs, Lang::ParameterSet.new, 'root', nil)
62
74
  handler.handle
63
75
  end
64
76
  end
@@ -77,7 +77,7 @@ module Pione
77
77
  @execution_thread = Thread.new do
78
78
  begin
79
79
  engine.handle
80
- rescue RuleEngine::ActionError => e
80
+ rescue RuleEngine::ActionError, Lang::MethodNotFound => e
81
81
  write(TupleSpace::CommandTuple.new("terminate", [System::Status.error(e)]))
82
82
  terminate
83
83
  end
@@ -115,7 +115,7 @@ module Pione
115
115
  if env = read!(TupleSpace::EnvTuple.new)
116
116
  env.obj
117
117
  else
118
- raise TupleSpaceError.new("\"env\" tuple not found.")
118
+ raise TupleSpaceError.new("the tuple space is invalid because \"env\" tuple not found.")
119
119
  end
120
120
  end
121
121
 
@@ -195,7 +195,6 @@ module Pione
195
195
  begin
196
196
  # store features
197
197
  Global.features = features
198
- Global.expressional_features = Util.parse_features(features)
199
198
  rescue Parslet::ParseFailed => e
200
199
  raise OptionError.new(
201
200
  "invalid feature expression \"%s\" is given for %s" % [features, command_name]
@@ -0,0 +1,49 @@
1
+ module Pione
2
+ module Command
3
+ # PioneActionList is a command definition of "pione action:list" for listing
4
+ # literate actions.
5
+ class PioneActionList < BasicCommand
6
+ #
7
+ # basic informations
8
+ #
9
+
10
+ command_name "pione action:list"
11
+ command_banner "show list of action names in document"
12
+ PioneCommand.add_subcommand("action:list", self)
13
+
14
+ #
15
+ # options
16
+ #
17
+
18
+ use_option :color
19
+
20
+ #
21
+ # command lifecycle: setup phase
22
+ #
23
+
24
+ setup :target
25
+
26
+ # Setup location of literate action document and action name.
27
+ def setup_target
28
+ abort("There are no literate action documents or packages.") if @argv[0].nil?
29
+ @location = Location[@argv[0]]
30
+ end
31
+
32
+ #
33
+ # command lifecycle: execution phase
34
+ #
35
+
36
+ execute :show_list
37
+
38
+ # Show list of action names.
39
+ def execute_show_list
40
+ names = LiterateAction::Document.load(@location).action_names.sort
41
+ if names.empty?
42
+ abort("no action names in %s" % @location.address)
43
+ else
44
+ names.each {|name| puts name}
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,83 @@
1
+ module Pione
2
+ module Command
3
+ # PioneAction is a command definition of "pione action" for executing
4
+ # literate action.
5
+ class PioneAction < BasicCommand
6
+ #
7
+ # basic informations
8
+ #
9
+
10
+ command_name "pione action"
11
+ command_banner "execute an action in literate action document"
12
+ PioneCommand.add_subcommand("action", self)
13
+
14
+ #
15
+ # options
16
+ #
17
+
18
+ use_option :color
19
+ use_option :debug
20
+
21
+ define_option(:domain) do |item|
22
+ item.long = "--domain"
23
+ item.desc = "use the domain information file"
24
+ item.default = Location["./domain.dump"]
25
+ item.value = lambda {|b| b}
26
+ end
27
+
28
+ define_option(:show) do |item|
29
+ item.long = "--show"
30
+ item.desc = "show the action without execution"
31
+ item.value = lambda {|b| b}
32
+ end
33
+
34
+ define_option(:directory) do |item|
35
+ item.short = "-d"
36
+ item.long = "--directory PATH"
37
+ item.desc = "execute in the PATH"
38
+ item.value = lambda {|b| Location[b]}
39
+ end
40
+
41
+ #
42
+ # command lifecycle: setup phase
43
+ #
44
+
45
+ setup :target
46
+ setup :domain
47
+
48
+ # Setup location of literate action document and action name.
49
+ def setup_target
50
+ abort("There are no literate action documents or packages.") if @argv[0].nil?
51
+ abort("Action name is needed.") if @argv[1].nil?
52
+ @location = Location[@argv[0]]
53
+ @name = @argv[1]
54
+ end
55
+
56
+ # Load a domain information file.
57
+ def setup_domain
58
+ if option[:domain].exist?
59
+ @domain_info = System::DomainInfo.read(option[:domain])
60
+ end
61
+ end
62
+
63
+ #
64
+ # command lifecycle: execution phase
65
+ #
66
+
67
+ execute :exec
68
+
69
+ # Update pacakge info files.
70
+ def execute_exec
71
+ if action = LiterateAction::Document.load(@location).find(@name)
72
+ if option[:show]
73
+ puts action.textize(@domain_info)
74
+ else
75
+ action.execute(@domain_info, option[:directory])
76
+ end
77
+ else
78
+ abort(e.message)
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -75,10 +75,7 @@ module Pione
75
75
  item.default = Lang::ParameterSetSequence.new
76
76
  item.action = proc do |command_name, option, str|
77
77
  begin
78
- stree = DocumentParser.new.parameter_set.parse(str)
79
- opt = {package_name: "-", filename: "-"}
80
- params = DocumentTransformer.new.apply(stree, opt)
81
- option[:params].merge!(params)
78
+ option[:params] = option[:params].merge(Util.parse_param_set(str))
82
79
  rescue Parslet::ParseFailed => e
83
80
  raise OptionError.new("invalid parameters \"%s\" in %s" % [str, command_name])
84
81
  end
@@ -118,11 +115,17 @@ module Pione
118
115
  end
119
116
 
120
117
  define_option(:rehearse) do |item|
121
- item.long = '--rehearse[=SCENARIO]'
118
+ item.long = '--rehearse [SCENARIO]'
122
119
  item.desc = 'rehearse the scenario'
123
120
  item.value = proc {|scenario_name| scenario_name || :anything}
124
121
  end
125
122
 
123
+ define_option(:timeout) do |item|
124
+ item.long = '--timeout SEC'
125
+ item.desc = 'timeout processing after SEC'
126
+ item.value = proc {|sec| sec.to_i}
127
+ end
128
+
126
129
  validate_option do |option|
127
130
  unless option[:task_worker] > 0 or
128
131
  (not(option[:stand_alone]) and option[:task_worker] == 0)
@@ -236,7 +239,7 @@ module Pione
236
239
  @env = Lang::Environment.new
237
240
  end
238
241
 
239
- # Read a package.
242
+ # Read a PIONE package. This setups package sharing and secnario handling also.
240
243
  def setup_package
241
244
  # package is not found
242
245
  if @argv.first.nil?
@@ -246,12 +249,14 @@ module Pione
246
249
  # read package
247
250
  @package_handler = Package::PackageReader.read(Location[@argv.first])
248
251
  @env = @package_handler.eval(@env)
252
+
253
+ # upload the package
249
254
  @package_handler.upload(option[:output_location] + "package")
250
255
 
251
256
  # check rehearse scenario
252
257
  if option[:rehearse] and not(@package_handler.info.scenarios.empty?)
253
- if scenario = @package_handler.find_scenario(option[:rehearse])
254
- option[:input_location] = scenario.input
258
+ if @scenario_handler = @package_handler.find_scenario(option[:rehearse])
259
+ option[:input_location] = @scenario_handler.input
255
260
  else
256
261
  abort "the scenario not found: %s" % option[:rehearse]
257
262
  end
@@ -377,9 +382,28 @@ module Pione
377
382
 
378
383
  # Start process manager agent.
379
384
  def execute_process_manager
385
+ param_set = Lang::ParameterSet.new
386
+
387
+ # use paramerter set on command option
388
+ if option[:params] and not(option[:params].pieces.empty?)
389
+ param_set = option[:params].pieces.first
390
+ end
391
+
392
+ # use parameter set on scenario
393
+ if not(@scenario_handler.nil?) and @scenario_handler.info.textual_param_sets
394
+ param_set = Util.parse_param_set(@scenario_handler.info.textual_param_sets).pieces.first
395
+ end
396
+
397
+ # start
380
398
  @process_manager =
381
- Agent::ProcessManager.start(@tuple_space, @env, @package_handler, option[:params], option[:stream])
382
- @process_manager.wait_until_terminated(nil)
399
+ Agent::ProcessManager.start(@tuple_space, @env, @package_handler, param_set, option[:stream])
400
+ Timeout::timeout(option[:timeout]) do
401
+ @process_manager.wait_until_terminated(nil)
402
+ end
403
+ rescue Agent::JobError => e
404
+ abort(e.message)
405
+ rescue Timeout::Error => e
406
+ abort("Job timed out after %s sec." % option[:timeout])
383
407
  end
384
408
 
385
409
  # Check rehearsal result.
@@ -15,6 +15,24 @@ module Pione
15
15
 
16
16
  use_option :debug
17
17
 
18
+ define_option(:name) do |item|
19
+ item.long = '--name=NAME'
20
+ item.desc = 'set package name'
21
+ item.value = proc {|val| val}
22
+ end
23
+
24
+ define_option(:editor) do |item|
25
+ item.long = '--editor=NAME'
26
+ item.desc = 'set package editor'
27
+ item.value = proc {|val| val}
28
+ end
29
+
30
+ define_option(:tag) do |item|
31
+ item.long = '--tag=NAME'
32
+ item.desc = 'set package tag'
33
+ item.value = proc {|val| val}
34
+ end
35
+
18
36
  #
19
37
  # command lifecycle: execution phase
20
38
  #
@@ -32,7 +50,7 @@ module Pione
32
50
  execute :compile_to_pnml
33
51
 
34
52
  def execute_compile_to_pnml
35
- print Util::PNMLCompiler.new(Location[@source]).compile
53
+ print Util::PNMLCompiler.new(Location[@source], option[:name], option[:editor], option[:tag]).compile
36
54
  end
37
55
  end
38
56
  end
@@ -119,6 +119,8 @@ module Pione
119
119
  # Update update info files.
120
120
  def execute_write_info
121
121
  Package::PackageHandler.write_info_files(Location[@target])
122
+ rescue Package::InvalidScenario => e
123
+ abort(e.message)
122
124
  end
123
125
 
124
126
  #
@@ -93,7 +93,9 @@ module Pione
93
93
 
94
94
  # Create a task worker agent.
95
95
  def setup_agent
96
- @agent = Agent::TaskWorker.new(@tuple_space, option[:expressive_features])
96
+ @agent = Agent::TaskWorker.new(@tuple_space, Global.expressional_features)
97
+ rescue Agent::TupleSpaceError => e
98
+ abort(e.message)
97
99
  end
98
100
 
99
101
  # Setup base location.
@@ -0,0 +1,53 @@
1
+ module Pione
2
+ module Command
3
+ # PioneUpdatePackageInfo is a command definition of "pione
4
+ # update-package-info".
5
+ class PioneUpdatePackageInfo < BasicCommand
6
+ #
7
+ # basic informations
8
+ #
9
+
10
+ command_name "pione update-package-info"
11
+ command_banner "update package info files"
12
+ PioneCommand.add_subcommand("update-package-info", self)
13
+
14
+ #
15
+ # options
16
+ #
17
+
18
+ use_option :color
19
+ use_option :debug
20
+
21
+ define_option(:force) do |item|
22
+ item.long = "--force"
23
+ item.desc = "update pacakge info files"
24
+ item.value = lambda {|b| b}
25
+ end
26
+
27
+ #
28
+ # command lifecycle: setup phase
29
+ #
30
+
31
+ setup :target
32
+
33
+ # Check archiver target location.
34
+ def setup_target
35
+ abort("There are no PIONE documents or packages.") if @argv.first.nil?
36
+ @target = @argv.first
37
+ end
38
+
39
+ #
40
+ # command lifecycle: execution phase
41
+ #
42
+
43
+ execute :update
44
+
45
+ # Update pacakge info files.
46
+ def execute_update
47
+ Package::PackageHandler.write_info_files(Location[@target], force: option[:force])
48
+ rescue Package::InvalidScenario => e
49
+ abort(e.message)
50
+ end
51
+ end
52
+ end
53
+ end