Python packages and CI

Hi to everybody! I am a new Julia user, I just started to use Julia a week ago. As a first project, I’d like to translate one of my Python projects, hopefully finding better performances.

Following some tutorials, I started a project on GitHub, setting GutHub actions to make docs and set the continuos integration. When I needed a Python package I used Conda and PyCall to install and use numpy, so that I could use it during unit tests. Now I need to add another package, classy. I tried the same procedure but it didn’t work since classy cannot be installed with Conda (but can be install using pip).

Now, I need to use classy for my project and I want a unit tests suite for my project. Which are your suggestions? Using a custom docker-image where these packages have already been installed, removing the necessity of using Conda? In my Python project (which is in a private repo) I use a custom docker image for the tests, but I am afraid I do not know how to change the ci.yml file. I wrote it following a tutorial (and looking into other repo, it looks quite standard to me).
In particular, I suppose that the docker-image is set from

Blockquote jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- ‘1.5’
os:
- ubuntu-latest

where I wrote ubuntu:latest.
Do you have any suggestions on how to avoid this problem? Maybe I should change my ci.yml file?
Thank you for your time,
Marco

1 Like

Just run classy on your machine for some unit tests and save the output to a file. Then in your Julia project, load the file of expected outputs and check them against the Julia results. That way, you don’t need to have Python at all on the test/CI machine.

3 Likes

Hi, thank you for your answer!
Yes, I got your point but this won’t work for me. classy is a module that I need to integrate in my code, not only for unit testing…so I cannot simply add the output:/

Welcome to Julia :slight_smile: The easist option is probably to just pip install from the Github actions script, here’s an example:

That same repo has an example of a Github action that runs a Docker image too (although not for tests, for building docs), if you wanted to go that route, its only slightly more complicated.

2 Likes

Hi Marius, thank you for your answer!
I’ll try it asap…then I’ll write to you if it’s working:)

I see. In the short run, you can use pip with github actions as noted by @marius311. In the long run, you should consider writing a native Julia wrapper for CLASS — since CLASS seems to be a pure C library with an interface in terms of structs, calling it directly from Julia should be straightforward if tedious.

You’d create a CLASS build script on Yggdrasil, then generate Julia struct mirrors of the CLASS structs (e.g. automated with Clang.jl) to put together a “Classy.jl” front-end package. Many people might find this useful.

5 Likes

It worked…thanks!

1 Like

I have never written a wrapper, but probably this would be interesting. I’ll consider it…thanks:)

1 Like

Conda.jl also supports pip:

You can use Conda.jl to install your Conda and pip dependencies directly from a Julia script.

1 Like