Skip to content

Comments

Pass keyword arguments to TDSCatalog object#303

Open
kahemker wants to merge 1 commit intoUnidata:mainfrom
kahemker:ssl-catalog
Open

Pass keyword arguments to TDSCatalog object#303
kahemker wants to merge 1 commit intoUnidata:mainfrom
kahemker:ssl-catalog

Conversation

@kahemker
Copy link

@kahemker kahemker commented Feb 28, 2020

Description Of Changes

My corporate network does not allow for standard SSL connections to weather forecast servers. I found that by allowing for passing keywords into the TDSCatalog object and then further into the session manager, I could send the appropriate headers and option flags into urllib that allow the get request to succeed.

Checklist

Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! And apologies on the delay in responding. Just a couple minor things here and this can go in.


"""
self.session = session_manager.create_session()
session_manager.set_session_options(**kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this line is doing any good since it sets options after self.session is created. I'm pretty sure it's only the get line below that's doing any good.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is needed for my proxy setup. I use this line to modify the HTTP headers on the request session. If you look inside http_util.py, the set_session_options function adds the keywords I need. Specifically the "User-Agent" parameter in the header.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case, you really should call set_session_options() before calling create_session(). set_session_options only affects subsequent calls to create_session.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting... if I comment out set_session_options after create_session() my code fails from the proxy blocking the request. I expect this.

If I move the set_session_options line before create_session() my code fails from the proxy blocking the request on Line 282 self.session.get(catalog_url, **kwargs). The same failure if comment out set_session_options. This is unexpected based on what you told me.

I'm not going to pretend like I understand what is going on. I just know the code in this PR is the only thing that works for my network.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you show the relevant sample of code you're using with siphon? At least the code that creates a TDSCatalog up to the point that fails? I feel like there's something I'm missing here... (You can add that in a stand-alone comment below since I think we're getting a little long-winded here)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added another comment with some relevant code samples. Sorry it took so long, ran into some issues with cftime package updating and manifesting another bug in pvlib.

@kahemker
Copy link
Author

kahemker commented Apr 7, 2020

I made another repo that shows how I am using this PR. I am doing solar forecasting with PVLIB which uses Siphon to gather data. I had to modify PVLIB to pass additional arguments into Siphon in order to successfully get the request through my corporate proxy.

I hope you can follow my readme when creating the test environment. If you don't install cftime=1.0.4 then you will see a bug related to converting datetime objects and numpy (read this bug report if you are curious)

@CLAassistant
Copy link

CLAassistant commented Apr 10, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Kyle H seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dopplershift dopplershift changed the base branch from master to main October 31, 2024 19:32
@dopplershift dopplershift requested a review from dcamron as a code owner October 31, 2024 19:32
@dopplershift dopplershift added this to the 0.10 milestone Nov 11, 2024
@dopplershift dopplershift removed this from the 0.10 milestone Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL Error with Certificate in catalog.py

3 participants