pycall_thread 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/examples/puma/Gemfile +2 -2
- data/examples/puma/app.rb +11 -10
- data/lib/pycall_thread/version.rb +1 -1
- data/lib/pycall_thread.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f06a9a4d8b09d14190d2001b9463bdd9101df77ced43e4cf898247718d69b1a
|
4
|
+
data.tar.gz: 0e0121315ee956037688ad7016621dc3f667c4ec99e05f7541a3a74b4ea61b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 168d6a9aa3c30ece2692ee3bb92502dbabd766097c3e2a90849f3d7d61384806b1e658cb8008c34714a2617c83ca416c395da55c44d2da4d62318d30062385a8
|
7
|
+
data.tar.gz: fc32925321e4ea1812ecde6416ef6d90130bbc6254a72beaeb265710ed18fc6f44fd1ebc0bf9fcdf7b7eb8d01829ab126cb2f0676c72b86039dda5e0c4c39683
|
data/Gemfile.lock
CHANGED
data/examples/puma/Gemfile
CHANGED
data/examples/puma/app.rb
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require "pycall_thread"
|
2
2
|
|
3
3
|
PyCallThread.init do
|
4
4
|
# Setup our local venv (using pdm, in .venv)
|
5
|
-
ENV[
|
5
|
+
ENV["PYTHON"] = `pdm run which python`.strip
|
6
6
|
site_dir = `pdm run python -c 'import site; print(site.getsitepackages()[0])'`.strip
|
7
7
|
|
8
|
-
require
|
8
|
+
require "pycall"
|
9
9
|
|
10
10
|
# This is to setup our local venv
|
11
|
-
site = PyCall.import_module(
|
11
|
+
site = PyCall.import_module("site")
|
12
12
|
site.addsitedir(site_dir)
|
13
13
|
end
|
14
14
|
|
15
|
+
# Simple Puma App that demonstrates PyCallThread
|
15
16
|
class App
|
16
|
-
def call(
|
17
|
+
def call(_)
|
17
18
|
winequality = PyCallThread.run do
|
18
|
-
pandas = PyCall.import_module(
|
19
|
-
data = pandas.read_csv(
|
20
|
-
data.
|
19
|
+
pandas = PyCall.import_module("pandas")
|
20
|
+
data = pandas.read_csv("https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv", sep: ";")
|
21
|
+
data.to_html
|
21
22
|
end
|
22
23
|
|
23
|
-
[200, {
|
24
|
+
[200, { "Content-Type" => "text/html" }, [winequality]]
|
24
25
|
end
|
25
|
-
end
|
26
|
+
end
|
data/lib/pycall_thread.rb
CHANGED
@@ -22,7 +22,7 @@ module PyCallThread
|
|
22
22
|
@initialized = true
|
23
23
|
end
|
24
24
|
|
25
|
-
def require_pycall(&require_pycall_block)
|
25
|
+
def self.require_pycall(&require_pycall_block)
|
26
26
|
# Only safe to use PyCallThread if PyCall hasn't already been loaded
|
27
27
|
raise "PyCall::LibPython already exists: PyCall can't have been initialized already" if defined?(PyCall::LibPython)
|
28
28
|
|