-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add a new SessionConfig
object to allow advanced configuration of the Downloader
#92
Conversation
Codecov Report
@@ Coverage Diff @@
## main #92 +/- ##
==========================================
+ Coverage 92.48% 93.33% +0.84%
==========================================
Files 4 5 +1
Lines 466 540 +74
==========================================
+ Hits 431 504 +73
- Misses 35 36 +1
Continue to review full report at Codecov.
|
SessionConfig
object to allow advanced configuration of the Downloader
I am going to ping people who have contributed to see if anyone wants to comment on this PR, and give people a chance to ask for tweaks before I push a major release. |
@@ -38,6 +38,9 @@ stages: | |||
- linux: build_docs | |||
pytest: false | |||
|
|||
- linux: mypy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypy
has pre-commit hooks if you want to avoid adding another job here: https://github.com/pre-commit/mirrors-mypy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have both. It usually helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only didn't put it in the pre-commit because mypy can be a little slow to run (and there wasn't any mention of the pre-commit in mypy's docs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I in general prefer using pre-commit for stuff which autofixes, especially with the pre-commit ci service autofixing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a bit bored reviewing this, sorry, but hopefully what I've left are some very minor but helpful comments...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring is looking good.
I would only suggest to use a library more suited to handling env vars than manually parsing them. I've suggested pydantic below.
@@ -38,6 +38,9 @@ stages: | |||
- linux: build_docs | |||
pytest: false | |||
|
|||
- linux: mypy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have both. It usually helps.
Thanks for the review @GitHK, are you using the |
No issue for me. Go ahead and remove it. We usually do periodic updates and fix these small issues. |
@GitHK Thanks! I have pulled it now, I am going to keep headers around for people using previous versions of sunpy. |
I have pushed 2.0.0rc1 up to PyPI if people want to test this and open any issues. |
@@ -36,6 +36,7 @@ | |||
"sphinx.ext.napoleon", | |||
"sphinx.ext.todo", | |||
"sphinx.ext.viewcode", | |||
"sphinx_autodoc_typehints", # must be loaded after napoleon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How well does this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only used it in two small libraries, this one and dkist and so far very happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about if we used this for a bigger library that starts with the letter s?
Overall: 👍 on pydantic, such a great library. |
This PR introduces breaking API changes, it will form a 2.0 release of parfive.
fixes #38
fixes #29
This PR is motivated by the fact that we have been slowly growing more and more keyword arguments, environment variables etc at various levels in the class.
This PR cleans up the environment variable handling and keyword arguments to the main
Downloader
class by making a config object which holds the state for the instance. As well as this some of the more obscure keyword arguments are moved into aSessionConfig
object.Changes in this PR
PARFIVE_HIDE_PROGRESS
environment variable will disable all progress bars.file_progress=
,use_aiofiles=
andnotebook=
keyword arguments have been moved into the newSessionConfig
object which can be passed toDownloader()
as theconfig=
keyword argument.headers=
keyword argument toDownloader()
is now deprecated in favour of passing them as part of theSessionConfig
object. They will be removed in a future release.Downloader
class is instantiated (by the new config classes).True
.timeouts
keyword argument has been removed from therun_download()
anddownload()
methods and replaced by an option inSessionConfig
.aiohttp.ClientSession
with theaiohttp_session_kwargs=
keyword argument toSessionConfig
.SessionConifg
where previously it could only be configured with an environment variable.SessionConfig
and the default when not using aiofiles has been increased from 100 bytes to 1024 bytes.SessionConfig
as well as theHTTP[S]_PROXY
environment variables.aiohttp.ClientTimeout
object toSessionConfig
.