3.4. Unit test¶
In this chapter, we will verify whether the AIT created up to Section 3.3 operates without using Qunomon. When this verification is complete, AIT execution program that operates on Qunomon will be created.
3.4.1. Prepare for unit test¶
3.4.1.1. Preparation of input data for unit test¶
Important
This task is a necessary preparation for the unit test of AI evaluation program, and it is not involved in the packaged AIT.
Create a directory in {YOUR_AIT_ROOT}/local_qai/inventory
to store your test data for unit test (as test input), and store the test input.
The directory name is obtained from the name
argument of the add_ait_inventories
function used in #5 Manifest Generation area.
Here is a sample structure of test input:
{YOUR_AIT_ROOT} │ └─local_qai │ └─inventory │ └─iris_data tableconvert_csv_4nryby.csv
3.4.1.2. Register test input¶
Set up the value
argument for the input data and parameters defined in the Prepare for the Input area with data for unit testing.
Example
input_generator = AITInputGenerator(manifest_path)
input_generator.add_ait_inventories(name='iris_data', value='iris_data/tableconvert_csv_4nryby.csv')
input_generator.set_ait_params(name='mean_column_name', value='petal.width')
Important
The value defined in this section is used only for unit testing and is not used when running on Qunomon.
3.4.2. Running unit test¶
3.4.2.1. Generation of the AIT Execution Program¶
Run all cells in my_ait.ipynb
and confirm that the execution is successful.
Tip
When ALL RUN is completed, an AIT execution program that runs on Qunomon will be automatically generated.
3.4.2.2. Copying your own python modules (optional)¶
If you have imported your own python module with Jupyter Lab, copy the module to {YOUR_AIT_ROOT}/deploy/container/repository/
.
Note
If you have not created any files other than
the my_ait.ipynb
Jupyter file, this operation is not necessary.
3.4.2.3. Preparation for unit test execution¶
Open Terminal from Jupyter and invoke the script for initialization.
Tip
It is recommended running the bash command.
bash
cd /workdir/root/tool/local_test/
./init.sh
Important
If the following message is seen, please change the line feed code of the init.sh from CRLF to the LF.
bash: ./init.sh: No such file or directory
3.4.2.4. Execute unit test¶
Open Terminal from Jupyter and invoke the script which execute a unit test.
cd /workdir/root/tool/local_test/
./run.sh
Important
If the following message is seen, please change the line feed code of the run.sh from CRLF to the LF.
bash: ./run.sh: No such file or directory
3.4.3. Evaluate unit test¶
Check the files below and make sure the unit tests are successful.
{YOUR_AIT_ROOT}/tool/local_test/ait.log
{YOUR_AIT_ROOT}/local_qai/mnt/ip/job_args/1/1/ait.input.json
{YOUR_AIT_ROOT}/local_qai/mnt/ip/job_result/1/1/ait.output.json
{YOUR_AIT_ROOT}/local_qai/mnt/ip/job_result/1/1/downloads/Log/ait.log
Tip
{YOUR_AIT_ROOT}/tool/local_test/ait.log is output only if the AIT execution fails.
The destination of ait.log can be changed. See the Function definitions area for details.
Tip
If an E901 error occurs, define an object (dictionary etc.) that can be expanded to a String as a method argument.
If your execution was succeeded, the results of execution will be saved to {YOUR_AIT_ROOT}/local_qai/mnt/ip/job_result/1/1
.