Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create post-link script to install Julia deps #41

Closed
wants to merge 11 commits into from

Conversation

MilesCranmer
Copy link
Contributor

Attempts to add a post-link script to install PySR's julia dependencies.

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

Addresses #38.

cc @ngam @mkitti

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

Could you add this line to conda-forge.yml?

azure:
  store_build_artifacts: true

This would allow us to see what actually gets packaged (by downloading the zipped files from the CI).

Copy link
Contributor

@ngam ngam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this the install step from the build script for now?

recipe/meta.yaml Outdated Show resolved Hide resolved
@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

Anyway, it is working as intended I believe, the key portion of the CI starts on line 845

Maybe a statement should be printed and a way to cancel...

Executing transaction: ...working...   Installing known registries into `~/feedstock_root/build_artifacts/pysr_1660455210381/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/share/julia`
  No Changes to `~/feedstock_root/build_artifacts/pysr_1660455210381/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/share/julia/environments/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/Project.toml`
  No Changes to `~/feedstock_root/build_artifacts/pysr_1660455210381/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/share/julia/environments/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/Manifest.toml`

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

The install/build script(s) for pysr deleted the following files (from dependencies) from the prefix:
['lib/julia/libmbedtls.so', 'lib/julia/libnghttp2.so', 'lib/julia/libmbedx509.so', 'lib/julia/libcurl.so', 'lib/julia/libopenblas64_.so', 'lib/julia/libmbedcrypto.so']
This will cause the post-link checks to mis-report. Please try not to delete and files (DSOs in particular) from the prefix
WARNING:conda_build.build:The install/build script(s) for pysr deleted the following files (from dependencies) from the prefix:
['lib/julia/libmbedtls.so', 'lib/julia/libnghttp2.so', 'lib/julia/libmbedx509.so', 'lib/julia/libcurl.so', 'lib/julia/libopenblas64_.so', 'lib/julia/libmbedcrypto.so']
This will cause the post-link checks to mis-report. Please try not to delete and files (DSOs in particular) from the prefix

I wonder what exactly this means...

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

Btw, we need to edit your reqs --- something like this is enough I believe or along the lines of what isuruf suggested: https://github.com/conda-forge/staged-recipes/pull/17647/files

requirements:
  host:
    - pip
    - python >=3.7
  run:
    - pyjulia >=0.5.7
    - julia <=1.7.1
    - numpy
    - pandas
    - python >=3.7
    - scikit-learn >=1.0.0
    - sympy

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipe) and found some lint.

Here's what I've got...

For recipe:

  • The top level meta key azure is unexpected

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@MilesCranmer
Copy link
Contributor Author

Thanks, all suggestions implemented. Let's see if it works

@MilesCranmer
Copy link
Contributor Author

Since the deps are changing, do I need to merge a new version of PySR (i.e., creating a v0.10.1), or is updating the build number enough?

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

build number is enough

recipe/meta.yaml Outdated
Comment on lines 21 to 28
- python >=3.6,<4.0
- pyjulia >=0.5.7
- julia <=1.7.1
- numpy >=1.14.0
- pandas
- sympy
- scikit-learn
- openlibm
- scikit-learn >=1.0.0
- openlibm <0.8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still the case that your package doesn't support 1.7.2? We have 1.8 coming up soon too.

Anyway, if the <=1.7.2 isn't strictly necessary, I think we can get rid of julia and openlibm from here. You get julia from pyjulia anyway, and openlibm comes with julia.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PySR itself works for any Julia version above 1.5.

I saw issues with the conda-forge version of julia 1.7.2 when I tried it a while ago, and since most PySR users don't use Julia for other things I thought it would be fine to fix it at a stable version. I could try relaxing that requirement now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sounds good. It is a good exercise to relax it to see if things work as expected. I believe we implemented significant changes in 1.7.2 that will carry over to 1.8.0, so it is good to resolve this at some point, though not necessarily in this PR

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

My one last concern is that we need to get someone from @conda-forge/core to approve this to avoid misunderstanding and trouble. Maybe @isuruf? I would give them like a week to respond.

If no response, my opinion is: You're the maintainer here, and this is your package after all, so you should feel empowered to make whatever changes that you think are appropriate and beneficial.

@MilesCranmer
Copy link
Contributor Author

Sounds good to me. If there's no response this week I will plan to merge this next weekend.

Also: I relaxed the Julia version requirement to 1.7.*.

@@ -0,0 +1 @@
"${PREFIX}/bin/python" -c 'import pysr; pysr.install()' >> "${PREFIX}/.messages.txt" 2>&1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where would this install the julia packages?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$CONDA_PREFIX/share I believe, especially after we specified the post-links in the julia-feedstock.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ngam I'm assuming the packages get installed in a location according to this env variable, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, messages crossed :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a downstream package uses pysr when being built by conda-build, will conda-build package the julia packages installed by this post-link script?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it will certainly do (I think). Is there anyway to limit this? Make it into an activate script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought post-link.sh runs on the user side?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the user can be the package building process. If you get pysr in your host or build reqs, then it will activate and do the whole post-link during the build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can defend against this by checking whether CONDA_BUILD_STATE is not test in the post-link script.

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

Hm... @MilesCranmer

[ Info: Trying to import PyCall...
┌ Error: `import PyCall` failed
│   exception =
│    ArgumentError: Package PyCall [438e738f-606a-5dbb-bf0a-cddfbfd45ab0] is required but does not seem to be installed:
│     - Run `Pkg.instantiate()` to install all recorded dependencies.
│    
│    Stacktrace:
│     [1] _require(pkg::Base.PkgId)
│       @ Base ./loading.jl:1089
│     [2] require(uuidkey::Base.PkgId)
│       @ Base ./loading.jl:1013
│     [3] top-level scope
│       @ ~/feedstock_root/build_artifacts/pysr_1660496397213/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/lib/python3.10/site-packages/julia/install.jl:36
│     [4] include(mod::Module, _path::String)
│       @ Base ./Base.jl:418
│     [5] exec_options(opts::Base.JLOptions)
│       @ Base ./client.jl:292
│     [6] _start()
│       @ Base ./client.jl:495

What went wrong between 1.7.1 and 1.7.2+?

@MilesCranmer
Copy link
Contributor Author

@ngam that issue by itself is fine - that's how the normal PyJulia install process works - it installs PyCall.jl if it can't import it.

However, the other issues look to be new: https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=551157&view=logs&j=656edd35-690f-5c53-9ba3-09c10d0bea97&t=e5c8ab1d-8ff9-5cae-b332-e15ae582ed2d&l=683 from julia >1.7.1

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

@conda-forge-admin, please rerender

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

@ngam that issue by itself is fine - that's how the normal PyJulia install process works - it installs PyCall.jl if it can't import it.

However, the other issues look to be new: https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=551157&view=logs&j=656edd35-690f-5c53-9ba3-09c10d0bea97&t=e5c8ab1d-8ff9-5cae-b332-e15ae582ed2d&l=683 from julia >1.7.1

I think the issue is with pycall still:

  [8e850b90] + libblastrampoline_jll
  [8e850ede] + nghttp2_jll
    Building Conda ─→ `~/feedstock_root/build_artifacts/pysr_1660496397213/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/share/julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/6e47d11ea2776bc5627421d59cdcc1296c058071/build.log`
    Building PyCall → `~/feedstock_root/build_artifacts/pysr_1660496397213/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p/share/julia/scratchspaces/44cfe95a-1eb2-52ea-b672-e2afdf69b78f/1fc929f47d7c151c839c5fc1375929766fb8edcc/build.log`
ERROR: LoadError: Error building `PyCall`: 

DirectoryNotACondaEnvironmentError: The target directory exists, but it is not a conda environment.
Use 'conda create' to convert the directory to a conda environment.
  target directory: /home/conda/feedstock_root/build_artifacts/pysr_1660496397213/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_p


[ Info: Running `conda install -y numpy` in root environment

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

I think the issue here is that your package is trying to make another conda env for itself. Currently, what we are doing is stacking envs. You have a conda env, right? Then a julia env gets built within it inside $CONDA_PREFIX/share/julia/ so there is no longer a need to create a new conda env and instead one can work within the existing conda env in the hierarchical structure.

I think this makes sense as the change from julia 1.7.1 to 1.7.3 exposed this issue. In your helper function, it may help to adjust it so that it can make use of this new feature we introduced --- i.e., all you need to do is ask julia to install your deps directly. What does PyCall do exactly in this case btw?

@MilesCranmer
Copy link
Contributor Author

pysr.install() is doing the following:

  1. Install PyCall.jl using PyJulia's install() command. Code
  2. Pkg.activate("pysr-0.10.0", shared=true) - (This should create a new env). Code
  3. Pkg.add("SymbolicRegression"). Code
  4. Pkg.instantiate(). Code

Copy link
Contributor

@ngam ngam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't working well. The issue raised by isuruf is crucial --- if another package uses pysr at some point we will end up packaging all these julia modules automatically, which we do not want.

I think we will have to settle with a user-triggered solution...

@ngam
Copy link
Contributor

ngam commented Aug 14, 2022

pysr.install() is doing the following:

  1. Install PyCall.jl using PyJulia's install() command. Code
  2. Pkg.activate("pysr-0.10.0", shared=true) - (This should create a new env). Code
  3. Pkg.add("SymbolicRegression"). Code
  4. Pkg.instantiate(). Code

Yes, I am not sure what's causing the error. I got it to work fine with a separate step after the fact (not post-link, i.e. like what you had before in the tests):

     Cloning git-repo `https://github.com/JuliaParallel/ClusterManagers.jl`
   Resolving package versions...
    Updating `~/.Mambaforge-Linux-x86_64/envs/py310/share/julia/environments/pysr-0.10.0/Project.toml`
  [34f1f09b] + ClusterManagers v0.4.2 `https://github.com/JuliaParallel/ClusterManagers.jl#14e7302`
    Updating `~/.Mambaforge-Linux-x86_64/envs/py310/share/julia/environments/pysr-0.10.0/Manifest.toml`
  [34f1f09b] + ClusterManagers v0.4.2 `https://github.com/JuliaParallel/ClusterManagers.jl#14e7302`
Precompiling project...
  82 dependencies successfully precompiled in 205 seconds (8 already precompiled)
/home/ngam/Repos/PySR/pysr/julia_helpers.py:39: UserWarning: It is recommended to restart Python after installing PySR's dependencies, so that the Julia environment is properly initialized.
  warnings.warn(

@@ -10,33 +10,21 @@ source:

build:
noarch: python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package probably cannot be noarch now, right? Will we need post-link.bat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

julia-feedstock is only available on macOS and linux so I'm assuming we can leave it as noarch until that changes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better the opposite in that case b/c these noarch packages will be available when the Julia package lands on those platforms, creating possible solutions but faulty installations.

@ngam ngam mentioned this pull request Aug 23, 2022
10 tasks
@ngam
Copy link
Contributor

ngam commented Aug 28, 2022

@mkitti could you have a look at what went wrong here? I am not entirely sure...

@mkitti mkitti mentioned this pull request Sep 12, 2022
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants