iron_worker_ng 1.6.3 → 1.6.4
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 +4 -4
- data/README.md +18 -0
- data/lib/iron_worker_ng/code/runtime/node.rb +6 -0
- data/lib/iron_worker_ng/code/runtime/php.rb +2 -1
- data/lib/iron_worker_ng/code/runtime/python.rb +2 -0
- data/lib/iron_worker_ng/code/runtime/ruby.rb +11 -0
- data/lib/iron_worker_ng/feature/python/merge_pip.rb +2 -1
- data/lib/iron_worker_ng/feature/python/merge_requirements.rb +35 -0
- data/lib/iron_worker_ng/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dceb21b4e176225f0a5734c84418c1869057002
|
4
|
+
data.tar.gz: 0a4661a382515893776e9fe322966dce35348e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4f81f7d49ee9780b5309059706c289256de133322b761ff7c0cd2133fb2721881ea57fa15d6575047e803f91dbdf2c71919399da05aedc7b510d0a6d24d7ba8
|
7
|
+
data.tar.gz: 98cc687d4f7b4e3cc91cbcf73435bdee44cd299081672d47b87c3b8bf75772e67ddb4912fe7fc5d4cbf3838a0e2338ec1d8173c8bd256ca5e879a1b472502ffb
|
data/README.md
CHANGED
@@ -415,6 +415,24 @@ code.merge_pip 'iron_mq'
|
|
415
415
|
code.merge_pip 'iron_worker', '==0.2'
|
416
416
|
```
|
417
417
|
|
418
|
+
### merge_requirements(path)
|
419
|
+
### requirements(path)
|
420
|
+
|
421
|
+
Merge all libraries from a python standard requirements.txt.
|
422
|
+
The requirements.txt example file after freezing may look like as follows:
|
423
|
+
|
424
|
+
```txt
|
425
|
+
Flask==0.8
|
426
|
+
Jinja2==2.6
|
427
|
+
Werkzeug==0.8.3
|
428
|
+
certifi==0.0.8
|
429
|
+
chardet==1.0.
|
430
|
+
```
|
431
|
+
|
432
|
+
```ruby
|
433
|
+
code.merge_requirements '../requirements.txt'
|
434
|
+
```
|
435
|
+
|
418
436
|
# Upload Your Worker
|
419
437
|
|
420
438
|
When you have your code package, you are ready to upload and run it on the IronWorker cloud.
|
@@ -13,6 +13,7 @@ var fs = require('fs');
|
|
13
13
|
var querystring = require('querystring');
|
14
14
|
var params = null;
|
15
15
|
var task_id = null;
|
16
|
+
var schedule_id = null;
|
16
17
|
var config = null;
|
17
18
|
|
18
19
|
process.argv.forEach(function(val, index, array) {
|
@@ -39,11 +40,16 @@ process.argv.forEach(function(val, index, array) {
|
|
39
40
|
if (val == "-id") {
|
40
41
|
task_id = process.argv[index + 1];
|
41
42
|
}
|
43
|
+
|
44
|
+
if (val == "-schedule_id") {
|
45
|
+
schedule_id = process.argv[index + 1];
|
46
|
+
}
|
42
47
|
});
|
43
48
|
|
44
49
|
exports.params = params;
|
45
50
|
exports.config = config;
|
46
51
|
exports.task_id = task_id;
|
52
|
+
exports.schedule_id = schedule_id;
|
47
53
|
|
48
54
|
NODE_RUNNER
|
49
55
|
end
|
@@ -13,13 +13,14 @@ module IronWorkerNG
|
|
13
13
|
function getArgs($assoc = true) {
|
14
14
|
global $argv;
|
15
15
|
|
16
|
-
$args = array('task_id' => null, 'dir' => null, 'payload' => array(), 'config' => null);
|
16
|
+
$args = array('task_id' => null, 'dir' => null, 'payload' => array(), 'config' => null, 'schedule_id' => null);
|
17
17
|
|
18
18
|
foreach ($argv as $k => $v) {
|
19
19
|
if (empty($argv[$k + 1])) continue;
|
20
20
|
|
21
21
|
if ($v == '-id') $args['task_id'] = $argv[$k + 1];
|
22
22
|
if ($v == '-d') $args['dir'] = $argv[$k + 1];
|
23
|
+
if ($v == '-schedule_id') $args['schedule_id'] = $argv[$k + 1];
|
23
24
|
|
24
25
|
if ($v == '-payload' && file_exists($argv[$k + 1])) {
|
25
26
|
$args['payload'] = file_get_contents($argv[$k + 1]);
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'iron_worker_ng/feature/python/merge_pip_dependency'
|
2
2
|
require 'iron_worker_ng/feature/python/merge_pip'
|
3
|
+
require 'iron_worker_ng/feature/python/merge_requirements'
|
3
4
|
|
4
5
|
module IronWorkerNG
|
5
6
|
module Code
|
@@ -7,6 +8,7 @@ module IronWorkerNG
|
|
7
8
|
module Python
|
8
9
|
include IronWorkerNG::Feature::Common::MergeExec::InstanceMethods
|
9
10
|
include IronWorkerNG::Feature::Python::MergePipDependency::InstanceMethods
|
11
|
+
include IronWorkerNG::Feature::Python::MergeRequirements::InstanceMethods
|
10
12
|
|
11
13
|
def runtime_run_code(local, params)
|
12
14
|
<<RUN_CODE
|
@@ -32,12 +32,14 @@ root = nil
|
|
32
32
|
payload_file = nil
|
33
33
|
config_file = nil
|
34
34
|
task_id = nil
|
35
|
+
schedule_id = nil
|
35
36
|
|
36
37
|
0.upto($*.length - 2) do |i|
|
37
38
|
root = $*[i + 1] if $*[i] == '-d'
|
38
39
|
payload_file = $*[i + 1] if $*[i] == '-payload'
|
39
40
|
config_file = $*[i + 1] if $*[i] == '-config'
|
40
41
|
task_id = $*[i + 1] if $*[i] == '-id'
|
42
|
+
schedule_id = $*[i + 1] if $*[i] == '-schedule_id'
|
41
43
|
end
|
42
44
|
|
43
45
|
ENV['GEM_PATH'] = ([root + '__gems__'] + (ENV['GEM_PATH'] || '').split(':')).join(':')
|
@@ -49,6 +51,7 @@ require 'json'
|
|
49
51
|
require 'yaml'
|
50
52
|
|
51
53
|
@iron_task_id = task_id
|
54
|
+
@iron_schedule_id = schedule_id
|
52
55
|
|
53
56
|
@payload = File.read(payload_file)
|
54
57
|
|
@@ -96,6 +99,10 @@ def iron_task_id
|
|
96
99
|
@iron_task_id
|
97
100
|
end
|
98
101
|
|
102
|
+
def iron_schedule_id
|
103
|
+
@iron_schedule_id
|
104
|
+
end
|
105
|
+
|
99
106
|
require '#{File.basename(@exec.path)}'
|
100
107
|
|
101
108
|
unless #{@exec.arg(:class, 0) == nil}
|
@@ -114,6 +121,10 @@ unless #{@exec.arg(:class, 0) == nil}
|
|
114
121
|
exec_inst.send(:iron_task_id=, iron_task_id)
|
115
122
|
end
|
116
123
|
|
124
|
+
if exec_inst.respond_to?(:iron_schedule_id=)
|
125
|
+
exec_inst.send(:iron_schedule_id=, iron_schedule_id)
|
126
|
+
end
|
127
|
+
|
117
128
|
exec_inst.run
|
118
129
|
end
|
119
130
|
RUBY_RUNNER
|
@@ -21,7 +21,7 @@ module IronWorkerNG
|
|
21
21
|
|
22
22
|
::Dir.mkdir(pip_dir_name)
|
23
23
|
|
24
|
-
p = 'pip-
|
24
|
+
p = 'pip-6.0.8'
|
25
25
|
`cd #{pip_dir_name} && curl -O https://pypi.python.org/packages/source/p/pip/#{p}.tar.gz && tar xf #{p}.tar.gz && cd #{p} && python setup.py install --user --root #{pip_dir_name} && cd .. && rm -rf #{p} #{p}.tar.gz`
|
26
26
|
|
27
27
|
pip_packages_dir = ::Dir.glob(pip_dir_name + ENV['HOME'] + '/.local/lib/python*').first
|
@@ -44,6 +44,7 @@ module IronWorkerNG
|
|
44
44
|
deps_string = @deps.map { |dep| dep.name + dep.version.to_s.sub(/\A\d/, '==\0') }.join(' ')
|
45
45
|
install_command = pip_binary + ' install -U -I --user --root ' + pips_dir_name + ' ' + deps_string
|
46
46
|
|
47
|
+
puts install_command
|
47
48
|
fork do
|
48
49
|
ENV['PYTHONPATH'] = pip_packages_dir + '/site-packages:' + pip_packages_dir + '/dist-packages'
|
49
50
|
puts `#{install_command}`
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module IronWorkerNG
|
2
|
+
module Feature
|
3
|
+
module Python
|
4
|
+
module MergeRequirements
|
5
|
+
module InstanceMethods
|
6
|
+
|
7
|
+
def merge_requirements(path)
|
8
|
+
feature = IronWorkerNG::Feature::Base.new(self)
|
9
|
+
IronWorkerNG::Fetcher.fetch_to_file(feature.rebase(path)) do |requirements|
|
10
|
+
specs = parse_requirements(requirements)
|
11
|
+
specs.each {|spec| merge_pip(spec[:name], spec[:version])}
|
12
|
+
end
|
13
|
+
@features << feature
|
14
|
+
end
|
15
|
+
|
16
|
+
alias :requirements :merge_requirements
|
17
|
+
|
18
|
+
private
|
19
|
+
def parse_requirements(file)
|
20
|
+
specs = []
|
21
|
+
File.readlines(file).each do |line|
|
22
|
+
line = line.strip
|
23
|
+
next if line.to_s.empty? || line.start_with?('#')
|
24
|
+
spec = line.split(/(==|>=|<=|<|>)/, 2)
|
25
|
+
version = spec[1]? spec[1]+spec[2]: ''
|
26
|
+
specs << {name: spec[0], version:version}
|
27
|
+
end
|
28
|
+
specs
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iron_worker_ng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kirilenko
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: iron_core
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/iron_worker_ng/feature/java/merge_jar.rb
|
217
217
|
- lib/iron_worker_ng/feature/python/merge_pip.rb
|
218
218
|
- lib/iron_worker_ng/feature/python/merge_pip_dependency.rb
|
219
|
+
- lib/iron_worker_ng/feature/python/merge_requirements.rb
|
219
220
|
- lib/iron_worker_ng/feature/ruby/merge_gem.rb
|
220
221
|
- lib/iron_worker_ng/feature/ruby/merge_gem_dependency.rb
|
221
222
|
- lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
|