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

Major DTO implementation #15

Merged
merged 123 commits into from
Mar 27, 2024
Merged

Major DTO implementation #15

merged 123 commits into from
Mar 27, 2024

Conversation

modifies the test endpoint so if you pass a file name it just runs that
test suite, if you don't then it will run all tests in the tests/ folder
APIEndpoint is a more fitting name going fowards as we implement
discover and caching REFS #5 and #8
gallagher command centre can have features not available per instance of
the command centre, this makes all the features optional hence if
one is not licensed then an exception is thrown by the client

REFS #8
we are moving towards discovering the api endpoints dynamically, this
is a major refactor in the way the api endpoints are going to work

REFS #5 and #8
gallagher command centre makes available a set of hrefs that should be
dynamically references as opposed to statically referencing api endpoints
this is the start of the change to do so. as part of this it's recommended to

- drop the root api endpoint query to be a privat endpoint
- the utils package to be renamed as core
- move the discovery contant outside of the APIEndpoint class

REFS #5
this is my first refactor towards getting dynamic discovery working
there are still issues with accessing the singlton to share the
discovered version around along side caching the discovery results

REFS #5
the project is now registered on pypi, initially published through
my personal development computer, we want to eventually move this to
be part of our ci/cd pipeline and publish the package through a github
action REFS #16
this a commit in a separate branch for me to experinment implementing
dynamic discovery of the api endpoints, at the moment because of
import cycles the singleton seems to be overrwritten

REFS #5
we have the discovery object being initialised when the base class
initialises and then the discovery fetches the url, note that
the href that the discover will return are fully qualified addresses

this drops using the api_base prefix

post this we need to formalies the configuration and syntax so this
scales to all endpoints

we are also yet to test for unlicensed features
REFS #5
adds context around the design of the classes and lifecycle for dynamic
discovery of api endpoints

REFS #5
the base model has a field called good_known_since, the intention is to
set a timestamp once a response has been parsed, so the application can
use this to identify if the response is stale and if it requires revalidation
pyndatic provides a post_init hook, this introduces use of this hook in the BaseModel
https://docs.pydantic.dev/2.0/api/main/\#pydantic.main.BaseModel.model_post_init
the original design intended to cache the Discovery response to conform hateoas
#5

overriding the pydantic method model_post_init to set the good_known_since var
introduced an error where the test first test would run the subsequent calls would fail
https://docs.pydantic.dev/2.0/api/main/\#pydantic.main.BaseModel.model_post_init

debugging this i found that the discover was running every time as the good_known_since
would never have been set and the cache check would fail.

initially thought of this as a bug with how parsing was working but turns out that if
the cache was detected then we were returning without initialising the configuration
against the discovery response.
by default we raise an exception on the get_config method in the base class
this ensures that only classes that implement (i.e real classes) the get_config
method execute
test anything protocol is a highly parseable output format
https://testanything.org/philosophy.html

this adds the plugin to pytest to produce tap output
starts work on #26 in readiness #25
inline with completing the parsing portion of the library we need to
address the pdf data which is dynamically discovered from the command
centre, REFS #1

we have started a discussion around this on the pydantic repo
pydantic/pydantic#8596

and must implement the most pydantic version of the solution
doing some ground work towards #1 where we need pdf fields to be
auto discovered for the dynamically parseable feature to work properly

this commit parse the basic list call for PdfDefinitions, detail and
other preloading functions to be added post this commit
@devraj devraj marked this pull request as ready for review March 27, 2024 21:45
@devraj
Copy link
Member Author

devraj commented Mar 27, 2024

Turning this PR into "ready for submission", this has been going for a while so I wan to merge these changes into the main branch so I can close off some of the operational tickets like #30 and #16

Some of those will be done on the main branch itself, post which I recommend protecting the main branch and then moving back into the feature branches with PRs.

@devraj devraj merged commit a38dcc3 into master Mar 27, 2024
1 check passed
@devraj devraj deleted the dto-implementation branch March 27, 2024 22:07
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.

1 participant