StatCan / aaw-contrib-jupyter-notebooks

Jupyter Notebooks to be used with Advanced Analytics Workspace platform
Other
10 stars 13 forks source link

Evaluate turning jupyter-notebooks into an automated test suite for platform #37

Open ca-scribner opened 3 years ago

ca-scribner commented 3 years ago

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.

ca-scribner commented 3 years ago

Objective

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.

Research

Known challenges

KFP

Connections to KFP runner

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:

Tools available

ca-scribner commented 3 years ago

So 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

ca-scribner commented 3 years ago

task paused to do other work