-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement PyCallThread as a library, and give a puma example
- Loading branch information
Showing
14 changed files
with
75 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
PATH | ||
remote: /Users/seth/src/pycall.rb | ||
specs: | ||
pycall (1.5.2) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
nio4r (2.7.3) | ||
puma (6.4.2) | ||
nio4r (~> 2.0) | ||
pycall (1.5.2) | ||
|
||
PLATFORMS | ||
arm64-darwin-23 | ||
|
||
DEPENDENCIES | ||
puma (~> 6.4.1) | ||
pycall! | ||
pycall | ||
|
||
BUNDLED WITH | ||
2.3.22 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require_relative '../../lib/pycall_thread/pycall_thread' | ||
|
||
PyCallThread.init do | ||
# Setup our local venv (using pdm, in .venv) | ||
ENV['PYTHON'] = `pdm run which python`.strip | ||
site_dir = `pdm run python -c 'import site; print(site.getsitepackages()[0])'`.strip | ||
|
||
require 'pycall' | ||
|
||
# This is to setup our local venv | ||
site = PyCall.import_module('site') | ||
site.addsitedir(site_dir) | ||
end | ||
|
||
class App | ||
def call(env) | ||
winequality = PyCallThread.run do | ||
pandas = PyCall.import_module('pandas') | ||
data = pandas.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-red.csv', sep: ';') | ||
data.to_html() | ||
end | ||
|
||
[200, { 'Content-Type' => 'text/html' }, [winequality]] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require './app' | ||
|
||
run App.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
# Start Puma with 3 threads on port 9292 | ||
puma -t 3:3 -p 9292 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ requires-python = "==3.12.*" | |
|
||
dependencies = [ | ||
"pandas", | ||
"psutil>=6.0.0", | ||
] | ||
|
||
[tool.pdm] | ||
|