pione 0.3.0 → 0.3.1
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.
- data/History.txt +9 -0
- data/Rakefile +13 -0
- data/bin/pione +5 -0
- data/bin/pione-compiler +5 -0
- data/example/ScoreAggregation/ScoreAggregation.pione +2 -0
- data/example/ScoreAggregation/bin/apply-template.rb +1 -1
- data/example/ScoreAggregation/bin/mean-summary.rb +1 -1
- data/example/ScoreAggregation/bin/total-mean.rb +1 -1
- data/example/ScoreAggregation/bin/total-statistics.rb +3 -3
- data/example/ScoreAggregation/pione-package.json +21 -0
- data/example/ScoreAggregation/scenario/case1/Scenario.pione +1 -0
- data/example/ScoreAggregation/scenario/case1/pione-scenario.json +36 -0
- data/lib/pione.rb +15 -2
- data/lib/pione/agent/basic-agent.rb +0 -1
- data/lib/pione/agent/job-terminator.rb +8 -3
- data/lib/pione/agent/task-worker.rb +9 -2
- data/lib/pione/command.rb +2 -0
- data/lib/pione/command/basic-command.rb +4 -0
- data/lib/pione/command/option.rb +4 -1
- data/lib/pione/command/pione-clean.rb +104 -17
- data/lib/pione/command/pione-client.rb +16 -3
- data/lib/pione/command/pione-command.rb +45 -0
- data/lib/pione/command/pione-compiler.rb +39 -0
- data/lib/pione/command/pione-log.rb +1 -0
- data/lib/pione/command/pione-task-worker.rb +6 -2
- data/lib/pione/command/pione-val.rb +1 -0
- data/lib/pione/front.rb +1 -0
- data/lib/pione/front/basic-front.rb +1 -1
- data/lib/pione/front/front-exception.rb +5 -1
- data/lib/pione/global.rb +3 -118
- data/lib/pione/global/broker-variable.rb +21 -8
- data/lib/pione/global/client-variable.rb +16 -8
- data/lib/pione/{system → global}/config.rb +2 -2
- data/lib/pione/global/global-exception.rb +40 -0
- data/lib/pione/global/input-generator-variable.rb +4 -1
- data/lib/pione/global/item.rb +168 -0
- data/lib/pione/global/log-variable.rb +64 -13
- data/lib/pione/global/network-variable.rb +4 -1
- data/lib/pione/global/package-variable.rb +25 -10
- data/lib/pione/global/path-variable.rb +62 -26
- data/lib/pione/global/relay-variable.rb +101 -36
- data/lib/pione/global/system-variable.rb +26 -9
- data/lib/pione/global/task-worker-variable.rb +19 -7
- data/lib/pione/global/tuple-space-notifier-variable.rb +60 -20
- data/lib/pione/lang.rb +0 -2
- data/lib/pione/lang/data-expr.rb +8 -0
- data/lib/pione/package/package-exception.rb +1 -1
- data/lib/pione/rule-engine/action-handler.rb +14 -12
- data/lib/pione/rule-engine/engine-exception.rb +11 -0
- data/lib/pione/rule-engine/flow-handler.rb +20 -11
- data/lib/pione/system.rb +1 -1
- data/lib/pione/system/file-cache.rb +1 -1
- data/lib/pione/system/init.rb +13 -15
- data/lib/pione/system/status.rb +30 -0
- data/lib/pione/system/system-exception.rb +0 -24
- data/lib/pione/test-helper.rb +8 -1
- data/lib/pione/test-helper/command-helper.rb +42 -15
- data/lib/pione/util.rb +1 -0
- data/lib/pione/util/embeded-expr-expander.rb +5 -11
- data/lib/pione/util/pnml-compiler.rb +97 -0
- data/lib/pione/util/profiler.rb +107 -0
- data/lib/pione/version.rb +1 -1
- data/man/pione-clean.1 +76 -0
- data/pione.gemspec +5 -2
- data/test/agent/spec_job-terminator.rb +41 -3
- data/test/command/data/pione-client/ActionError.pione +5 -0
- data/test/command/data/pione-compiler/Sequence.pnml +137 -0
- data/test/command/spec_pione-clean.rb +250 -5
- data/test/command/spec_pione-client.rb +57 -46
- data/test/command/spec_pione-command.rb +18 -0
- data/test/command/spec_pione-compiler.rb +13 -0
- data/test/global/spec_item.rb +77 -0
- data/test/lang/data/data-expr.yml +5 -0
- data/test/rule-engine/{spec_action-handler.pione → data/action-handler/BasicAction.pione} +0 -0
- data/test/rule-engine/data/action-handler/UsePackageScript.pione +17 -0
- data/test/rule-engine/spec_action-handler.rb +143 -80
- data/test/system/spec_status.rb +13 -0
- data/test/{tuple → tuple-space}/spec_basic-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_data-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_finished-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_message-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_task-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_touch-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_working-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/tuple-behavior.rb +0 -0
- data/test/util/data/pnml/Sequence.pnml +137 -0
- data/test/util/spec_pnml-compiler.rb +21 -0
- data/test/util/spec_profiler.rb +53 -0
- metadata +75 -32
- data/example/ScoreAggregation/package.yml +0 -5
- data/example/ScoreAggregation/scenario/case1/scenario.yml +0 -29
- data/lib/pione/lang/interpolator-parser.rb +0 -44
- data/lib/pione/lang/interpolator-transformer.rb +0 -13
- data/test/lang/spec_interpolator-parser.rb +0 -5
- data/test/lang/spec_interpolator-transformer.rb +0 -15
data/History.txt
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# History
|
|
2
2
|
|
|
3
|
+
## 0.3.1(2013/10/29)
|
|
4
|
+
|
|
5
|
+
* Fixed performance bug.
|
|
6
|
+
* Enable to generate profile reports of rule application.
|
|
7
|
+
* Added PNML compiler.
|
|
8
|
+
* Changed to stop processing when action rule happens error.
|
|
9
|
+
* Improved pione-clean command and the document, see `man pione-clean`.
|
|
10
|
+
* Added `pione` facade command.
|
|
11
|
+
|
|
3
12
|
## 0.3.0(2013/10/20)
|
|
4
13
|
|
|
5
14
|
* Improved multi-inheritance package system.
|
data/Rakefile
CHANGED
|
@@ -69,3 +69,16 @@ task 'clean' do
|
|
|
69
69
|
sh "rm -rf output/*"
|
|
70
70
|
sh "rm -rf log.txt"
|
|
71
71
|
end
|
|
72
|
+
|
|
73
|
+
#
|
|
74
|
+
# man
|
|
75
|
+
#
|
|
76
|
+
|
|
77
|
+
def generate_man(src, dest)
|
|
78
|
+
sh "pandoc -s --from=markdown+pandoc_title_block --to=man %s > %s" % [src, dest]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
desc "generate man documents"
|
|
82
|
+
task "man" do
|
|
83
|
+
generate_man("doc/man/pione-clean.md", "man/pione-clean.1")
|
|
84
|
+
end
|
data/bin/pione
ADDED
data/bin/pione-compiler
ADDED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "pione"
|
|
4
4
|
|
|
5
|
-
means = Pione.val(
|
|
5
|
+
means = Pione.val('$I[1].join(":")').split(":").map{|filename| File.read(filename).chomp.to_f}
|
|
6
6
|
|
|
7
7
|
10.times do |i|
|
|
8
8
|
count = means.select{|mean| i*10 <= mean and mean < (i+1)*10}.size
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require "pione"
|
|
4
4
|
|
|
5
|
-
name_list = Pione.val "
|
|
6
|
-
scores_f = Pione.val
|
|
7
|
-
means_f = Pione.val
|
|
5
|
+
name_list = Pione.val '$*.join(":")'
|
|
6
|
+
scores_f = Pione.val '$I[1].join(":")'
|
|
7
|
+
means_f = Pione.val '$I[2].join(":")'
|
|
8
8
|
|
|
9
9
|
total_mean = Pione::Location[Pione.val("$I[3]")].read.to_f
|
|
10
10
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"PackageName": "ScoreAggregation",
|
|
3
|
+
"Parents": [
|
|
4
|
+
|
|
5
|
+
],
|
|
6
|
+
"Documents": [
|
|
7
|
+
"ScoreAggregation.pione"
|
|
8
|
+
],
|
|
9
|
+
"Scenarios": [
|
|
10
|
+
"scenario/case1"
|
|
11
|
+
],
|
|
12
|
+
"Bins": [
|
|
13
|
+
"bin/total-statistics.rb",
|
|
14
|
+
"bin/apply-template.rb",
|
|
15
|
+
"bin/mean-summary.rb",
|
|
16
|
+
"bin/personal-bar-graph.sh",
|
|
17
|
+
"bin/personal-pre-statistics.rb",
|
|
18
|
+
"bin/total-mean.rb",
|
|
19
|
+
"bin/histgram-graph.sh"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.@ ScenarioName :: "case1"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ScenarioName": "case1",
|
|
3
|
+
"ParamSet": null,
|
|
4
|
+
"Inputs": [
|
|
5
|
+
"input/S.score",
|
|
6
|
+
"input/W.score",
|
|
7
|
+
"input/G.score",
|
|
8
|
+
"input/Q.score",
|
|
9
|
+
"input/M.score",
|
|
10
|
+
"input/X.score",
|
|
11
|
+
"input/V.score",
|
|
12
|
+
"input/L.score",
|
|
13
|
+
"input/K.score",
|
|
14
|
+
"input/F.score",
|
|
15
|
+
"input/J.score",
|
|
16
|
+
"input/Z.score",
|
|
17
|
+
"input/I.score",
|
|
18
|
+
"input/E.score",
|
|
19
|
+
"input/D.score",
|
|
20
|
+
"input/H.score",
|
|
21
|
+
"input/U.score",
|
|
22
|
+
"input/C.score",
|
|
23
|
+
"input/A.score",
|
|
24
|
+
"input/P.score",
|
|
25
|
+
"input/R.score",
|
|
26
|
+
"input/B.score",
|
|
27
|
+
"input/stat-template.erb",
|
|
28
|
+
"input/N.score",
|
|
29
|
+
"input/Y.score",
|
|
30
|
+
"input/T.score",
|
|
31
|
+
"input/O.score"
|
|
32
|
+
],
|
|
33
|
+
"Outputs": [
|
|
34
|
+
|
|
35
|
+
]
|
|
36
|
+
}
|
data/lib/pione.rb
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
Thread.abort_on_exception = true
|
|
2
2
|
|
|
3
3
|
#
|
|
4
|
-
#
|
|
4
|
+
# setup bundler
|
|
5
5
|
#
|
|
6
6
|
|
|
7
|
-
# bundler
|
|
8
7
|
require 'bundler/setup' rescue nil
|
|
9
8
|
|
|
9
|
+
#
|
|
10
|
+
# initialize profiler
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
require 'pione/util/profiler'
|
|
14
|
+
if targets = ENV["PIONE_PROFILE"]
|
|
15
|
+
Pione::Util::Profiler.init
|
|
16
|
+
Pione::Util::Profiler.targets.concat(targets.split(":"))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#
|
|
20
|
+
# load libraries
|
|
21
|
+
#
|
|
22
|
+
|
|
10
23
|
# standard
|
|
11
24
|
require 'set'
|
|
12
25
|
require 'socket'
|
|
@@ -26,12 +26,17 @@ module Pione
|
|
|
26
26
|
#
|
|
27
27
|
|
|
28
28
|
def transit_to_wait
|
|
29
|
-
read(TupleSpace::CommandTuple.new(name: "terminate"))
|
|
29
|
+
tuple = read(TupleSpace::CommandTuple.new(name: "terminate"))
|
|
30
|
+
status = System::Status.success
|
|
31
|
+
unless tuple.args.empty?
|
|
32
|
+
status = tuple.args.first
|
|
33
|
+
end
|
|
34
|
+
return status
|
|
30
35
|
end
|
|
31
36
|
|
|
32
|
-
def transit_to_fire
|
|
37
|
+
def transit_to_fire(status)
|
|
33
38
|
Log::Debug.system("job terminator fires the action %s." % @action)
|
|
34
|
-
@action.call
|
|
39
|
+
@action.call(status)
|
|
35
40
|
end
|
|
36
41
|
end
|
|
37
42
|
end
|
|
@@ -74,7 +74,14 @@ module Pione
|
|
|
74
74
|
engine = make_engine(task)
|
|
75
75
|
|
|
76
76
|
# start the engine
|
|
77
|
-
@execution_thread = Thread.new
|
|
77
|
+
@execution_thread = Thread.new do
|
|
78
|
+
begin
|
|
79
|
+
engine.handle
|
|
80
|
+
rescue RuleEngine::ActionError => e
|
|
81
|
+
write(TupleSpace::CommandTuple.new("terminate", [System::Status.error(e)]))
|
|
82
|
+
terminate
|
|
83
|
+
end
|
|
84
|
+
end
|
|
78
85
|
|
|
79
86
|
# spawn child task worker if flow
|
|
80
87
|
if engine.rule_definition.rule_type == "flow"
|
|
@@ -135,7 +142,7 @@ module Pione
|
|
|
135
142
|
# child worker loop
|
|
136
143
|
while @execution_thread.alive? do
|
|
137
144
|
if @execution_thread.status == "sleep"
|
|
138
|
-
if child_agent.nil? or
|
|
145
|
+
if child_agent.nil? or child_agent.terminated?
|
|
139
146
|
# when there isn't active child agent
|
|
140
147
|
child_agent = self.class.new(tuple_space_server, @features, @env)
|
|
141
148
|
child_agent.once = true
|
data/lib/pione/command.rb
CHANGED
|
@@ -7,6 +7,7 @@ require 'pione/command/command-exception'
|
|
|
7
7
|
require 'pione/command/spawner'
|
|
8
8
|
require 'pione/command/option'
|
|
9
9
|
require 'pione/command/basic-command'
|
|
10
|
+
require 'pione/command/pione-command'
|
|
10
11
|
require 'pione/command/pione-client'
|
|
11
12
|
require 'pione/command/pione-task-worker'
|
|
12
13
|
require 'pione/command/pione-broker'
|
|
@@ -21,4 +22,5 @@ require 'pione/command/pione-syntax-checker'
|
|
|
21
22
|
require 'pione/command/pione-log'
|
|
22
23
|
require 'pione/command/pione-val'
|
|
23
24
|
require 'pione/command/pione-package'
|
|
25
|
+
require 'pione/command/pione-compiler'
|
|
24
26
|
|
data/lib/pione/command/option.rb
CHANGED
|
@@ -41,12 +41,15 @@ module Pione
|
|
|
41
41
|
|
|
42
42
|
# OptionDefinition is a class for holding option definitions.
|
|
43
43
|
class OptionDefinition
|
|
44
|
+
attr_accessor :parser_mode
|
|
45
|
+
|
|
44
46
|
# Creata a command option context.
|
|
45
47
|
def initialize
|
|
46
48
|
extend OptionInterface
|
|
47
49
|
@items = [] # option item definitions
|
|
48
50
|
@default = {} # default value table
|
|
49
51
|
@validators = [] # option validators
|
|
52
|
+
@parser_mode = :parse!
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
def item(name)
|
|
@@ -73,7 +76,7 @@ module Pione
|
|
|
73
76
|
|
|
74
77
|
# setup option parser
|
|
75
78
|
@items.sort{|a,b| a.long <=> b.long}.each {|item| setup_item(command_name, opt, data, item)}
|
|
76
|
-
end.
|
|
79
|
+
end.send(@parser_mode, argv)
|
|
77
80
|
|
|
78
81
|
# check option's validness
|
|
79
82
|
check(data)
|
|
@@ -8,7 +8,8 @@ module Pione
|
|
|
8
8
|
#
|
|
9
9
|
|
|
10
10
|
command_name "pione-clean"
|
|
11
|
-
command_banner "
|
|
11
|
+
command_banner "remove PIONE's temporary files, cache, and etc."
|
|
12
|
+
PioneCommand.add_subcommand("clean", self)
|
|
12
13
|
|
|
13
14
|
#
|
|
14
15
|
# options
|
|
@@ -16,6 +17,45 @@ module Pione
|
|
|
16
17
|
|
|
17
18
|
use_option :debug
|
|
18
19
|
|
|
20
|
+
# --older option
|
|
21
|
+
define_option(:older) do |item|
|
|
22
|
+
item.long = '--older=DATE'
|
|
23
|
+
item.desc = 'remove file older than the date'
|
|
24
|
+
item.default = false
|
|
25
|
+
item.value = proc do |str|
|
|
26
|
+
begin
|
|
27
|
+
Date.iso8601(str)
|
|
28
|
+
rescue ArgumentError
|
|
29
|
+
begin
|
|
30
|
+
Date.today - str.to_i
|
|
31
|
+
rescue
|
|
32
|
+
abort("invalid value of older option: %s" % str)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# --type option
|
|
39
|
+
define_option(:type) do |item|
|
|
40
|
+
item.long = '--type=NAME'
|
|
41
|
+
item.desc = 'remove only files of the type'
|
|
42
|
+
item.default = false
|
|
43
|
+
item.value = proc do |name|
|
|
44
|
+
case name
|
|
45
|
+
when "temporary"
|
|
46
|
+
:temporary
|
|
47
|
+
when "file-cache"
|
|
48
|
+
:file_cache
|
|
49
|
+
when "package-cache"
|
|
50
|
+
:package_cache
|
|
51
|
+
when "profile"
|
|
52
|
+
:profile
|
|
53
|
+
else
|
|
54
|
+
abort("unknown type: %s" % str)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
19
59
|
#
|
|
20
60
|
# command lifecycle: setup phase
|
|
21
61
|
#
|
|
@@ -30,34 +70,81 @@ module Pione
|
|
|
30
70
|
# command lifecycle: execution phase
|
|
31
71
|
#
|
|
32
72
|
|
|
33
|
-
execute :
|
|
34
|
-
execute :
|
|
35
|
-
execute :
|
|
36
|
-
execute :
|
|
73
|
+
execute :remove_temporary
|
|
74
|
+
execute :remove_file_cache
|
|
75
|
+
execute :remove_package_cache
|
|
76
|
+
execute :remove_profile
|
|
37
77
|
|
|
38
|
-
|
|
39
|
-
|
|
78
|
+
# Remove temporary files. This removes working files based on temporary
|
|
79
|
+
# directory's mtime.
|
|
80
|
+
def execute_remove_temporary
|
|
81
|
+
if type?(:temprary)
|
|
82
|
+
Location[Global.my_temporary_directory].each_entry do |entry|
|
|
83
|
+
if delete?(entry)
|
|
84
|
+
FileUtils.remove_entry_secure(entry.path)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
40
88
|
end
|
|
41
89
|
|
|
42
|
-
|
|
43
|
-
|
|
90
|
+
# Remove file cache files. This removes it base on cache directory's mtime.
|
|
91
|
+
def execute_remove_file_cache
|
|
92
|
+
if type?(:file_cache)
|
|
93
|
+
Location[Global.my_file_cache_directory].each_entry do |entry|
|
|
94
|
+
if delete?(entry)
|
|
95
|
+
FileUtils.remove_entry_secure(entry.path)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
44
99
|
end
|
|
45
100
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
101
|
+
# Remove package cache files.
|
|
102
|
+
def execute_remove_package_cache
|
|
103
|
+
if type?(:package_cache)
|
|
104
|
+
# remove PPG package
|
|
105
|
+
Global.ppg_package_cache_directory.each_entry do |entry|
|
|
106
|
+
unless @db.has_digest?(Package::PackageFilename.parse(entry.basename).digest)
|
|
107
|
+
if delete?(entry)
|
|
108
|
+
entry.delete
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# remove directory package
|
|
114
|
+
Global.directory_package_cache_directory.each_entry do |entry|
|
|
115
|
+
unless @db.has_digest?(entry.basename)
|
|
116
|
+
if delete?(entry)
|
|
117
|
+
entry.delete
|
|
118
|
+
end
|
|
119
|
+
end
|
|
50
120
|
end
|
|
51
121
|
end
|
|
52
122
|
end
|
|
53
123
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
124
|
+
# Remove profile reports.
|
|
125
|
+
def execute_remove_profile
|
|
126
|
+
if type?(:profile)
|
|
127
|
+
Location[Global.profile_report_directory].each_entry do |entry|
|
|
128
|
+
if delete?(entry)
|
|
129
|
+
entry.delete
|
|
130
|
+
end
|
|
58
131
|
end
|
|
59
132
|
end
|
|
60
133
|
end
|
|
134
|
+
|
|
135
|
+
#
|
|
136
|
+
# helper methods
|
|
137
|
+
#
|
|
138
|
+
|
|
139
|
+
# Return true if the entry has the type.
|
|
140
|
+
def type?(type)
|
|
141
|
+
option[:type].nil? or option[:type] == type
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Return true if the entry should be removed.
|
|
145
|
+
def delete?(entry)
|
|
146
|
+
option[:older].nil? or option[:older] >= entry.mtime.to_date
|
|
147
|
+
end
|
|
61
148
|
end
|
|
62
149
|
end
|
|
63
150
|
end
|