Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Activate venv at server start and remove the check from functions#1276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SilasMarvin merged 1 commit intomasterfromsilas-venv-check-move
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletionspgml-extension/src/bindings/langchain/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,8 +8,6 @@ use crate::create_pymodule;
create_pymodule!("/src/bindings/langchain/langchain.py");

pub fn chunk(splitter: &str, text: &str, kwargs: &serde_json::Value) -> Result<Vec<String>> {
crate::bindings::python::activate()?;

let kwargs = serde_json::to_string(kwargs).unwrap();

Python::with_gil(|py| -> Result<Vec<String>> {
Expand Down
4 changes: 0 additions & 4 deletionspgml-extension/src/bindings/python/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,6 @@ pub fn activate() -> Result<bool> {
}

pub fn pip_freeze() -> Result<TableIterator<'static, (name!(package, String),)>> {
activate()?;
let packages = Python::with_gil(|py| -> Result<Vec<String>> {
let freeze = get_module!(PY_MODULE).getattr(py, "freeze")?;
let result = freeze.call0(py)?;
Expand All@@ -42,7 +41,6 @@ pub fn pip_freeze() -> Result<TableIterator<'static, (name!(package, String),)>>
}

pub fn validate_dependencies() -> Result<bool> {
activate()?;
Python::with_gil(|py| {
let sys = PyModule::import(py, "sys").unwrap();
let version: String = sys.getattr("version").unwrap().extract().unwrap();
Expand All@@ -68,7 +66,6 @@ pub fn validate_dependencies() -> Result<bool> {
}

pub fn version() -> Result<String> {
activate()?;
Python::with_gil(|py| {
let sys = PyModule::import(py, "sys").unwrap();
let version: String = sys.getattr("version").unwrap().extract().unwrap();
Expand All@@ -77,7 +74,6 @@ pub fn version() -> Result<String> {
}

pub fn package_version(name: &str) -> Result<String> {
activate()?;
Python::with_gil(|py| {
let package = py.import(name)?;
Ok(package.getattr("__version__")?.extract()?)
Expand Down
10 changes: 0 additions & 10 deletionspgml-extension/src/bindings/transformers/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,8 +34,6 @@ pub fn get_model_from(task: &Value) -> Result<String> {
}

pub fn embed(transformer: &str, inputs: Vec<&str>, kwargs: &serde_json::Value) -> Result<Vec<Vec<f32>>> {
crate::bindings::python::activate()?;

let kwargs = serde_json::to_string(kwargs)?;
Python::with_gil(|py| -> Result<Vec<Vec<f32>>> {
let embed: Py<PyAny> = get_module!(PY_MODULE).getattr(py, "embed").format_traceback(py)?;
Expand All@@ -58,8 +56,6 @@ pub fn embed(transformer: &str, inputs: Vec<&str>, kwargs: &serde_json::Value) -
}

pub fn tune(task: &Task, dataset: TextDataset, hyperparams: &JsonB, path: &Path) -> Result<HashMap<String, f64>> {
crate::bindings::python::activate()?;

let task = task.to_string();
let hyperparams = serde_json::to_string(&hyperparams.0)?;

Expand All@@ -86,8 +82,6 @@ pub fn tune(task: &Task, dataset: TextDataset, hyperparams: &JsonB, path: &Path)
}

pub fn generate(model_id: i64, inputs: Vec<&str>, config: JsonB) -> Result<Vec<String>> {
crate::bindings::python::activate()?;

Python::with_gil(|py| -> Result<Vec<String>> {
let generate = get_module!(PY_MODULE).getattr(py, "generate").format_traceback(py)?;
let config = serde_json::to_string(&config.0)?;
Expand DownExpand Up@@ -162,8 +156,6 @@ pub fn load_dataset(
limit: Option<usize>,
kwargs: &serde_json::Value,
) -> Result<usize> {
crate::bindings::python::activate()?;

let kwargs = serde_json::to_string(kwargs)?;

let dataset = Python::with_gil(|py| -> Result<String> {
Expand DownExpand Up@@ -313,8 +305,6 @@ pub fn load_dataset(
}

pub fn clear_gpu_cache(memory_usage: Option<f32>) -> Result<bool> {
crate::bindings::python::activate().unwrap();

Python::with_gil(|py| -> Result<bool> {
let clear_gpu_cache: Py<PyAny> = get_module!(PY_MODULE)
.getattr(py, "clear_gpu_cache")
Expand Down
2 changes: 0 additions & 2 deletionspgml-extension/src/bindings/transformers/transform.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,6 @@ pub fn transform<T: serde::Serialize>(
args: &serde_json::Value,
inputs: T,
) -> Result<serde_json::Value> {
crate::bindings::python::activate()?;
whitelist::verify_task(task)?;

let task = serde_json::to_string(task)?;
Expand DownExpand Up@@ -74,7 +73,6 @@ pub fn transform_stream<T: serde::Serialize>(
args: &serde_json::Value,
input: T,
) -> Result<Py<PyAny>> {
crate::bindings::python::activate()?;
whitelist::verify_task(task)?;

let task = serde_json::to_string(task)?;
Expand Down
1 change: 1 addition & 0 deletionspgml-extension/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@ extension_sql_file!("../sql/schema.sql", name = "schema");
#[cfg(not(feature = "use_as_lib"))]
#[pg_guard]
pub extern "C" fn _PG_init() {
bindings::python::activate().expect("Error setting python venv");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This works? I ask because each connection forks from the postmaster. It gets the venv set correctly? :O

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It works for me locally. I can test from multiple different connections.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can confirm tested from three different connections and it worked

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Well, that was easy.

SilasMarvin reacted with hooray emoji
orm::project::init();
}

Expand Down
9 changes: 1 addition & 8 deletionspgml-extension/src/orm/model.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,10 +88,6 @@ impl Model {
},
};

if runtime == Runtime::python {
let _ = crate::bindings::python::activate();
}

let dataset = snapshot.tabular_dataset();
let status = Status::in_progress;
// Create the model record.
Expand DownExpand Up@@ -334,10 +330,7 @@ impl Model {
}

#[cfg(feature = "python")]
Runtime::python => {
let _ = crate::bindings::python::activate();
crate::bindings::sklearn::Estimator::from_bytes(&data)?
}
Runtime::python => crate::bindings::sklearn::Estimator::from_bytes(&data)?,

#[cfg(not(feature = "python"))]
Runtime::python => {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp