iron_worker_ng 0.13.1 → 0.14.0

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.
@@ -190,7 +190,7 @@ module IronWorkerNG
190
190
  log_group 'Generating code package webhook'
191
191
 
192
192
  log 'You can invoke your worker by POSTing to the following URL'
193
- log "#{client.api.url(client.api.project_id)}/tasks/webhook?code_name=#{name}&oauth=#{client.api.token}"
193
+ log client.api.url("projects/#{client.api.project_id}/tasks/webhook?code_name=#{name}&oauth=#{client.api.token}")
194
194
  end
195
195
 
196
196
  def info_code(name, params, options)
@@ -18,6 +18,8 @@ module IronWorkerNG
18
18
  attr_accessor :base_dir
19
19
  attr_accessor :dest_dir
20
20
 
21
+ attr_accessor :use_local_iron_worker_ng
22
+
21
23
  undef exec
22
24
  undef gem
23
25
 
@@ -39,6 +41,8 @@ module IronWorkerNG
39
41
  @name = nil
40
42
  @exec = nil
41
43
 
44
+ @use_local_iron_worker_ng = false
45
+
42
46
  worker_files = []
43
47
 
44
48
  if args.length == 1 && args[0].is_a?(String)
@@ -257,6 +261,13 @@ RUNNER
257
261
  builder = IronWorkerNG::Code::Builder.new
258
262
  builder.builder_remote_build_command = @remote_build_command
259
263
 
264
+ builder.use_local_iron_worker_ng = @use_local_iron_worker_ng
265
+
266
+ if @use_local_iron_worker_ng
267
+ builder.gem('iron_worker_ng')
268
+ builder.fixate
269
+ end
270
+
260
271
  builder.bundle(container, local)
261
272
 
262
273
  container.get_output_stream(@name + '.worker') do |wf|
@@ -15,6 +15,8 @@ module IronWorkerNG
15
15
  @remote_build_command = nil
16
16
  @full_remote_build = false
17
17
 
18
+ @use_local_iron_worker_ng = false
19
+
18
20
  runtime(:ruby)
19
21
  end
20
22
 
@@ -32,6 +34,12 @@ BUILDER_SH
32
34
  end
33
35
  end
34
36
 
37
+ install_iron_worker_ng = ''
38
+
39
+ if not @use_local_iron_worker_ng
40
+ install_iron_worker_ng = "system(\"gem install iron_worker_ng -v #{IronWorkerNG::VERSION}\")"
41
+ end
42
+
35
43
  container.get_output_stream(@dest_dir + '__builder__.rb') do |builder|
36
44
  builder.write <<BUILDER_RUBY
37
45
  # #{IronWorkerNG.full_version}
@@ -42,7 +50,7 @@ File.open('.gemrc', 'w') do |gemrc|
42
50
  gemrc.puts('gem: --no-ri --no-rdoc')
43
51
  end
44
52
 
45
- puts `gem install iron_worker_ng -v #{IronWorkerNG::VERSION}`
53
+ #{install_iron_worker_ng}
46
54
 
47
55
  require 'iron_worker_ng'
48
56
 
@@ -1,12 +1,16 @@
1
+ require_relative '../../feature/python/merge_pip_dependency'
2
+ require_relative '../../feature/python/merge_pip'
3
+
1
4
  module IronWorkerNG
2
5
  module Code
3
6
  module Runtime
4
7
  module Python
5
8
  include IronWorkerNG::Feature::Common::MergeExec::InstanceMethods
9
+ include IronWorkerNG::Feature::Python::MergePipDependency::InstanceMethods
6
10
 
7
11
  def runtime_run_code(local = false)
8
12
  <<RUN_CODE
9
- python #{File.basename(@exec.path)} "$@"
13
+ PYTHONPATH=`pwd`/__pips__ python #{File.basename(@exec.path)} "$@"
10
14
  RUN_CODE
11
15
  end
12
16
  end
