py.Any
that lets you release a Python value even if it's still held by Scala code
I am trying to run scalapy from intellij in my window machine. I am using anaconda python with python version 3.8.5 . I am getting the below error
`java.lang.UnsatisfiedLinkError: Unable to load library 'python3.8m':
The specified module could not be found.
The specified module could not be found.
The specified module could not be found.
Native library (win32-x86-64/python3.8m.dll) not found in resource path `
python-config --ldflags
to check where the libraries are installed?
python-config --ldflags
but it is giving me python-config is not recognized as an internal or external command,operable program or batch file.
error. Please help me with this
@bishnushankar95_twitter: Hmm, can you try running
from distutils import sysconfig;
print(sysconfig.get_config_var("LIBDIR"))
in Python? that should tell you where the shared libraries are
class scala_class extends py_class
.so
(linux) or .dylib
(mac) files next to your Python installation?
Hi all, ive created python module and now I want to call it from scala using ScalaPy.
I started with call the module and the specific function:
val testScalaPy = py.Module("my_module.test_feature")
val res = testScalaPy.TestFeature.extract(payload = 1)
And its works perfectly.
Now, i would like to be able to pass case class to the extract function:
case class Payload(value: Int)
val res = testScalaPy.TestFeature.extract(payload(100))
but im getting:
type mismatch;
found : com.riskified.poc.ScalaPyPocTest.Payload
required: me.shadaj.scalapy.py.Any
error after rewriting to feature.selectDynamic("TestFeature").applyDynamicNamed("extract")(scala.Tuple2("payload", Payload(200)))
possible cause: maybe a wrong Dynamic method signature?
Any ideas on how to implement writer/reader or if this ability exists already?
Writer
derivation)
case class Payload(total: Int, info: Info)
case class Info(firstName: Name, lastName: String)
case class Name(nameVal: String)
@nirdunetz: not in the near future, since unlike JavaScript it's not immediately clear exactly what a case class should map to in Python (an object? a dictionary?)
you'll need to use something like https://github.com/softwaremill/magnolia/tree/scala2, which can extract out info on which fields are in each case class and what are their types, and then write code using ScalaPy APIs to construct a Python dictionary (or whatever type you want) and add the fields to it by recursively converting them
def write(v: Payload): py.Object = {
val out = py.global.dict()
out.bracketUpdate("total", implicitly[Writer[Int]].write(out.total)
...
out