Best practice for third party libraries and packages #5502
Replies: 2 comments 4 replies
-
Hi @lorentzenchr! To answer your questions:
Almost certainly no, if only to avoid debugging headaches associated with holding a complex stateful object like a database connection in a module global variable. Additionally, with such a connection it's not clear that you could ever have more than one instance of the corresponding backend.
I think that's hard to answer without more context about the use case/application. We recently added a |
Beta Was this translation helpful? Give feedback.
-
@cpcloud Thanks for having had a look. I‘ve to say, I‘m now even more confused. def fun(df):
# For the time being, we assume a pandas df and use pandas API,
# but would love to use ibis
df["new"] = 1
return df How could a library then use ibis that seems to need a connection, e.g. the default con to duckdb? |
Beta Was this translation helpful? Give feedback.
-
If one writes a library/package that does some data mangling, and one wants to be able to switch backends in the future, ibis seems to be a perfect fit.
The documentation mainly focuses on direct/human users. Are there recommendations for the usage of and development with ibis in a 3rd party library?
To give concrete examples:
import mylibrary
) and then use it inside of all of its classes and functions? In that case, the connection would be a global (and internal) variable.def myfun(data)
receives some in-memory data, creates a temporary table, calulcates and returns a single number. Should the function then first register the temporary table (create_table
,read_in_memory
orread_pandas
...) and thendrop_table
before returning?Beta Was this translation helpful? Give feedback.
All reactions