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

No darkerd HTTP API server similar to blackd #59

Open
akaihola opened this issue Aug 19, 2020 · 0 comments
Open

No darkerd HTTP API server similar to blackd #59

akaihola opened this issue Aug 19, 2020 · 0 comments
Labels
enhancement New feature or request performance Speed or memory usage improvement
Milestone

Comments

@akaihola
Copy link
Owner

A darkerd daemon should import and call Black in-process.

In the comment below from #23, this approach is compared to a darkerd -> blackd solution:


Let's consider a darkerd daemon which makes HTTP API calls to a separate blackd daemon. That would mean

  • two processes running,
  • added code complexity in darkerd, and
  • probably no performance benefits (compared to calling the black Python API directly in the darkerd process).

So the performance benefit would be achieved by just

  • creating a darkerd,
  • making it call the darker Python API, and
  • letting darker in turn call the black and (and optionally isort) Python APIs internally.

Compared to blackd, it's important to consider that it's not possible to pass only source code in the HTTP request. darker needs to have access to the unmodified version of each file in Git HEAD. Do do this,

  • the HTTP request to darkerd must point to actual files on disk (either Git root dir + set of relative paths, or just a set of absolute paths)
  • the darkerd process must have access to the filesystem, so in practice run in the same machine as the caller (i.e. the IDE)

If we were to implement darkerd, I would

  • mirror the implementation of blackd (it's under 200 lines of code)
  • use the same libraries (aiohttp, aiohttp-cors and maybe click)

Originally posted by @akaihola in #23 (comment)

@akaihola akaihola added the enhancement New feature or request label Aug 19, 2020
@akaihola akaihola added this to the 1.3.0 milestone Aug 19, 2020
@akaihola akaihola modified the milestones: 1.3.0, 1.3.1, 1.4.0 Sep 4, 2021
@akaihola akaihola modified the milestones: 1.4.0, 1.4.1 Oct 31, 2021
@akaihola akaihola modified the milestones: 1.4.1, 1.5.0 Feb 8, 2022
@akaihola akaihola modified the milestones: 1.5.0, 1.6.0 Feb 24, 2022
@akaihola akaihola changed the title Expose darker's functionality as an HTTP API with a darkerd server No darkerd HTTP API server similar to blackd Apr 6, 2022
@akaihola akaihola modified the milestones: 1.6.0, 1.7.0 Apr 6, 2022
@akaihola akaihola modified the milestones: 1.7.0, 1.8.0 Dec 28, 2022
@akaihola akaihola added the performance Speed or memory usage improvement label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Speed or memory usage improvement
Projects
Development

No branches or pull requests

1 participant