I have quite a few engineering diagrams that have been annotated in CDF and now we need to convert them to SVGs in order for some third party application to read them. The API supports this, but the Python SDK does not, or at least not directly. It is possible to force the behavior, but it requires a cumbersome workaround to “trick” the SDK.
The SDK seems to expect that the convert job is the next after detect, in theory this makes some sense, however in reality this is not how it will be done. The process will be to detect annotations, then get them approved, then generate the SVG file. The middle step is a manual and the convert job will be run as a separate pipeline.
As shown below, the API supports this by having the feature that we can send in the file and the annotations, the input for the SDK is the output of detect. It is possible to replicate the required input, but it is cumbersome. Is there a way to more simply use the files and the annotations through the SDK to convert the files after the fact?
Ideally I would want to do something like this:
files = client.files.list(data_set_external_ids=docDataSetExtId)
ext_ids = [f.external_id for f in files]
flt = AnnotationFilter(annotated_resource_type="file", annotated_resource_ids=[{"externalId": ext_id} for ext_id in ext_ids])
annotations = client.annotations.list(flt, limit=-1)
# This
client.diagrams.convert(files, annotations)
# or like this
for file in files:
flt = AnnotationFilter(annotated_resource_type="file", annotated_resource_ids=[{"externalId": file.external_id}])
annotations = client.annotations.list(flt, limit=-1)
client.diagrams.convert(file, annotations)
# Or even just having the SDK handle all of it in the background (best option for me)
# And then the SDK or CDF itself just retrieves all annotations linked to the file
client.diagrams.convert(external_id=file.external_id)

https://api-docs.cognite.com/20230101/tag/Engineering-diagrams/operation/diagramConvert
