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

Review comments - Part 1 #70

Merged
merged 18 commits into from
Jan 17, 2022
Merged

Review comments - Part 1 #70

merged 18 commits into from
Jan 17, 2022

Conversation

da1910
Copy link
Collaborator

@da1910 da1910 commented Jan 13, 2022

This PR switches the build backend and consolidates requirements files into pyproject.toml.

Closes #60 - Streamline requirements
Closes #61 - Drop 3.6
Closes #62 - Rename CI/CD step

@codecov
Copy link

codecov bot commented Jan 13, 2022

Codecov Report

Merging #70 (beefd60) into main (91052a4) will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #70      +/-   ##
==========================================
+ Coverage   90.82%   90.95%   +0.13%     
==========================================
  Files           7        7              
  Lines         828      829       +1     
==========================================
+ Hits          752      754       +2     
+ Misses         76       75       -1     
Impacted Files Coverage Δ
src/ansys/openapi/common/__init__.py 100.00% <ø> (ø)
src/ansys/openapi/common/_oidc.py 75.00% <ø> (+0.50%) ⬆️
src/ansys/openapi/common/_util.py 98.36% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 91052a4...beefd60. Read the comment docs.

Copy link
Contributor

@Andy-Grigg Andy-Grigg left a comment

Choose a reason for hiding this comment

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

Some questions and comments, mainly around the OIDC server stuff. Is it worth getting a review from Maksim as well?

pyproject.toml Outdated Show resolved Hide resolved
@@ -233,6 +233,9 @@ def __init__(self):
async def get_auth_code(self):
return self._auth_code.get(block=True)

def __del__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

So even though the OIDCCallbackHTTPServer object was deleted, the server wasn't necessarily closed? Makes sense I suppose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's specifically the socket binding, the garbage collector was probably cleaning up the sever in time, but I think it wasn't actively releasing the socket binding. This looks like it fixes the issue I was seeing, but I'm not confident. I'll address the other comments here and see if the issue recurs in CI runs.

@@ -200,7 +200,6 @@ async def await_callback():
if _log_tokens:
logger.debug(f"[TECHDOCS]Received authorization code: {auth_code}")
self._callback_server.shutdown()
del self._callback_server
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you confirmed that implementing the __del__() method below is sufficient to completely shutdown the server without this explicit del? It might be good to leave this in place, or maybe call server_close? I'm just conscious of accidentally leaving a server socket open.

Choose a reason for hiding this comment

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

It might be good to leave this in place, or maybe call server_close? I'm just conscious of accidentally leaving a server socket open.

We've had issues with pymapdl where we forget to collect the MAPDL instance and leave the remote/local process running. Checking collection in unit testing is helpful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Calling del here was not a practical solution in the long term. Calling shutdown should stop the server, and the __del__() method does seem to be sufficient to release the socket binding.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still a bit paranoid about this. Is it possible to add a test that checks that once the OIDC callback server is deallocated the port binding is gone. Is it possible to write a unit test that asserts the port really is open?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I imagine we could spin a callback server up, hit it with a request, shut it down then see if we bind to the port. I suspect we will be slightly at the mercy of the Linux network stack, but I can give it a go and see.

Testing it in place is on the list of things to do, but it's nontrivial, we need to mock a web browser and IDP (probably adapted from how requests_oauthlib or httpx_auth do it).

pyproject.toml Show resolved Hide resolved
requirements_docs.txt Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
pyproject.toml Outdated
build-backend = "flit_core.buildapi"

[project]
name = "ansys_openapi_common"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the name that will appear on pypi? If so, I think it should be 'ansys-openapi-common'.

@da1910 da1910 merged commit 9a83910 into main Jan 17, 2022
@da1910 da1910 deleted the feat/consolidate-dependencies branch January 17, 2022 10:33
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.

ci stage rename drop py3.6 streamline requirements
3 participants