-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Inconsistent performance between GitHub CI and local #1140
Comments
I also ran into this problem. It turned out to be a a mac (local) vs debian (CI) issue You can identify the offending lines by spinning up a docker container that matches your ci environment, mounting your local repo, and running black in the container. Example commands below:
That will reproduce the changes you're getting on CI. Use |
Interesting! I have ubuntu 18.04 locally (and at least that's the runner I specified in actions) so I don't think it would (at face value) be due to differences in operating system. This is a very nice sanity check, however, I can at least use a container to get a third opinion on the matter! :) |
I'd be interested to know what the differences in formatting are between the two versions; that might help us figure out where the problem is. |
You mean OS versions? For my bug report I installed the exact same version of the library, so something else must be different. But +1, knowing version differences is useful! |
Sorry, I meant what the change is that Black wants to make on your CI but not your local installation. |
Oh that’s a good idea! Is there a command to run that would show changes for a file (I’m using —check and it just shows the file names that would be changed). |
|
It was Var_name = ( vs Var_name = ( In my case. Using pre-commit, stable, language version 3.6 Sorry for formatting, working from phone. |
I ran into this issue as well using the system black package on Ubuntu 20.04. There were wild differences between my mac version and ubuntu in terms of which files should be reformatted. For now I just worked around it by using the pip package version which should be consistent across platforms. Example: pip3 install black
python3 -m black -t py38 --check tests This might have something to do with how ubuntu builds it's version of black and not an inconsistency problem on the part of black. |
I'm running into the same problem, with an additional detail that the files it's complaining about in CI were not touched in this PR. |
@yousra-rubikloud we just had a release, are you sure that's not the reason for the difference you're seeing? I'd recommend pinning Black to an exact version whenever you're running it in CI. |
@JelleZijlstra on the CI I have black-20.8b1 and locally I have black==19.10b0. Which version was the one with the fix? |
I don't think there is a fix for the issue originally reported here, but different versions of Black format things differently, so you should make sure you use the same version locally and in your CI, or you're bound to run into inconsistencies. |
That's not ideal. I'm in the process of moving a large project to black: I am okay with having one changeset that contains all of the changes black makes, but I'm not so sure about having these every time black updates something. Is it common to have significant changes like this? Actually, looking deeper, it seems to me that 20.8b1 does not respect the line length directive. It's reflowing lines that are >88 chars, even though I have it set to 119. |
What's the alternative? Black needs to have the ability to evolve. It needs to fix things too. You can pin versions if you need fixed behavior. |
I just encountered this issue with Github Actions, and solved it by fixing my version control of
- repo: https://github.com/psf/black
rev: 19.10b0 |
@srinathganesh did you compare the version of black on your host vs. CI? That's usually the issue - see the above thread for examples to pin to a specific version. |
Deleted my comment since it was kind of misleading. My problem was two things, one is version of black and second is my CI was running alpine while host was ubuntu, python-slim did the trick |
@synchronizing We can make progress on this if people who run into this look more closely into why it's happening. I strongly suspect it's usually a case of different Black versions being run in different places, but I'd be happy to be proven wrong if there's a way to reproduce the issue. |
Closing as there is no clear way to reproduce it. Most likely people running into this are actually running different versions of Black in different places. |
I am running into this and have confirmed that I am nominally running the same version of |
I ran into the same issue because I thought I was using the same version. It turns out that stating the version in tag is not enough. Without specifying it using |
The behavior is very unexpected. @JunranY found the solution to the issue in our repo at cmudig/draco2#199. |
I'm alright with making the default Black version tied to the action version being used. For context |
That would be awesome. Thank you for proving the GitHub action and black. It's an amazing tool to have! |
Am I correct to assume that there's still no fix for this? Seeing wild inconsistencies between local macOS and Github Actions runner. |
@lifenautjoe No reproducible issue has been reported. If you are seeing this, please open a new bug with instructions to reproduce it. Most likely you are running different versions of Black in different places. Note that the version of the GH Action is independent from the version of Black being used by it (cf. https://black.readthedocs.io/en/stable/integrations/github_actions.html). |
accepting comment by @JunranY fixed it for me; have to make the version explicit on a seperate line
|
I said I'd change this, but I never even opened an issue. I'll fix that. |
I'm having 2 github actions, running in exactly the same way, and one fails, and the other doesn't. |
Hi there! We're using black for snakemake (I love it so far!) but I'm running into an issue where, despite having the same version of black installed via conda in GitHub CI versus locally, the local version reports that all is well, the GitHub CI version reports that one file needs to be reformatted.
Locally:
and in GitHub CI
The version of black there is also the same
Further, locally it tells me I need to reformat other files (which the remote doesn't suggest)
Do you have suggestions for what we might further try, or ideas for why it's inconsistent? The testing step is here (not sure if you can see it) and the PR in question is here. Thanks!
Expected behavior A clear and concise description of what you expected to happen.
The local and remote black formatting commands would produce the same result.
Environment (please complete the following information):
Does this bug also happen on master? To answer this, you have two options:
Yes I tried this, same result locally. Thanks for your help!
The text was updated successfully, but these errors were encountered: