|
|
Subscribe / Log in / New account

Python gets a "Developer-in-Residence"

By Jake Edge
July 28, 2021

Backlogs in bug triage, code review, and other elements of the development process are nothing new for free-software projects; there is clearly a lot more interest in creating new features (and the bugs that go with them, of course) than in taking on the less-satisfying bits. For a large project like CPython, though, the backlog can seriously impede progress—potentially chasing off contributors whose work falls through the cracks. In order to address that, the Python Software Foundation (PSF) has raised some funds to hire Łukasz Langa as the CPython "Developer-in-Residence". Langa will be working to help clear the backlog, while also looking into other areas of interest to the PSF and the Python steering council.

Langa is a longtime CPython core developer and the release manager for Python 3.8 and 3.9; he is also the creator of the Black code formatter for Python. But, beyond all of that, he has been advocating for more full-time Python developers for a while now, so this is something of a dream come true for him personally. He described the goals for the position in a July 12 blog post, which was his first day on the job:

When the PSF first announced the Developer in Residence position, I was immediately incredibly hopeful for Python. I think it's a role with transformational potential for the project. In short, I believe the mission of the Developer in Residence (DIR) is to accelerate the developer experience of everybody else. This includes not only the core development team, but most importantly the drive-by contributors submitting pull requests and creating issues on the tracker.

He noted that Python is largely volunteer-driven, though there are a few folks being paid by their employer to work on the language full-time; for example, there is a team of three people (including Python creator Guido van Rossum) who are working on speeding up CPython. Full-time people make a difference: "Just by the sheer force of sitting at a desk for a given number of hours they can achieve big things." But the role of the DIR is somewhat different; he sees it as a way to bring in even more contributors to the project:

Now, what can the DIR do as one person? I believe I can multiply the impact of the hundreds of contributors who are not core developers. The DIR can do it by:
  • providing a steady review stream which helps dealing with PR backlog;
  • triaging issues on the tracker dealing with issue backlog;
  • being present in official communication channels to unblock people with questions;
  • keeping CI and the test suite in usable state which further helps contributors focus on their changes at hand;
  • keeping tabs on where the most work is needed and what parts of the project are most important.

There is an important side effect to providing this service, and that is a good first developer experience for an external contributor. Great contributor experiences lead to future contributions, and a stream of contributions leads to an occasional contributor becoming a core developer. I've seen this through leading the Black project. It's now maintained by 9 people including me.

The DIR position is patterned after a successful program for the Python-based Django web framework; since 2014, the Django fellowship program has been paying people to handle "some of the administrative and community management tasks" for the project. One aspect of that program that Langa has adopted is its weekly progress reports; transparency is one of the key elements of the job and in measuring its impact. He noted that metrics like the number of pull requests and bug reports handled are useful, but there is more that he (and the community) would like to know:

It would be awesome to have some insight into whether having a DIR improves the health of the Python community, has any concrete impact over Python adoption, or Python runtime's performance, and so on, and so on. How to measure this is admittedly unclear to me at this point.

He will be undertaking some larger-scale research to try to help determine what kinds of work the project's volunteers are doing and how the CPython project is functioning overall. For example, the Python standard library is often under discussion within the project, but there are unresolved questions about it that he will be seeking answers on:

Research to understand the project better can be done by capturing user interest in particular libraries within the standard library, the amount of work given libraries require, and who the active experts behind the libraries are. This can be done through open issue analysis, the amount of pull requests for a given library, but also through surveying core developers and users as some libraries might require little maintenance but be critical. The reason to do this research is to determine which standard library modules need help and what the maintainer cost is for standard library modules.

So far, Langa has posted two admirably detailed status reports for the first two weeks. Each includes a daily log of his activities, which show an eye-opening amount of progress with closing pull requests and bug reports. In addition, there is quite a bit of other information about the things that he looked into. For example, he observed a test failure on Windows in week one:

Since Azure Pipelines just released an update to their Windows image and I identified that the problem only happens with the new image, I was ready to report a regression on their GitHub project. But I noticed that somehow the problem only happens to me.

I joked that this is probably because of my first name… and it turned out to be true. Maybe I shouldn't be surprised. I have a long history of Unicode-related issues affecting me in the real world.

Long story short: the new Azure Pipelines image includes the full name of the PR author in an environment variable. The HTTP_ACCEPT tests tried to serialize all of os.environ to an ASCII string in the CGI script. This crashed the CGI script but since the tested server is fork-based, this crash was only seen on the test side as truncated output.

Knowing this, it was easy to fix. But this [easily] took 10 hours of work for me this week.

That same kind of problem manifested itself (more benignly) during his 2018 Python Language Summit talk: "[...] he noticed his name in Larry Hastings's schedule-display application started with the dreaded ▯ rather than Ł. That, he said with a grin, is the story of his life."

Meanwhile, in week two, he tackled some problems with tests that intermittently fail in the continuous integration (CI) system. While there are efforts to reduce the number of such tests, or to reduce their volatility, tests for areas like networking or that use timeouts will likely always be somewhat problematic; he has improved things substantially:

Up until now, re-runs triggered re-running all tests in the affected test file. As you can imagine, the test files for the most flaky tests tend to also be the largest. Now with a change I made (see BPO-44708 for details), we are only re-running affected test methods which speeds up the occasional re-run dramatically.

[...] As you can see, re-running concurrent_futures tests now takes 2.5s instead of over 82s.

Interestingly, this not only increases speed of the re-runs but also makes it more likely that they will succeed. You see, the fewer tests we need to re-run, the less likely we are to hit another intermittent failure.

One guesses that these reports may become more terse over time, but they definitely reflect a high level of excitement with his new role. Langa is also cognizant of his responsibility both to CPython and to the DIR program. He strongly believes in the need for this position—it could perhaps lead to other paid positions within the Python ecosystem for one thing—so he intends to leave a lasting impression of its value:

On the other hand, this year will prove whether this position is worth keeping for future years. I deeply believe it is, therefore it all comes down to my performance over the next twelve months.

A recent thread on the python-dev mailing list highlights the impact the DIR position could have. In the thread, a Python user pointed to a bug that was filed in 2017, had a pull request associated with it, and still remained unfixed, They wondered if that was evidence that the Python review process is flawed. As Van Rossum replied, Python is no exception to the rule that "*maintainer attention* is actually the scarcest resource in many open source projects". In addition, while it may look like a bug fix "just" requires review, often that is actually the most difficult part:

I think there's a misunderstanding here -- you seem to imply that producing a bugfix is work that takes somebody's time, while reviewing a bugfix is not work and doesn't cost anything. But realistically, for most issues, things are the other way around -- writing the code is easy (at least to a core dev :-) but reviewing code is a gut-wrenching process that takes up emotional energy and a lot of time. Given the discussion in the issue corresponding to the PR it is clear that that is what is going on here.

As Barry Warsaw pointed out, unblocking this kind of problem "is exactly what the Developer-in-Residence program was designed to address". That specific problem was resolved by Van Rossum before the DIR came on board, but one might guess that these kinds of problems will be reduced over the next year.

There are other examples of people being hired by foundations to work on open-source projects, and some companies are supporting those contributors, both full- and part-time, as well. The Linux Foundation fellows are a prominent example; they often take on duties that might not be done by volunteers or those solely focused on their company's development priorities.

Hiring a Developer-in-Residence is a big step for the PSF, but one that seems likely to pay outsized dividends. Bringing in more contributors, which will hopefully lead to more core developers, is important for any open-source project—Python is no exception there either. Providing a smoother path for those contributors in the early going, and trying to ensure that their efforts do not languish, will help a lot in that effort. Finding a way to hire for this kind of role is a step that more projects should consider—many probably will.


Index entries for this article
PythonCPython
PythonPython Software Foundation (PSF)


to post comments

Python gets a "Developer-in-Residence"

Posted Jul 28, 2021 22:17 UTC (Wed) by LtWorf (subscriber, #124958) [Link] (24 responses)

Very OT but… DO NOT USE THE BLACK CODE FORMATTER.

It changes its mind on what the style should be across versions, so unless your build tools and git hooks that check the format, and all the developers all run the same distribution, you will encounter pain.

Also on version bump you will have the giant commit to restyle everything.

Interestingly formatting a formatted code with a newer version and then reformatting with the older version will not reset the format completely.

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 1:14 UTC (Thu) by jerojasro (guest, #98169) [Link] (4 responses)

While getting your code reformatted on version-bump is quite annoying (hasn't happened to me, though, but I take your word for it), I don't really see the fuss about it, or the need for all-caps, at least in *this* article; the code-formatting library is one of the few that I'm quite comfortable pinning to a specific version for a project's lifetime to avoid the issue you mention.

Your comment feels very OT, indeed.

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 5:21 UTC (Thu) by LtWorf (subscriber, #124958) [Link] (3 responses)

Well it's not a library that is part of the project. When developers are having different distributions they will get different versions, so their reformat will keep changing the same stuff back and forth.

Just thought of saving people some waste of time, as i wish I knew about this.

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 14:24 UTC (Thu) by mathstuf (subscriber, #69389) [Link] (2 responses)

This is why, IMO, code formatting should be enforced at the integration time rather than development time (such as as a commit hook). Instead, CI should verify it and rewrite the branch (or just make a "reformat new code" commit if you're ok with that…) to apply the formatting as desired. Then everyone agrees on what version of the formatter is being used and you don't have your Debian developers "fighting" with your Arch developers via their formatting tool availability.

Since the projects I work on only have a single release branch maintained at a time, right before we branch is a great time to update the formatter (clang-format has the same issue as black described at the top here) and reformat the entire repository using its updated opinions. With more than one release branch, there's no good time to reformat wholesale however.

Python gets a "Developer-in-Residence"

Posted Aug 2, 2021 7:56 UTC (Mon) by massimiliano (subscriber, #3048) [Link] (1 responses)

This is why, IMO, code formatting should be enforced at the integration time rather than development time (such as as a commit hook).

I have a slightly different take on this.

IMHO, CI should never rewrite (reformat) your code, it should just fail the build if it is malformed (just like if a test failed).

What commit hooks should do, instead, is run tools that are in sync with whatever CI is doing on that branch, so that they will not introduce failed builds. I usually achieve this making so that every dev has the "official" development environment available using docker, the Dockerfile is in the repo, and the scripts that the developer (or commit hook) uses run the same tools that CI runs (because CI ultimately uses the same Dockerfile: it's in the repo).

Keeping the Dockerfile in the repo is what keeps CI and the dev env in sync. It is a technicality, an implementation detail, but the general principle is to specify the development tools unambiguously and make so that both developers and CI use exactly the same tools at every commit by keeping that specification in the same repo as the code. Often using docker is a practical way to do it, but of course, others are possible.

Python gets a "Developer-in-Residence"

Posted Aug 2, 2021 11:42 UTC (Mon) by mathstuf (subscriber, #69389) [Link]

CI doesn't *automatically* do it. You need a `Do: reformat` command (so you can plan for it at least).

> it should just fail the build if it is malformed (just like if a test failed).

Given how unsure many developers are with `git rebase -i` and resolving intra-branch conflicts due to reformatting, this will just end up littering the history with useless "fix clang-format" commits instead of people integrating the diffs back into the appropriate commit.

> I usually achieve this making so that every dev has the "official" development environment available using docker

That assumes you can even *have* an "official" development environment. It also doesn't consider non-Linux platforms at all.

> run the same tools that CI runs (because CI ultimately uses the same Dockerfile: it's in the repo).

One of the design decisions we had when making our workflow tool (ghostflow) is that *no* code in the repo is trusted, so none of it is executed (be it in a Dockerfile or no). It can indicate *what* to run (e.g., "file X uses clang-format-9, but file Y is third party code, so ignore it"), but how it is run is in the workflow deployment, not the repository.

> Keeping the Dockerfile in the repo is what keeps CI and the dev env in sync. It is a technicality, an implementation detail, but the general principle is to specify the development tools unambiguously and make so that both developers and CI use exactly the same tools at every commit by keeping that specification in the same repo as the code. Often using docker is a practical way to do it, but of course, others are possible.

We're not making a *product*, so there's not "one build" that is blessed. We get bugs about it not working on Windows, macOS, Arch, Fedora, Ubuntu, HPC deployments, weird MPI deployments, vcpkg, etc. A diverse development base helps flush things out that we just can't test for.

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 7:53 UTC (Thu) by hynek (subscriber, #55397) [Link] (13 responses)

As someone who has used Black since the earliest alphas, I have to say this is a misrepresentation.

Łukasz and his team are doing their best to keep changes meaningful and at a minimum. It has been _months_ since it happened to any of my many code bases, and it was always worth it.

> Interestingly formatting a formatted code with a newer version and then reformatting with the older version will not reset the format completely.

Since Black goes for a canonical code form, the only reason why this could be true is a bug. Software sometimes has bugs, it's sad but true. On the other hand, YELLING that nobody should should use Black is rude FUD. It certainly isn't an outlier bug-wise.

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 10:05 UTC (Thu) by rsidd (subscriber, #2582) [Link] (9 responses)

Thanks. I hadn't encountered Black before, but on reading the docs, it certainly looks like any version differences are minor and shouldn't restyle everything (if already restyled by a previous version of Black). But it does sound like you should use only Black and not mix it with any other styler. So the shouty comment does sound like FUD. The author probably had a genuine bad experience, but there are more productive ways to share it.

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 12:28 UTC (Thu) by hynek (subscriber, #55397) [Link] (5 responses)

Yes, since Black formats everything to a canonical shape, it makes no sense to have other formatters.

With one exception: isort, because Black doesn’t format imports.

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 19:14 UTC (Thu) by NYKevin (subscriber, #129325) [Link] (2 responses)

> With one exception: isort, because Black doesn’t format imports.

AIUI, this is a deliberate choice on the part of Black, because imports can have side effects.

(Imports *should not* have side effects. You should be able to reorder them without breaking anything. But bad code exists, so...)

Python gets a "Developer-in-Residence"

Posted Jul 30, 2021 7:37 UTC (Fri) by hynek (subscriber, #55397) [Link] (1 responses)

It's even more complicated than that.

Since PEP 8 asks you to sort your import into blocks of standard library, 3rd party packages, and app packages, a non-trivial insight into the packaging situation of the current app/package is required. Thus it makes sense to punt on it, since it would open a completely new can of worms and the code is already present in isort.

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 21:57 UTC (Sat) by NYKevin (subscriber, #129325) [Link]

Right. But Black's documentation also says that it is not supposed to change the AST at all, except in a small number of special cases which should not affect runtime behavior.[1] Since import-reordering actually could change the runtime behavior, I think they consider it permanently out-of-scope, rather than just "too hard."

(As mentioned before, there is no good reason for import-reordering to change runtime behavior. It's just that Python doesn't have any hard limits which prevent you from shooting yourself in the foot like that.)

[1]: https://black.readthedocs.io/en/stable/the_black_code_sty...

Python gets a "Developer-in-Residence"

Posted Jul 30, 2021 8:22 UTC (Fri) by rsidd (subscriber, #2582) [Link] (1 responses)

If I understand the Black docs right, Black formats imports (I just checked: it does), but doesn't sort them?

Python gets a "Developer-in-Residence"

Posted Jul 30, 2021 14:01 UTC (Fri) by kpfleming (subscriber, #23250) [Link]

Correct. (plus some characters)

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 7:43 UTC (Sat) by LtWorf (subscriber, #124958) [Link] (2 responses)

> So the shouty comment does sound like FUD. The author probably had a genuine bad experience, but there are more productive ways to share it.

It's not FUD if it's real.

It's a tool that in theory wants to be like go fmt, but in practice isn't, and creates the need to reformat the whole codebase (and pollute commit history) periodically.

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 10:53 UTC (Sat) by rsidd (subscriber, #2582) [Link] (1 responses)

It aims to minimize diffs. The version-to-version changes suggest that some small specific bits, at most, would be reformatted, so the diff from formatting a previously Black-formatted file with a new Black version should be tiny.

If you really have an example where the entire file was changed by a new version of Black, why not report that as a bug? I don't see how that can happen with any format tool, actually.

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 13:42 UTC (Sat) by mathstuf (subscriber, #69389) [Link]

> I don't see how that can happen with any format tool, actually.

The usual culprits in my experience include (in a rough order):

- line length breaking heuristics
- updates to the language (e.g., C++03 → C++11 made lots of "> >" → ">>" diff noise)
- more insight into comments (reflowing paragraphs or such) or macros

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 7:42 UTC (Sat) by LtWorf (subscriber, #124958) [Link] (2 responses)

> It has been _months_ since it happened

It should just not happen, because commits that change hundreds of files at once, with "style" as description make going back in history incredibly hard.

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 15:21 UTC (Sat) by rsidd (subscriber, #2582) [Link] (1 responses)

You have a python project with hundreds of files? That was bitten by this issue where every file was totally changed by a new version of black? Is it then that hard to report a bug, saying, file example x formatted by black version y, then reformatted by black version z, has an enormous diff?

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 17:51 UTC (Sat) by LtWorf (subscriber, #124958) [Link]

Since I only use stable distributions, how is that going to help? The authors can't change the past, and any "fix" will only generate more diff.

My issue is more on the general approach of the project, that seems to be ok with periodically having to reformat stuff.

Python gets a "Developer-in-Residence"

Posted Aug 1, 2021 15:03 UTC (Sun) by sjj (guest, #2020) [Link]

Apparently some code formatters can create deep emotional traumas that burst forth in unrelated blog comment sections. Dangerous stuff.

Python gets a "Developer-in-Residence"

Posted Aug 2, 2021 13:10 UTC (Mon) by obspsr (subscriber, #56917) [Link] (3 responses)

What is the reason of calling a formatter "Black" ? ! Here in Europe we do not understand US jokes, hardly KerryMen's jokes so ... :-((

Python gets a "Developer-in-Residence"

Posted Aug 2, 2021 13:24 UTC (Mon) by farnz (subscriber, #17727) [Link] (2 responses)

The author of the "Black" code formatter is Polish, and IIUC chose the name because it's a formatter that "gives you any colour you want, as long as it's black", in reference to the apocryphal quote from Henry Ford about the Model T.

Python gets a "Developer-in-Residence"

Posted Aug 2, 2021 13:43 UTC (Mon) by obspsr (subscriber, #56917) [Link]

For sure ! ... I remember now that Henri Ford told that but my grand-father was the first reseller of General Motors in 1925 and
we where more GM and Sloan oriented ! Thanks.

Python gets a "Developer-in-Residence"

Posted Aug 2, 2021 13:50 UTC (Mon) by excors (subscriber, #95769) [Link]

> The author of the "Black" code formatter is Polish, and IIUC chose the name because it's a formatter that "gives you any colour you want, as long as it's black", in reference to the apocryphal quote from Henry Ford about the Model T.

The documentation for Black prominently says "Any color you like", so that does sound like the source of the name.

Regarding the authenticity of the quote, Henry Ford's autobiography says: (https://en.wikisource.org/wiki/My_Life_and_Work/4)

> No business can improve unless it pays the closest possible attention to complaints and suggestions. If there is any defect in service then that must be instantly and rigorously investigated, but when the suggestion is only as to style, one has to make sure whether it is not merely a personal whim that is being voiced. Salesmen always want to cater to whims instead of acquiring sufficient knowledge of their product to be able to explain to the customer with the whim that what they have will satisfy his every requirement--that is, of course, provided what they have does satisfy these requirements.
>
> Therefore in 1909 I announced one morning, without any previous warning, that in the future we were going to build only one model, that the model was going to be "Model T," and that the chassis would be exactly the same for all cars, and I remarked:
>
> "Any customer can have a car painted any colour that he wants so long as it is black."

It seems colour wasn't really the point - it was to illustrate his broader idea that it was better to just produce a single model of car and tell customers that that's what they ought to want, in order to lower production costs and widen the market for cars, which would more than make up for any losses in the luxury end where customers expect companies to cater to their whims.

(It's possible that Ford or his ghostwriter made up the quote with the benefit of hindsight, but at least it's a less apocryphal source than many famous quotes.)

Python gets a "Developer-in-Residence"

Posted Jul 29, 2021 1:36 UTC (Thu) by songmaster (subscriber, #1748) [Link]

The Perl Foundation has been funding Dave Mitchell and Tony Cook to do this kind of work on the Perl 5 core for many years using their Grant Proposal mechanism, https://news.perlfoundation.org/list?category=Grants

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 20:29 UTC (Sat) by ehiggs (subscriber, #90713) [Link] (2 responses)

> As you can see, re-running concurrent_futures tests now takes 2.5s instead of over 82s.

> Interestingly, this not only increases speed of the re-runs but also makes it more likely that they will succeed. You see, the fewer tests we need to re-run, the less likely we are to hit another intermittent failure.

I'm aware/familiar of the operational realities of flaky tests and also requiring a green build to merge. But concurrent futures is likely non-deterministic code. IME if concurrent tests fail ever then it's **definitely** wrong and any green test result is luck. Rerunning to tease out a green test suite run is not a good useful in the slightest.

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 20:30 UTC (Sat) by ehiggs (subscriber, #90713) [Link]

> Rerunning to tease out a green test suite run is not a good useful in the slightest.

Bad edit :(

Rerunning to tease out a green test suite run is not {a good idea | not useful} in the slightest.

Python gets a "Developer-in-Residence"

Posted Jul 31, 2021 21:34 UTC (Sat) by mathstuf (subscriber, #69389) [Link]

I don't think that's talking about "rerunning until it passes", but rather "if the test suite determines you may have affected it, it no longer takes more than a minute". But there are tests that are useful to "rerun until pass or N failures" (in one project I work on, context menus are opened which are display manager modal in X and serializing the tests is not feasible as it'd easily make the test suite take 5x longer to run). Tests involving inter-thread communication are better to "rerun until failure or N passes" though.


Copyright © 2021, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds