Open ca-scribner opened 3 years ago
It would be beneficial if we could use some or all of our existing tutorial jupyter-notebooks as automated tests. This would:
If not able to easily use existing guides as tests, defining a format for writing future guides so that they could be used as tests would also be helpful. Examples of this are from fastai who built their own notebook runner and use all guide notebooks as automated tests, including assertions, etc.
Many tests involve submitting kubeflow pipelines jobs, which requires a connection to the KFP runner (typically via instantiating a Client()
). From inside platform, this can be done simply by calling Client()
and using default in-platform authentication. For automated tests handled by a github runner, this would not work.
Possible solutions could be:
Client()
calls (see mlops repo's CI for example of off-platform authentication for submitting kfp jobs
Client()
calls in all test suite examples to use the off-platform authentication. Some ways to do this could be adding a get_client()
helper that is smart enough to fail to off-platform methods, or use something like injecting a mocked Client()
into all examples during testing which overrides default behaviour with the off-platform authentication. For a regular suite of .py
files using pytest, we can inject this code using the conftest.py
file to create a fixture that mocks over Client()
, but the below notebook extensions to pytest don't seem to use the code from conftest.py
start-custom.sh
that we usually start the servers with. pytest --nbval
compares cell output to existing output, pytest --nbval-lax
just makes sure cells run without errorSo far tried using pytest w/nbdev to run our code as a test suite on a github action runner. The only blocker is the one summarized above with connections to KFP runner. If the goal is to run test cases without any changes to the existing code, I hit trouble with connecting to kfp runner using Client()
. Client()
needs additional authentication when off platform. If the test suite was entirely .py
files, I can use conftest.py
(which pytest
will run before testing) to make a global mock of the Client()
that uses an existing Client
fixture that's been properly authenticated off-platform. It works great with .py
, but the pytest
extensions that enable notebook usage are not affected by the fixtures built in conftest.py
(filed issue here to ask about this). Other options are
Client()
call, maybe building a helper function that does this automatically (could first try Client()
but default back to reading extra creds from environment variables and trying a different way?)Client()
for each test somehow else (some pytest
nb extensions had this feature)task paused to do other work
To aid in automated testing of the platform, can we change some or all of the repo into an automated test suite? Could be run by papermill or some other notebook runner, maybe require a specific input/output format to dictate what "success" is, etc.