@@ -0,0 +1,37 @@
1
+ require 'tmpdir'
2
+ require 'fileutils'
3
+
4
+ module IronWorkerNG
5
+ module Feature
6
+ module Python
7
+ module MergePip
8
+ class Feature < IronWorkerNG::Feature::Base
9
+ attr_reader :deps
10
+
11
+ def initialize(code, deps)
12
+ super(code)
13
+
14
+ @deps = deps
15
+ end
16
+
17
+ def bundle(container)
18
+ IronCore::Logger.debug 'IronWorkerNG', "Bundling pip dependencies"
19
+
20
+ tmp_dir_name = ::Dir.tmpdir + '/' + ::Dir::Tmpname.make_tmpname('iron-worker-ng-', 'pips')
21
+
22
+ ::Dir.mkdir(tmp_dir_name)
23
+
24
+ deps_string = @deps.map { |dep| dep.version == '' ? dep.name : dep.name + '==' + dep.version }.join(' ')
25
+ install_command = 'pip install --upgrade --install-option="--install-purelib=' + tmp_dir_name + '" ' + deps_string
26
+
27
+ system(install_command)
28
+
29
+ container_add(container, '__pips__', tmp_dir_name, true)
30
+
31
+ FileUtils.rm_rf(tmp_dir_name)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,55 @@
1
+ module IronWorkerNG
2
+ module Feature
3
+ module Python
4
+ module MergePipDependency
5
+ class Feature < IronWorkerNG::Feature::Base
6
+ attr_reader :name
7
+ attr_reader :version
8
+
9
+ def initialize(code, name, version)
10
+ super(code)
11
+
12
+ @name = name
13
+ @version = version
14
+ end
15
+
16
+ def build_command
17
+ if @code.full_remote_build
18
+ "pip '#{@name}', '#{@version}'"
19
+ elsif @code.remote_build_command
20
+ "dir '__build__/__pips__'"
21
+ else
22
+ nil
23
+ end
24
+ end
25
+ end
26
+
27
+ module InstanceMethods
28
+ def merge_pip(name, version = '')
29
+ IronCore::Logger.info 'IronWorkerNG', "Adding python pip dependency with name='#{name}' and version='#{version}'"
30
+
31
+ @features << IronWorkerNG::Feature::Python::MergePipDependency::Feature.new(self, name, version)
32
+
33
+ unless @fixators.include?(:merge_pip_dependency_fixate)
34
+ @fixators << :merge_pip_dependency_fixate
35
+ end
36
+ end
37
+
38
+ alias :pip :merge_pip
39
+
40
+ def merge_pip_dependency_fixate
41
+ if not full_remote_build
42
+ IronCore::Logger.info 'IronWorkerNG', 'Fixating pip dependencies'
43
+
44
+ @features.reject! { |f| f.class == IronWorkerNG::Feature::Python::MergePip::Feature }
45
+
46
+ deps = @features.reject { |f| f.class != IronWorkerNG::Feature::Python::MergePipDependency::Feature }
47
+
48
+ @features << IronWorkerNG::Feature::Python::MergePip::Feature.new(self, deps)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,5 +1,5 @@
1
1
  module IronWorkerNG
2
- VERSION = '0.13.1'
2
+ VERSION = '0.14.0'
3
3
 
4
4
  def self.version
5
5
  VERSION
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: 0.13.1
4
+ version: 0.14.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-26 00:00:00.000000000 Z
13
+ date: 2012-12-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: iron_core
@@ -161,6 +161,8 @@ files:
161
161
  - lib/iron_worker_ng/code/php.rb
162
162
  - lib/iron_worker_ng/code/go.rb
163
163
  - lib/iron_worker_ng/feature/base.rb
164
+ - lib/iron_worker_ng/feature/python/merge_pip.rb
165
+ - lib/iron_worker_ng/feature/python/merge_pip_dependency.rb
164
166
  - lib/iron_worker_ng/feature/java/merge_jar.rb
165
167
  - lib/iron_worker_ng/feature/ruby/merge_gem_dependency.rb
166
168
  - lib/iron_worker_ng/feature/ruby/merge_gem.rb