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

Fix issue 292 adhoc services and passing session through #293

Closed
wants to merge 29 commits into from
Closed

Fix issue 292 adhoc services and passing session through #293

wants to merge 29 commits into from

Conversation

trjaffe
Copy link
Contributor

@trjaffe trjaffe commented Jan 26, 2022

The original issue is simple to fix in scs.py. But in order to test it, I needed to be able to call a development server that didn't have the right certificate information. So I wanted to be able to do this:

session=requests.Session()
session.verify=False
conetest=vo.dal.SCSService('https://dev.server/vo/cone?table=foobar',session=session)
links=results[0].getdatalink(session=session)

etc. So I added the option to specify the session in the .getdatalink() method. It in turn calls some DAL methods that already take an optional session, so the change to help me debug was small and will be useful in future. It's undoubtedly also useful in other methods, but there might be a better way to do this. For instance, in DALResults, the method from_result_url() (called by getdatalink()) calls use_session() from utils/http.py, which creates a new session by default. Instead of creating a new one, DALResults could use self._session. In that case, the above call to getdatalink() wouldn't have to specify the session and would automatically inherit the one used in the cone service, the one already defined with verif=False.

Thoughts?

@trjaffe trjaffe marked this pull request as draft January 26, 2022 19:42
@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #293 (1d2281e) into main (b5b33e8) will decrease coverage by 0.01%.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##             main     #293      +/-   ##
==========================================
- Coverage   75.50%   75.49%   -0.02%     
==========================================
  Files          44       44              
  Lines        5128     5125       -3     
==========================================
- Hits         3872     3869       -3     
  Misses       1256     1256              
Impacted Files Coverage Δ
pyvo/dal/tap.py 73.37% <50.00%> (ø)
pyvo/dal/adhoc.py 66.58% <83.33%> (+0.48%) ⬆️
pyvo/__init__.py 100.00% <100.00%> (ø)
pyvo/dal/scs.py 68.57% <100.00%> (ø)
pyvo/dal/ssa.py 56.00% <100.00%> (ø)
pyvo/utils/compat.py 100.00% <100.00%> (ø)
pyvo/_astropy_init.py

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Contributor

@msdemlei msdemlei left a comment

Choose a reason for hiding this comment

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

I've never looked into the inner workings of passing around the session, but these changes look very reasonable.

On changing the MRO on SCSResults: Let's go for it.

@andamian
Copy link
Contributor

andamian commented Mar 17, 2022

There are a number of simple workarounds (kludges) to this problem:
1.

import os
from requests.packages.urllib3.exceptions import InsecureRequestWarning
os.environ['CURL_CA_BUNDLE'] = ''   # disable cert check
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)  # ignore warning

The CURL_CA_BUNDLE can be set in the environment without touching the library code.
2. Add session.verify = False to

return session

However, the ability to pass an external session might have its own merits (apart from setting verify=False) and should probably be considered in the context of the upcoming proposed changes to SSO (https://wiki.ivoa.net/twiki/bin/view/IVOA/SSO_next).

@trjaffe trjaffe marked this pull request as ready for review May 5, 2022 15:49
@trjaffe
Copy link
Contributor Author

trjaffe commented May 5, 2022

What do I need to do to get this through?

pyvo/dal/adhoc.py Outdated Show resolved Hide resolved
@bsipocz bsipocz added this to the v1.4 milestone May 5, 2022
@trjaffe
Copy link
Contributor Author

trjaffe commented May 5, 2022

Apparently my rebase screwed everything up. Might be best to nuke it all from orbit and start over.

@bsipocz
Copy link
Member

bsipocz commented May 5, 2022

Apparently my rebase screwed everything up. Might be best to nuke it all from orbit and start over.

I'm happy to fix it for this PR if you prefer. (you might not have pushed the rebased version back with --force? )

@trjaffe
Copy link
Contributor Author

trjaffe commented May 5, 2022

Apparently my rebase screwed everything up. Might be best to nuke it all from orbit and start over.

I'm happy to fix it for this PR if you prefer. (you might not have pushed the rebased version back with --force? )

I did. Isn't that the correct way? But why does the PR now show that I changed 31 files when I only changed a couple of them? I was wondering if the fact that I forked before master became main would cause git any confusion. If it's not fixable, I can close this, delete my fork and start fresh and do a new PR.

@bsipocz
Copy link
Member

bsipocz commented May 5, 2022

Yes, it's the correct way.
I'm just guessing around for the source of the issue, I've seen it many times, but it's still puzzling how people end up in it.
Maybe you didn't fetch the astropy version before you did the rebase?

Anyway, at this point, an interactive rebase is needed on the freshly fetched astropy version. And it has to be interactive to be able to remove the duplicated commits.
(https://github.com/bsipocz/pyvo/tree/rebased_issue292)

@andamian
Copy link
Contributor

andamian commented May 5, 2022

Apparently my rebase screwed everything up. Might be best to nuke it all from orbit and start over.

That's exactly why I prefer the "Squash and merge" approach. I've screwed it up myself so many times that I think that the benefits of rebasing are not worth it.

@bsipocz
Copy link
Member

bsipocz commented May 5, 2022

Apparently my rebase screwed everything up. Might be best to nuke it all from orbit and start over.

That's exactly why I prefer the "Squash and merge" approach. I've screwed it up myself so many times that I think that the benefits of rebasing are not worth it.

Haha, I firmly believe that there are usually one or two tricky steps, and if one identifies them they will be set up to be a rebase wizard for life. Typical issues are that the rebase branch is not the up-to-date one but either the default branch from the fork, or an outdated version from upstream. And other typical issue is that force push isn't used instead the offer by github to update is accepted (and that lands a 'main' merge commit in the branch). Even in the case when it doesn't introduce extra unrelated commits, it brings in a nonlinear branch structure that is not nice to work with if/when a bisect or any history digging is required.

IMO the squash on merge has a ton of negative side effects, 1: it doesn't create a merge commit on the main branch but puts the squashed commit on it directly. That messes up a lot of the release scripts (you may not use those in pyvo, but they are super useful to identify any changelog and backport inconsistencies before they end up in a release) and possibly with the backports, too.
2) And while "squash and merge" is fine for small PRs like this one, in the case of a big feature I would prefer to have multiple commits that carry the history of the development, e.g. easier to go back and check when and possibly why a bug got introduced. It's not that easy to bisect and land on a thousand-lines worth of change instead of a logical chunk of a few dozens or a hundred.

Anyway, I'm not a maintainer here, so I'm OK with whichever workflow you decide to follow.

(one rather good resource to practice some of the scenarios is https://learngitbranching.js.org/, especially the remote and advanced topics)

@andamian
Copy link
Contributor

andamian commented May 6, 2022

I agree 100% (and thanks for the resource). Re-basing makes sense for large projects or commits but the effort is not justified in all cases. That's why in PyVO, oftentimes we've been accepting "Squash and merge".

@trjaffe
Copy link
Contributor Author

trjaffe commented May 11, 2022

Closing in favor of cleaner PR #327

@trjaffe trjaffe closed this May 11, 2022
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.

None yet

8 participants