jupyter_on_rails 0.8.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +112 -55
- data/jupyter_on_rails.gemspec +2 -2
- data/lib/jupyter_on_rails/{iruby_kernel_extention.rb → initializer.rb} +6 -14
- data/lib/jupyter_on_rails/kernel.rb +5 -4
- data/lib/jupyter_on_rails/railtie/jupyter.rake +27 -5
- data/lib/jupyter_on_rails/version.rb +1 -1
- metadata +7 -10
- data/.github/FUNDING.yml +0 -2
- data/.github/workflows/ruby.yml +0 -29
- data/.gitignore +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cf8414bcf2477c6f0ab5f05153c2dfc284ca6efa13f4e13971d678c89129672
|
4
|
+
data.tar.gz: 3faf28c8f979d5e7b27e676ecd6e0ddab7306458a3d7f18abafc1dc3bc2eabdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca7ade7c2e39d21c09ef6e7030f0bdc1c4acc751fdc5a7c3aa2f0d97d7fbe9b025af9decae5886dbf5ee9483dd0a32b97bdc51404eab4d0e3ef281b761aa55e
|
7
|
+
data.tar.gz: ebe590b5ab2c2c0f0a262c6072a795e082467ffc27853fc8190f10f8090f7269ccb4a08284afa1be2ab195030cd2c5451b72d2fb918c99f888d69b0897840876
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jupyter_on_rails (0.
|
4
|
+
jupyter_on_rails (0.11.0)
|
5
5
|
daru
|
6
6
|
iruby
|
7
7
|
railties
|
@@ -9,119 +9,176 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (6.
|
13
|
-
actionview (= 6.
|
14
|
-
activesupport (= 6.
|
15
|
-
rack (~> 2.0, >= 2.0.
|
12
|
+
actionpack (6.1.4.1)
|
13
|
+
actionview (= 6.1.4.1)
|
14
|
+
activesupport (= 6.1.4.1)
|
15
|
+
rack (~> 2.0, >= 2.0.9)
|
16
16
|
rack-test (>= 0.6.3)
|
17
17
|
rails-dom-testing (~> 2.0)
|
18
18
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
19
|
-
actionview (6.
|
20
|
-
activesupport (= 6.
|
19
|
+
actionview (6.1.4.1)
|
20
|
+
activesupport (= 6.1.4.1)
|
21
21
|
builder (~> 3.1)
|
22
22
|
erubi (~> 1.4)
|
23
23
|
rails-dom-testing (~> 2.0)
|
24
24
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
25
|
-
activesupport (6.
|
25
|
+
activesupport (6.1.4.1)
|
26
26
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
27
|
-
i18n (>=
|
28
|
-
minitest (
|
29
|
-
tzinfo (~>
|
30
|
-
zeitwerk (~> 2.
|
31
|
-
addressable (2.
|
27
|
+
i18n (>= 1.6, < 2)
|
28
|
+
minitest (>= 5.1)
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
zeitwerk (~> 2.3)
|
31
|
+
addressable (2.8.0)
|
32
32
|
public_suffix (>= 2.0.2, < 5.0)
|
33
|
-
ast (2.4.
|
34
|
-
|
35
|
-
|
33
|
+
ast (2.4.2)
|
34
|
+
async (1.29.0)
|
35
|
+
console (~> 1.10)
|
36
|
+
nio4r (~> 2.3)
|
37
|
+
timers (~> 4.1)
|
38
|
+
async-http (0.56.2)
|
39
|
+
async (~> 1.25)
|
40
|
+
async-io (~> 1.28)
|
41
|
+
async-pool (~> 0.2)
|
42
|
+
protocol-http (~> 0.22.0)
|
43
|
+
protocol-http1 (~> 0.14.0)
|
44
|
+
protocol-http2 (~> 0.14.0)
|
45
|
+
async-http-faraday (0.9.0)
|
46
|
+
async-http (~> 0.42)
|
47
|
+
faraday
|
48
|
+
async-io (1.31.0)
|
49
|
+
async (~> 1.14)
|
50
|
+
async-pool (0.3.6)
|
51
|
+
async (~> 1.25)
|
52
|
+
backports (3.21.0)
|
36
53
|
builder (3.2.4)
|
37
|
-
bump (0.
|
38
|
-
concurrent-ruby (1.1.
|
54
|
+
bump (0.10.0)
|
55
|
+
concurrent-ruby (1.1.9)
|
56
|
+
console (1.12.0)
|
57
|
+
fiber-local
|
39
58
|
crass (1.0.6)
|
40
59
|
daru (0.3)
|
41
60
|
packable (~> 1.3.13)
|
42
61
|
data_uri (0.1.0)
|
43
62
|
erubi (1.10.0)
|
44
|
-
faraday (1.
|
63
|
+
faraday (1.4.2)
|
64
|
+
faraday-em_http (~> 1.0)
|
65
|
+
faraday-em_synchrony (~> 1.0)
|
66
|
+
faraday-excon (~> 1.1)
|
67
|
+
faraday-net_http (~> 1.0)
|
68
|
+
faraday-net_http_persistent (~> 1.1)
|
45
69
|
multipart-post (>= 1.2, < 3)
|
70
|
+
ruby2_keywords (>= 0.0.4)
|
71
|
+
faraday-em_http (1.0.0)
|
72
|
+
faraday-em_synchrony (1.0.0)
|
73
|
+
faraday-excon (1.1.0)
|
46
74
|
faraday-http-cache (2.2.0)
|
47
75
|
faraday (>= 0.8)
|
48
|
-
|
76
|
+
faraday-net_http (1.0.1)
|
77
|
+
faraday-net_http_persistent (1.1.0)
|
78
|
+
ffi (1.15.4)
|
79
|
+
ffi-rzmq (2.0.7)
|
80
|
+
ffi-rzmq-core (>= 1.0.7)
|
81
|
+
ffi-rzmq-core (1.0.7)
|
82
|
+
ffi
|
83
|
+
fiber-local (1.0.0)
|
84
|
+
github_changelog_generator (1.16.3)
|
49
85
|
activesupport
|
86
|
+
async (>= 1.25.0)
|
87
|
+
async-http-faraday
|
50
88
|
faraday-http-cache
|
51
89
|
multi_json
|
52
90
|
octokit (~> 4.6)
|
53
91
|
rainbow (>= 2.2.1)
|
54
92
|
rake (>= 10.0)
|
55
93
|
retriable (~> 3.0)
|
56
|
-
i18n (1.8.
|
94
|
+
i18n (1.8.10)
|
57
95
|
concurrent-ruby (~> 1.0)
|
58
|
-
|
59
|
-
|
96
|
+
io-console (0.5.9)
|
97
|
+
irb (1.3.7)
|
98
|
+
reline (>= 0.2.7)
|
99
|
+
iruby (0.7.4)
|
60
100
|
data_uri (~> 0.1)
|
61
|
-
|
101
|
+
ffi-rzmq
|
102
|
+
irb
|
103
|
+
mime-types (>= 3.3.1)
|
62
104
|
multi_json (~> 1.11)
|
63
|
-
|
105
|
+
native-package-installer
|
106
|
+
loofah (2.12.0)
|
64
107
|
crass (~> 1.0.2)
|
65
108
|
nokogiri (>= 1.5.9)
|
66
109
|
method_source (1.0.0)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
110
|
+
mime-types (3.4.1)
|
111
|
+
mime-types-data (~> 3.2015)
|
112
|
+
mime-types-data (3.2021.1115)
|
113
|
+
mini_portile2 (2.6.1)
|
114
|
+
minitest (5.14.4)
|
115
|
+
multi_json (1.15.0)
|
71
116
|
multipart-post (2.1.1)
|
72
|
-
|
73
|
-
|
117
|
+
native-package-installer (1.1.1)
|
118
|
+
nio4r (2.5.7)
|
119
|
+
nokogiri (1.12.5)
|
120
|
+
mini_portile2 (~> 2.6.1)
|
74
121
|
racc (~> 1.4)
|
75
|
-
octokit (4.
|
122
|
+
octokit (4.21.0)
|
76
123
|
faraday (>= 0.9)
|
77
124
|
sawyer (~> 0.8.0, >= 0.5.3)
|
78
|
-
packable (1.3.
|
125
|
+
packable (1.3.15)
|
79
126
|
backports
|
80
127
|
parallel (1.20.1)
|
81
|
-
parser (3.0.
|
128
|
+
parser (3.0.1.1)
|
82
129
|
ast (~> 2.4.1)
|
83
|
-
|
84
|
-
|
130
|
+
protocol-hpack (1.4.2)
|
131
|
+
protocol-http (0.22.0)
|
132
|
+
protocol-http1 (0.14.1)
|
133
|
+
protocol-http (~> 0.22)
|
134
|
+
protocol-http2 (0.14.2)
|
135
|
+
protocol-hpack (~> 1.4)
|
136
|
+
protocol-http (~> 0.18)
|
137
|
+
public_suffix (4.0.6)
|
138
|
+
racc (1.6.0)
|
85
139
|
rack (2.2.3)
|
86
140
|
rack-test (1.1.0)
|
87
141
|
rack (>= 1.0, < 3)
|
88
142
|
rails-dom-testing (2.0.3)
|
89
143
|
activesupport (>= 4.2.0)
|
90
144
|
nokogiri (>= 1.6)
|
91
|
-
rails-html-sanitizer (1.
|
145
|
+
rails-html-sanitizer (1.4.2)
|
92
146
|
loofah (~> 2.3)
|
93
|
-
railties (6.
|
94
|
-
actionpack (= 6.
|
95
|
-
activesupport (= 6.
|
147
|
+
railties (6.1.4.1)
|
148
|
+
actionpack (= 6.1.4.1)
|
149
|
+
activesupport (= 6.1.4.1)
|
96
150
|
method_source
|
97
|
-
rake (>= 0.
|
98
|
-
thor (
|
151
|
+
rake (>= 0.13)
|
152
|
+
thor (~> 1.0)
|
99
153
|
rainbow (3.0.0)
|
100
|
-
rake (13.0.
|
101
|
-
regexp_parser (2.
|
154
|
+
rake (13.0.3)
|
155
|
+
regexp_parser (2.1.1)
|
156
|
+
reline (0.2.7)
|
157
|
+
io-console (~> 0.5)
|
102
158
|
retriable (3.1.2)
|
103
|
-
rexml (3.2.
|
104
|
-
rubocop (1.
|
159
|
+
rexml (3.2.5)
|
160
|
+
rubocop (1.15.0)
|
105
161
|
parallel (~> 1.10)
|
106
162
|
parser (>= 3.0.0.0)
|
107
163
|
rainbow (>= 2.2.2, < 4.0)
|
108
164
|
regexp_parser (>= 1.8, < 3.0)
|
109
165
|
rexml
|
110
|
-
rubocop-ast (>= 1.
|
166
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
111
167
|
ruby-progressbar (~> 1.7)
|
112
168
|
unicode-display_width (>= 1.4.0, < 3.0)
|
113
|
-
rubocop-ast (1.
|
114
|
-
parser (>=
|
169
|
+
rubocop-ast (1.6.0)
|
170
|
+
parser (>= 3.0.1.1)
|
115
171
|
ruby-progressbar (1.11.0)
|
172
|
+
ruby2_keywords (0.0.4)
|
116
173
|
sawyer (0.8.2)
|
117
174
|
addressable (>= 2.3.5)
|
118
175
|
faraday (> 0.8, < 2.0)
|
119
|
-
thor (1.0
|
120
|
-
|
121
|
-
tzinfo (
|
122
|
-
|
176
|
+
thor (1.1.0)
|
177
|
+
timers (4.3.3)
|
178
|
+
tzinfo (2.0.4)
|
179
|
+
concurrent-ruby (~> 1.0)
|
123
180
|
unicode-display_width (2.0.0)
|
124
|
-
zeitwerk (2.4.
|
181
|
+
zeitwerk (2.4.2)
|
125
182
|
|
126
183
|
PLATFORMS
|
127
184
|
ruby
|
@@ -134,4 +191,4 @@ DEPENDENCIES
|
|
134
191
|
rubocop
|
135
192
|
|
136
193
|
BUNDLED WITH
|
137
|
-
2.
|
194
|
+
2.2.22
|
data/jupyter_on_rails.gemspec
CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
32
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
33
33
|
`git ls-files -z`.split("\x0")
|
34
|
-
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
35
|
-
.reject { |f| f.match(
|
34
|
+
.reject { |f| f.match(%r{^(test|spec|features|\.github)/}) }
|
35
|
+
.reject { |f| f.match(/(\.gitignore|\.png)$/) }
|
36
36
|
end
|
37
37
|
spec.bindir = 'exe'
|
38
38
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -1,12 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module JupyterOnRails
|
4
|
-
module
|
5
|
-
|
6
|
-
attr_accessor :root, :sandbox
|
7
|
-
end
|
8
|
-
|
9
|
-
def run
|
4
|
+
module Initializer
|
5
|
+
def self.run(root:, sandbox:)
|
10
6
|
# Load Daru extensions
|
11
7
|
begin
|
12
8
|
require 'daru'
|
@@ -25,22 +21,18 @@ module JupyterOnRails
|
|
25
21
|
end
|
26
22
|
|
27
23
|
original = Dir.pwd
|
28
|
-
root = IRubyKernelExtention.root
|
29
24
|
Dir.chdir root
|
30
25
|
app_file = File.expand_path('config/environment.rb', root)
|
31
26
|
require app_file
|
32
27
|
Rails.application.require_environment!
|
33
28
|
Dir.chdir original
|
34
29
|
|
35
|
-
|
36
|
-
ActiveRecord::Base.connection.begin_transaction(joinable: false)
|
30
|
+
return unless sandbox
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
ActiveRecord::Base.connection.begin_transaction(joinable: false)
|
33
|
+
at_exit do
|
34
|
+
ActiveRecord::Base.connection.rollback_transaction
|
41
35
|
end
|
42
|
-
|
43
|
-
super
|
44
36
|
end
|
45
37
|
end
|
46
38
|
end
|
@@ -20,12 +20,13 @@ module JupyterOnRails
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def load_extensions
|
23
|
-
require_relative '
|
24
|
-
JupyterOnRails::IRubyKernelExtention.root = @root
|
25
|
-
JupyterOnRails::IRubyKernelExtention.sandbox = @sandbox
|
23
|
+
require_relative 'initializer'
|
26
24
|
|
27
25
|
require 'iruby'
|
28
|
-
IRuby::Kernel.
|
26
|
+
IRuby::Kernel.events.register(:initialized) do |_kernel|
|
27
|
+
JupyterOnRails::Initializer.run(root: @root, sandbox: @sandbox)
|
28
|
+
end
|
29
|
+
|
29
30
|
IRuby::Display::Registry.instance_eval do
|
30
31
|
match do |obj|
|
31
32
|
obj.is_a?(ActiveRecord::Relation) ||
|
@@ -6,21 +6,43 @@ require 'ostruct'
|
|
6
6
|
|
7
7
|
# rubocop:disable Metrics/BlockLength
|
8
8
|
namespace :jupyter do
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
exec_jupyter_command = lambda do |subcomand|
|
11
11
|
ipython_dir = ENV['IPYTHONDIR'] || Rails.root / '.ipython'
|
12
12
|
|
13
13
|
env = { 'JUPYTER_DATA_DIR' => ipython_dir.to_s }
|
14
|
-
commands =
|
15
|
-
|
14
|
+
commands = ['jupyter', subcomand]
|
15
|
+
|
16
|
+
if (Rails.root / 'pyproject.toml').exist?
|
17
|
+
commands = %w[poetry run] + commands
|
18
|
+
elsif (Rails.root / 'Pipfile').exist?
|
19
|
+
commands = %w[pipenv run] + commands
|
20
|
+
end
|
21
|
+
|
16
22
|
Process.exec(env, *commands)
|
17
23
|
end
|
18
24
|
|
25
|
+
desc 'start jupyter notebook'
|
26
|
+
task notebook: :install_kernels do
|
27
|
+
instance_exec('notebook', &exec_jupyter_command)
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'start jupyter lab'
|
31
|
+
task lab: :install_kernels do
|
32
|
+
instance_exec('lab', &exec_jupyter_command)
|
33
|
+
end
|
34
|
+
|
19
35
|
desc 'Install the kernel'
|
20
36
|
task :install_kernels do
|
21
37
|
root = Rails.root
|
22
38
|
ipython_dir = ENV['JUPYTER_DATA_DIR'] || ENV['IPYTHONDIR'] || root / '.ipython'
|
23
39
|
ipython_dir = File.absolute_path(ipython_dir.to_s)
|
40
|
+
application_module =
|
41
|
+
if Rails::VERSION::MAJOR >= 6
|
42
|
+
Rails.application.class.module_parent
|
43
|
+
else
|
44
|
+
Rails.application.class.parent
|
45
|
+
end
|
24
46
|
|
25
47
|
sh "JUPYTER_DATA_DIR=#{Shellwords.shellescape(ipython_dir.to_s)} bundle exec iruby register --force"
|
26
48
|
|
@@ -35,7 +57,7 @@ namespace :jupyter do
|
|
35
57
|
kernel_file = File.expand_path("kernels/#{cfg.kernel_name}/kernel.json", ipython_dir.to_s)
|
36
58
|
kernel_h = JSON.parse(File.read(kernel_file))
|
37
59
|
kernel_h['argv'] << File.expand_path(cfg.boot_file, __dir__)
|
38
|
-
kernel_h['display_name'] = "#{
|
60
|
+
kernel_h['display_name'] = "#{application_module} (rails #{Rails.version}#{cfg.name_ext})"
|
39
61
|
kernel_h['env'] ||= {}
|
40
62
|
kernel_h['env']['RAILS_ROOT'] = root.to_s
|
41
63
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jupyter_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuki INOUE
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|
@@ -115,9 +115,6 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- ".github/FUNDING.yml"
|
119
|
-
- ".github/workflows/ruby.yml"
|
120
|
-
- ".gitignore"
|
121
118
|
- ".rubocop.yml"
|
122
119
|
- CHANGELOG.md
|
123
120
|
- Gemfile
|
@@ -133,7 +130,7 @@ files:
|
|
133
130
|
- lib/jupyter_on_rails/boot_sandbox.rb
|
134
131
|
- lib/jupyter_on_rails/daru/active_record_ext.rb
|
135
132
|
- lib/jupyter_on_rails/daru/data_frame_ext.rb
|
136
|
-
- lib/jupyter_on_rails/
|
133
|
+
- lib/jupyter_on_rails/initializer.rb
|
137
134
|
- lib/jupyter_on_rails/kernel.rb
|
138
135
|
- lib/jupyter_on_rails/railtie.rb
|
139
136
|
- lib/jupyter_on_rails/railtie/jupyter.rake
|
@@ -144,7 +141,7 @@ metadata:
|
|
144
141
|
allowed_push_host: https://rubygems.org
|
145
142
|
homepage_uri: https://github.com/Yuki-Inoue/jupyter_on_rails
|
146
143
|
source_code_uri: https://github.com/Yuki-Inoue/jupyter_on_rails
|
147
|
-
post_install_message:
|
144
|
+
post_install_message:
|
148
145
|
rdoc_options: []
|
149
146
|
require_paths:
|
150
147
|
- lib
|
@@ -159,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
156
|
- !ruby/object:Gem::Version
|
160
157
|
version: '0'
|
161
158
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
163
|
-
signing_key:
|
159
|
+
rubygems_version: 3.1.6
|
160
|
+
signing_key:
|
164
161
|
specification_version: 4
|
165
162
|
summary: Integrate jupyter into rails
|
166
163
|
test_files: []
|
data/.github/FUNDING.yml
DELETED
data/.github/workflows/ruby.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
name: Ruby
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
build:
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v2
|
14
|
-
- name: Set up Ruby
|
15
|
-
uses: actions/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: 2.7.2
|
18
|
-
# https://github.com/actions/cache/blob/master/examples.md#ruby---bundler
|
19
|
-
- uses: actions/cache@v1
|
20
|
-
with:
|
21
|
-
path: vendor/bundle
|
22
|
-
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
|
23
|
-
restore-keys: |
|
24
|
-
${{ runner.os }}-gems-
|
25
|
-
- name: Build and test with Rake
|
26
|
-
run: |
|
27
|
-
gem install bundler
|
28
|
-
bundle install --jobs 4 --retry 3 --path vendor/bundle
|
29
|
-
bundle exec rubocop
|