-
Notifications
You must be signed in to change notification settings - Fork 11
Major typing update. #71
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
base: main
Are you sure you want to change the base?
Conversation
…d returned for dataset create, dataset update, sample create, sample update, instrument create, instrument update, proposal create, proposal update, and datablock create. There are now endpoints for deleting samples, instruments, and proposals.
…s array. Same with sample IDs.
…ned on a call to an API endpoint (.../v100/...) that doesn't exist, but what it's actually testing is the "datasets_get_one" call, which has traditionally returned a 404 when the criteria given to the endpoint do not match any records. That is not a 404. That is a successful HTTP call to a valid endpoint, which does not garner a 404 status code. Instead the endpoint should return a response indicating there was no matching record. Pyscicat now returns 'None' for that case, which is much more appropriate than a 404 exception. That change now makes this test fail, because this test expects a 404. This test is also bogus because the client would not even be able to authenticate, let alone make a request for a dataset, if the base URL provided was invalid, so a user would never reach this state.
|
about This test no longer applies. It's meant to ensure that a 404 is returned on a call to an API endpoint (.../v100/...) that doesn't exist, but what it's actually testing is the "datasets_get_one" call, which has traditionally returned a 404 when the criteria given to the endpoint do not match any records. That is not a 404. That is a successful HTTP call to a valid endpoint, which does not garner a 404 status code. Instead the endpoint should return a response indicating there was no matching record. Pyscicat now returns 'None' for that case, which is much more appropriate than a 404 exception. That change now makes this test fail, because this test is expecting a 404 on an attempt to call an invalid endpoint (which it is not doing). This test is also bogus because the client would not even be able to authenticate, let alone make a request for a dataset, if the base URL provided was invalid, so a user would never reach this state. |
|
Is this something you need for a project? As we discussed I think pyscicat should move towards being an implementation of the auto-generated SDK with extra bells and whistles, and not spend a lot of time improving the existing API...especially for breaking changes like this. |
|
This is code I put together all at once a few weeks ago at the tail end of the last Pyscicat PR, but deliberately set aside. It's not required for any projects, current or upcoming. It uses pydantic to strictly verify the type of what's coming back from the server and return actual objects (including lists of objects). It's arguably the way the SDK should have worked from the start, but now we've got a userbase to think of, so it may never see the light of day. :D |
Objects of the appropriate types are required and returned for dataset create, dataset update, sample create, sample update, instrument create, instrument update, proposal create, proposal update, and datablock create. There are now endpoints for deleting samples, instruments, and proposals. More accurate models as well.
This PR should represent a version # change for Pyscicat, becayse it will probably break existing code.
For example, instead of this:
We now do this:
Because we're getting back instantiated class objects with real attributes, not just generic objects.