summaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/python/python_udf
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-06-17 23:08:38 +0300
committervvvv <[email protected]>2025-06-18 11:14:06 +0300
commit7803a38571cb0dc674b01065f374c116de966b4b (patch)
tree1e3e98c1d5205cf9930965e6a5c6a967824165ac /yql/essentials/udfs/common/python/python_udf
parent80d6f567b04024db1404525203859e917f332a26 (diff)
YQL-20086 udfs
commit_hash:631fd9ed259a7c95a618e1265f61df28a87ce922
Diffstat (limited to 'yql/essentials/udfs/common/python/python_udf')
-rw-r--r--yql/essentials/udfs/common/python/python_udf/python_function_factory.h24
-rw-r--r--yql/essentials/udfs/common/python/python_udf/python_udf.cpp16
2 files changed, 20 insertions, 20 deletions
diff --git a/yql/essentials/udfs/common/python/python_udf/python_function_factory.h b/yql/essentials/udfs/common/python/python_udf/python_function_factory.h
index a4e393b4868..657fb1f442b 100644
--- a/yql/essentials/udfs/common/python/python_udf/python_function_factory.h
+++ b/yql/essentials/udfs/common/python/python_udf/python_function_factory.h
@@ -34,14 +34,14 @@ public:
const TType* functionType,
ITypeInfoHelper::TPtr&& helper,
const NYql::NUdf::TSourcePosition& pos)
- : Ctx(new TPyContext(helper, tag, pos))
- , FunctionName(name)
+ : Ctx_(new TPyContext(helper, tag, pos))
+ , FunctionName_(name)
, FunctionType_(functionType)
{
}
~TPythonFunctionFactory() {
- Ctx->Cleanup();
+ Ctx_->Cleanup();
PyCleanup();
}
@@ -50,30 +50,30 @@ private:
const IValueBuilder* valueBuilder,
const TUnboxedValuePod* args) const override
{
- TPyCastContext::TPtr castCtx = MakeIntrusive<TPyCastContext>(valueBuilder, Ctx);
+ TPyCastContext::TPtr castCtx = MakeIntrusive<TPyCastContext>(valueBuilder, Ctx_);
// for get propper c-compatible null-terminating string
TString source(args[0].AsStringRef());
TPyGilLocker lock;
- TPyObjectPtr module = CompileModule(FunctionName, source);
+ TPyObjectPtr module = CompileModule(FunctionName_, source);
if (!module) {
- UdfTerminate((TStringBuilder() << Ctx->Pos << "Failed to compile module: " << GetLastErrorAsString()).data());
+ UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to compile module: " << GetLastErrorAsString()).data());
}
- TPyObjectPtr function(PyObject_GetAttrString(module.Get(), FunctionName.data()));
+ TPyObjectPtr function(PyObject_GetAttrString(module.Get(), FunctionName_.data()));
if (!function) {
- UdfTerminate((TStringBuilder() << Ctx->Pos << "Failed to find entry point: " << GetLastErrorAsString()).data());
+ UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to find entry point: " << GetLastErrorAsString()).data());
}
if (!PyCallable_Check(function.Get())) {
- UdfTerminate((TStringBuilder() << Ctx->Pos << "Entry point is not a callable").data());
+ UdfTerminate((TStringBuilder() << Ctx_->Pos << "Entry point is not a callable").data());
}
try {
SetupCallableSettings(castCtx, function.Get());
} catch (const yexception& e) {
- UdfTerminate((TStringBuilder() << Ctx->Pos << "Failed to setup callable settings: "
+ UdfTerminate((TStringBuilder() << Ctx_->Pos << "Failed to setup callable settings: "
<< e.what()).data());
}
return FromPyCallable(castCtx, FunctionType_, function.Release());
@@ -104,8 +104,8 @@ private:
return module;
}
- const TPyContext::TPtr Ctx;
- const TString FunctionName;
+ const TPyContext::TPtr Ctx_;
+ const TString FunctionName_;
const TType* FunctionType_;
inline static std::atomic_uint AtomicCounter = 0;
};
diff --git a/yql/essentials/udfs/common/python/python_udf/python_udf.cpp b/yql/essentials/udfs/common/python/python_udf/python_udf.cpp
index 1007c75edc3..a14d9d81c32 100644
--- a/yql/essentials/udfs/common/python/python_udf/python_udf.cpp
+++ b/yql/essentials/udfs/common/python/python_udf/python_udf.cpp
@@ -49,9 +49,9 @@ class TPythonModule: public IUdfModule
{
public:
TPythonModule(const TString& resourceName, EPythonFlavor pythonFlavor, bool standalone = true)
- : ResourceName(resourceName), Standalone(standalone)
+ : ResourceName_(resourceName), Standalone_(standalone)
{
- if (Standalone) {
+ if (Standalone_) {
Py_SetProgramName(PYTHON_PROGRAMM_NAME);
PrepareYqlModule();
Py_Initialize();
@@ -67,7 +67,7 @@ public:
}
#ifndef _win_
- if (Standalone) {
+ if (Standalone_) {
TVector<TStringBuf> paths;
if (pythonFlavor == EPythonFlavor::System) {
paths.push_back(TStringBuf("/usr/lib/python2.7/dist-packages"));
@@ -82,14 +82,14 @@ public:
TPyObjectPtr pyExecutableStr = PyRepr(GetExecPath().data());
Y_ABORT_UNLESS(PySys_SetObject(executableVar, pyExecutableStr.Get()) >= 0, "Can't set sys.executable");
- if (Standalone) {
+ if (Standalone_) {
PyEval_InitThreads();
MainThreadState_ = PyEval_SaveThread();
}
}
~TPythonModule() {
- if (Standalone) {
+ if (Standalone_) {
PyEval_RestoreThread(MainThreadState_);
Py_Finalize();
}
@@ -121,15 +121,15 @@ public:
}
const auto pos = builder.GetSourcePosition();
- builder.Implementation(new TPythonFunctionFactory(name, ResourceName, userType, std::move(typeHelper), pos));
+ builder.Implementation(new TPythonFunctionFactory(name, ResourceName_, userType, std::move(typeHelper), pos));
} catch (const yexception& e) {
builder.SetError(TStringBuf(e.what()));
}
}
private:
- TString ResourceName;
- bool Standalone;
+ TString ResourceName_;
+ bool Standalone_;
PyThreadState* MainThreadState_;
};