(self, mlmodel_as_input)
| 1598 | [True, False], |
| 1599 | ) |
| 1600 | def test_pipeline(self, mlmodel_as_input): |
| 1601 | model = self.get_test_model_path(return_as_mlmodel=mlmodel_as_input) |
| 1602 | output_dir = str(tempfile.TemporaryDirectory()) |
| 1603 | |
| 1604 | # The API will bisect the model into two chunks, and produces a pipeline model |
| 1605 | bisect_model( |
| 1606 | model, |
| 1607 | output_dir, |
| 1608 | merge_chunks_to_pipeline=True, |
| 1609 | ) |
| 1610 | |
| 1611 | # check the file name is correct |
| 1612 | if mlmodel_as_input: |
| 1613 | name = "" |
| 1614 | else: |
| 1615 | mlpackage_name = os.path.basename(model) |
| 1616 | name, _ = os.path.splitext(mlpackage_name) |
| 1617 | name += "_" |
| 1618 | |
| 1619 | pipeline_path = os.path.join(output_dir, f"{name}chunked_pipeline.mlpackage") |
| 1620 | assert os.path.isdir(pipeline_path) |
| 1621 | |
| 1622 | # check the Core ML model is a pipeline model |
| 1623 | spec = load_spec(pipeline_path) |
| 1624 | assert spec.WhichOneof("Type") == "pipeline" |
| 1625 | |
| 1626 | # cleanup |
| 1627 | if not mlmodel_as_input: |
| 1628 | shutil.rmtree(model) |
| 1629 | shutil.rmtree(output_dir) |
| 1630 | |
| 1631 | def test_compressed_model(self): |
| 1632 | # use coremltools.optimizee to palettize a Core ML model |
nothing calls this directly
no test coverage detected