Standard/Recommended practices for adding codes with third-party libraries into Sage codebase?

78 views
Skip to first unread message

Jing Guo

unread,
May 19, 2024, 3:53:25 PMMay 19
to sage-devel
Dear all,

In the past few months I have been working on a Sage library for counting graph homomorphisms: https://github.com/guojing0/count-graph-homs (It's still updating, hence not 100% complete)

In `concurrent_hom_count.py`, I use third-party libraries, such as `numba`, `dask`, and `numpy`. For numpy, I think it's already in Sage. So I was wondering what would be the standard/best/recommended practices if I want to contribute this code to Sage, which I suppose does not support either `numba` or `dask` (searching in the codebase returns nothing)?

Thank you!

Jing

Matthias Koeppe

unread,
May 19, 2024, 10:43:46 PMMay 19
to sage-devel
On Sunday, May 19, 2024 at 12:53:25 PM UTC-7 Jing Guo wrote:
In the past few months I have been working on a Sage library for counting graph homomorphisms: https://github.com/guojing0/count-graph-homs (It's still updating, hence not 100% complete)

In `concurrent_hom_count.py`, I use third-party libraries, such as `numba`, `dask`, and `numpy`. For numpy, I think it's already in Sage. So I was wondering what would be the standard/best/recommended practices if I want to contribute this code to Sage, which I suppose does not support either `numba` or `dask` (searching in the codebase returns nothing)?

It depends on the intended degree of integration into Sage.
The loosest integration: Prepare it as a pip-installable package (which declares its dependencies using the standard Python packaging practices);  then add it as an optional "pip" package to the Sage disitribution.
See Meta-ticket: Add external user packages as optional/experimental packages (https://github.com/sagemath/sage/issues/31164) for examples and pointers to documentation.

Dima Pasechnik

unread,
May 20, 2024, 10:57:41 AMMay 20
to sage-...@googlegroups.com
On Mon, May 20, 2024 at 3:43 AM Matthias Koeppe
<matthia...@gmail.com> wrote:
>
> On Sunday, May 19, 2024 at 12:53:25 PM UTC-7 Jing Guo wrote:
>
> In the past few months I have been working on a Sage library for counting graph homomorphisms: https://github.com/guojing0/count-graph-homs (It's still updating, hence not 100% complete)
>
> In `concurrent_hom_count.py`, I use third-party libraries, such as `numba`, `dask`, and `numpy`. For numpy, I think it's already in Sage. So I was wondering what would be the standard/best/recommended practices if I want to contribute this code to Sage, which I suppose does not support either `numba` or `dask` (searching in the codebase returns nothing)?
>
>
> It depends on the intended degree of integration into Sage.
> The loosest integration: Prepare it as a pip-installable package (which declares its dependencies using the standard Python packaging practices); then add it as an optional "pip" package to the Sage disitribution.

How exactly is this code using Sage - what are graph Sage-specific
functions used?
Tight integration with Sage would need, in the present Sage distro
model, numbda and dask as its packages, and in particular numba would
be very tricky, as it needs LLVM.

> See Meta-ticket: Add external user packages as optional/experimental packages (https://github.com/sagemath/sage/issues/31164) for examples and pointers to documentation.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/d29caf89-d6b5-4896-94b1-b4703218e857n%40googlegroups.com.

Jing Guo

unread,
May 20, 2024, 12:43:45 PMMay 20
to sage-...@googlegroups.com
Thank you for all the advice. I guess for the concurrent one, I probably would go with the pip approach.

For Sage specific functions, we use tree decomposition and nice tree decomposition, and all other graph functions.

Jing
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/L6lp0CSKMR8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/CAAWYfq2ZLpQ-s8eDmwcZUtAccN42UJOYWt_%2B_qJ_v20d8fka4g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages