showyourwork / showyourwork

A workflow for reproducible and open scientific articles

Home Page:https://show-your.work

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build on github is broken with 'pulp' has no attribute 'list_solvers'

mkenworthy opened this issue · comments

All the repos seem to be broken when I do a git push from my local repo - the jobs report shows this error:

Uploading logs
Error: exec: Traceback (most recent call last):
  File "/home/runner/.local/bin/snakemake", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.local/lib/python3.10/site-packages/snakemake/__init__.py", line 2504, in main
    parser = get_argument_parser()
  File "/home/runner/.local/lib/python3.10/site-packages/snakemake/__init__.py", line 1471, in get_argument_parser
    lp_solvers = pulp.list_solvers(onlyAvailable=True)
AttributeError: module 'pulp' has no attribute 'list_solvers'. Did you mean: 'listSolvers'?

It seems to be related to this issue:

#snakemake/snakemake#2607

Any advice on how to resolve appreciated!

Check out the solution here and here. tl;dr: You'll need to manually downgrade pulp.

Okay, dumb question... how do I manually downgrade pulp on the github repo and action?

Adding:

        with:
          showyourwork-spec: git+https://github.com/showyourwork/showyourwork

Under the showyourwork action step should use the latest branch until a release is made.

Hello, I was just hoping to get some help here - I'm having this same exact problem! I'm afraid I don't quite understand the various threads/links posted above or what the solution was, but I did try manually downgrading pulp from version 2.8.0 --> 2.7.0, and I still get the error.

Oddly, with pulp 2.7.0, if I start up python and import pulp, then run the line:

pulp.list_solvers

it returns:

<function listSolvers at 0x10704fba0>

which leads me to think that I have downgraded to a version that should work, but I still the same error as originally posted above. Perhaps I need to do something else now before git pushing?

Thanks!

I assume that you are running locally? In this case, when you downgrade the pulp version locally, you are doing so only on your system python, not the environment internal to the showyourwork. Installing directly from GitHub should resolve this issue until there is a new release.

pip install -U git+https://github.com/showyourwork/showyourwork

Let me know if that works.

Thanks for the suggestion! I think it is beginning to point me in the right direction, but I'm still confused. I want to integrate with Overleaf, so I've been trying to follow both the "Quickstart" and "Overleaf Integration" pages.

I tried creating a new conda environment, then installed python=3.10.0, then ran the above pip install you suggested to get the latest development version.

Then I made a small edit in a figure .py file, so that I could git push that to the repo I set up with the Overleaf integration. Interestingly, this time when it failed again with the same above error message:
Screenshot 2024-04-23 at 4 53 14 PM

I realized for the first time that it is first installing "showyourwork" for some reason. And it looks like it is indeed installing version 0.4.3, which I believe is the version with the list_solvers problem.

I don't understand why it is doing this? I already installed showyourwork, and when I git push I do so from the environment with the latest version of showyourwork version 0.4.4.dev37+g1526059. So it makes me think from your message that perhaps when I git push, it is not looking at the environment I'm working in?

Thanks!

Do you have these additional lines in the GitHub action yaml?

#435 (comment)

Hi Casey, just to add to arm61's comment, because it wasn't initially clear for me - there are two separate showyourwork's going on here.

On your local machine, you've installed syw correctly and it's working.

On github, it has to download and build a separate syw for the github servers and actions to work on, and you specify what syw version that github uses by editing .github/workflows/build.yml so that the middle bit looks like:

  - name: Build the article PDF
    id: build
    with:
      showyourwork-spec: git+https://github.com/showyourwork/showyourwork
    uses: showyourwork/showyourwork-action@v1

git add build.yml, commit and push it, and it should work.

Thank you so much @mkenworthy for that additional clarification! That really helped because I had not yet made the realization/understanding that there are two separate showyourworks being used! Perhaps since it has helped both of us, something like a brief explanation of this could be added into the documentation pages, @arm61 ?

Ok I got it to work now! I edited the .github/workflows/build.yml file as shown above, being careful to use regular spaces when setting the indentation (it failed the first few times because I was using tab to space, and I didn't know that .yml is very picky about indentation!).

I also accidentally didn't have the read/write permissions set as explained here, but once I fixed all of that and git pushed it, things compiled correctly!

I hope it is alright to ask an additional clarification question on this thread. If I download the PDF of my document from the github repo, it has all of the nice hyperlinks and watermarks. But when I view/download the document from Overleaf, it is missing all of that. See the two attached PDFs:
from_github.pdf
from_overleaf.pdf

Is this a limitation of Overleaf, not being able to properly include the hyperlinks/watermarks?

Additionally, the local folder on my laptop doesn't contain the new figure or PDF. I tried git pulling while in my showyourwork environment, but nothing seems to change. I suspect I'm just not understanding something, but any help here would be appreciated!

Thanks again!

Excellent, glad it's now working, it's always satisfying to get the green text at the end of the compile.

It's a limitation of overleaf that you don't have the hyperlinks included, you only get the full version on your repo and github AFAIK.

So long as you run showyourwork locally on your computer and in your repo, the local folder should have the new version and PDF built in it. If you try showyourwork clean then showyourwork build that might clear out some stale files.

Hey @CaseyMcGrath and @mkenworthy, thanks for the update and the input. (I had a feeling there was confusion about the presence of different environments, but I wanted to make sure that I understood and fixed the bug first.)

As @mkenworthy says, this is a limitation of Overleaf. If you compile locally, you will get the nice glyphs (note, there are other differences between the Overleaf version and the local/GitHub version, i.e., if you use the \variable LaTeX function).

@CaseyMcGrath for adding to the documentation, we would always welcome a PR with this update. However, there are two other solutions:

  • If we make a release to PyPI, then this bug will be effectively gone for the majority of users, so it may not need documenting.
  • @CaseyMcGrath, could you please specify a particular section in the documentation that requires updating? I can then work on it and have you review it (documentation written/reviewed by a user is always better than that from a developer's perspective).

Hi @arm61, thanks for your response, I appreciate the clarification!

Regarding your proposed solutions, makes sense that if/when you release the next set of updates, the bug will likely be fixed. Hopefully in the mean time others will find this thread if they are running into the same issues.

I'm not sure where might be the best place to add to the documentation - I've been going over all of the various doc pages and trying to figure out where it might best fit in.

One potential option you could perhaps consider would be to add @mkenworthy 's note to the "Installation" page? What do you think @mkenworthy? Maybe after the "Note: showyourwork! is constantly under development, so users..." you could add in another mini section or note along the lines of:


Note:
When using showyourwork!, two versions will be installed:

  1. one on your local machine, when you run the above pip install command on your computer.
  2. and a second one on GitHub itself. In order to compile the document, your GitHub repo also installs showyourwork! for its servers/actions to work on.

If you need to change what version of showyourwork! is installed on the GitHub side, that can be directly done by editing the .github/workflows/build.yml file saved in your local showyourwork! article directory. For example, if you want GitHub to install and use the latest development version of showyourwork!, then look for the following lines in this build.yml file and add the following:

  - name: Build the article PDF
    id: build
    with:
      showyourwork-spec: git+https://github.com/showyourwork/showyourwork
    uses: showyourwork/showyourwork-action@v1

Feel free to adapt/change my suggestion how you see fit!

Oh and one other minor thing I happened to notice: the link here is currently broken.

hi, I'd be happy for my text to be added. I can't do it as I'm not good enough with the sphinx docs and pushing a request, so please go ahead and do it!