Skip to content

export_tracking_points

Extract tracking points from Mocha.

ExportTrackingPoints

Bases: Extractor

Export tracking points.

Source code in client/ayon_mocha/plugins/publish/export_tracking_points.py
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
class ExportTrackingPoints(publish.Extractor):
    """Export tracking points."""

    label = "Export Tracking Points"
    families: ClassVar[list[str]] = ["trackpoints"]
    log: Logger

    def process(self, instance: pyblish.api.Instance) -> None:
        """Process the instance."""
        dir_path = Path(self.staging_dir(instance))
        project: Project = instance.context.data["project"]
        layer: Layer = instance.data["layer"]

        process_info = ExporterProcessInfo(
            mocha_python_path=instance.context.data["mocha_python_path"],
            mocha_exporter_path=instance.context.data["mocha_exporter_path"],
            current_project_path=instance.context.data["currentFile"],
            staging_dir=dir_path,
            options=instance.data["exporter_options"]
        )

        """
        representations = self.external_export_process(
            instance.name,
            instance.data["use_exporters"],
            layer,
            process_info
        )
        """
        outputs = self.export(
            instance.data["productName"],
            project,
            instance.data["use_exporters"],
            layer,
            process_info,
        )

        representations = self.process_outputs_to_representations(
            outputs, instance)

        instance.data.setdefault(
            "representations", []).extend(representations)

        self.log.debug(instance.data["representations"])

    def process_outputs_to_representations(
            self, outputs: list[dict],
            instance: pyblish.api.Instance) -> list[dict]:
        """Process the output to representations.

        This will process output from the exporters to representations.

        Args:
            outputs (list[dict]): list of outputs.
            instance (pyblish.api.Instance): instance.

        Returns:
            list[dict]: list of representations.

        Raises:
            KnownPublishError: if the exporter produced multiple
                sequences and single files.

        """
        representations = []
        staging_dir = Path(self.staging_dir(instance))

        for output in outputs:
            # if there are multiple files in one representation
            # we need to check if it is sequence or not as current
            # integration does not support multiple files that are not
            # in sequences.
            repre_name = self._exporter_name_to_representation_name(
                output["name"])

            cols, rems = clique.assemble(output["files"])
            if rems and cols:
                # there are both sequences and single files
                if cols > 1:
                    # the extractor produced multiple sequences
                    # and single files. This is not supported now
                    # due to the complexity.
                    msg = ("The exporter produced multiple sequences "
                           "and single files. This is not supported.")
                    raise KnownPublishError(msg)
                output_files = cols[0]
                for reminder in rems:
                    self.add_to_resources(
                        Path(self.staging_dir(instance)) / reminder, instance)
                representations.append({
                    "name": repre_name,
                    "ext": output["ext"],
                    "files": output_files,
                    "stagingDir": output["stagingDir"],
                    "outputName": output["outputName"],
                })
            if rems and not cols:
                if len(rems) > 1:
                    # if there are only non-sequence files
                    for reminder in rems:
                        self.add_to_resources(
                            Path(self.staging_dir(instance)) / reminder, instance)  # noqa: E501
                    manifest_file = self._create_manifest_file(
                        staging_dir, rems, repre_name)
                    representations.append({
                        "name": repre_name,
                        "ext": output["ext"],
                        "files": manifest_file,
                        "stagingDir": output["stagingDir"],
                        "outputName": output["outputName"],
                    })
                else:
                    # if there is only one non-sequence file
                    representations.append({
                        "name": repre_name,
                        "ext": output["ext"],
                        "files": rems[0],
                        "stagingDir": output["stagingDir"],
                        "outputName": output["outputName"],
                    })
            if cols and not rems:
                # if there are only sequences
                if len(cols) > 1:
                    # the extractor produced multiple sequences
                    # and single files. This is not supported now
                    # due to the complexity.
                    msg = ("The exporter produced multiple sequences "
                           "and single files. This is not supported.")
                    raise KnownPublishError(msg)
                representations.append({
                    "name": repre_name,
                    "ext": output["ext"],
                    "files": list(cols[0]),
                    "stagingDir": output["stagingDir"],
                    "outputName": output["outputName"],
                })
        return representations

    @staticmethod
    def _create_manifest_file(
            staging_dir: Path, files: list[str], repre_name: str) -> str:
        """Create a manifest file.

        This will put all the files to a manifest file that
        will be used as a representation. This is because the
        current integration does not support multiple files
        that are not in sequences.

        Args:
            staging_dir (Path): staging directory.
            files (list[str]): list of files.
            repre_name (str): representation name.

        Returns:
            str: manifest file name.

        """
        file_name = f"{repre_name}.manifest"
        manifest_file = staging_dir / file_name
        with open(manifest_file, "w", encoding="utf-8") as file:
            file.writelines(files)
        return file_name

    def export(
            self,
            product_name: str,
            project: Project,
            exporters: list[ExporterInfo],
            layer: Layer,
            process_info: ExporterProcessInfo
        ) -> list[dict]:
        """Export the instance.

        This is using in-process export but since the export
        times are pretty fast, it's easier and probably
        faster than using the external export.

        Args:
            product_name (str): used for naming the resulting
                files.
            project (Project): Mocha project.
            exporters (list[ExporterInfo]): exporters to use.
            layer (Layer): layer to export.
            process_info (ExporterProcessInfo): process information.

        Returns:
            list[dict]: list of representations.

        Raises:
            KnownPublishError: if the export fails.

        """
        views = [view_info.name for view_info in project.views]
        views_to_export = list(
            {
                View(num)
                for num, view_info in enumerate(project.views)
                if view_info.name in views or view_info.abbr in views
            }
        )
        output: list[dict] = []
        for exporter_info in exporters:
            exporter_name = exporter_info.label
            if not exporter_name:
                msg = ("Cannot get exporter name "
                       f"from {exporter_info.label} exporter.")
                raise KnownPublishError(msg)

            """
            ext = self._get_extension(exporter_info)
            if not ext:
                msg = ("Cannot get extension "
                       f"from {exporter_info.label} exporter.")
                raise KnownPublishError(msg)
            """

            options = process_info.options

            exporter_short_hash = exporter_info.id[:8]

            version = get_mocha_version() or "2024"

            # exporters were rewritten in 2025. For older version
            # we need to parse the file extension from the exporter
            # label. We add it here so it is later on used from the
            # resulted file name.
            file_name = f"{product_name}_{exporter_short_hash}"
            if int(version.split(".")[0]) < MOCHA_2025:
                ext = ExportTrackingPoints._get_extension(exporter_info)
                if not ext:
                    msg = ("Cannot get extension "
                           f"from {exporter_info.label} exporter.")
                    raise KnownPublishError(msg)
                file_name += f".{ExportTrackingPoints._get_extension(exporter_info)}"  # noqa: E501

            tracking_file_path = (
                    process_info.staging_dir / file_name
            )

            result = exporter_info.exporter.do_export(
                project,
                layer,
                tracking_file_path.as_posix(),
                options.get("frame_time", 0.0),
                views_to_export[0],
                {
                    "Invert": options.get("invert", False),
                    "RemoveLensDistortion": options.get(
                        "remove_lens_distortion", False)
                }
            )
            self.log.debug(
                "Selected exporter: %s", exporter_name)
            self.log.debug(
                "Exporting to: %s", tracking_file_path)
            if not result:
                msg = f"Export failed for {exporter_name}."
                raise KnownPublishError(msg)

            output_files = []

            ext = None
            for k, v in result.items():
                Path(k).write_bytes(v)
                output_files.append(Path(k).name)
                if ext is None:
                    ext = Path(k).suffix[1:]

            output.append({
                "name": exporter_info.label,
                "ext": ext,
                "files": output_files,
                "stagingDir": process_info.staging_dir.as_posix(),
                "outputName": exporter_short_hash,
            })

        return output

    def add_to_resources(
            self, path: Path, instance: pyblish.api.Instance) -> None:
        """Add the path to the resources."""
        self.log.debug("Adding to resources: %s", path)

        publish_dir_path = Path(instance.data["publishDir"])
        instance.data["transfers"].append(
            [path.as_posix(), (publish_dir_path / path.name).as_posix()])

    def external_export_process(self,
        instance_name: str,
        exporters: list[ExporterInfo],
        layer: Layer,
        process_info: ExporterProcessInfo) -> list[dict]:
        """Process the instance using external export.

        This will prepare the arguments and run the external mocha exporter
        script to export the tracking data.

        Returns:
            list[dict]: list of representations.

        Raises:
            KnownPublishError: if the export fails.

        """
        invert: bool = process_info.options.get(
            "invert", False)
        remove_lens_distortion: bool = process_info.options.get(
            "remove_lens_distortion", False)

        args = [
            process_info.mocha_python_path.as_posix(),
            process_info.mocha_exporter_path.as_posix(),
            "--export-type=tracking",
            "--project={}".format(path_to_subprocess_arg(
                process_info.current_project_path.as_posix())),
        ]

        if invert:
            args += "--invert"

        if remove_lens_distortion:
            args += "--remove-lens-distortion"

        self.log.debug(
            "Exporting data using %s exporters",
            len(exporters))

        exporter_info: ExporterInfo
        representations: list[dict] = []
        for exporter_info in exporters:

            exporter_name = exporter_info.label
            if not exporter_name:
                msg = ("Cannot get exporter name "
                       f"from {exporter_info.label} exporter.")
                raise KnownPublishError(msg)

            ext = self._get_extension(exporter_info)
            if not ext:
                msg = ("Cannot get extension "
                       f"from {exporter_info.label} exporter.")
                raise KnownPublishError(msg)

            args += [
                f"--exporter-name={exporter_info.label}",
                "--file-path", path_to_subprocess_arg(
                    (process_info.staging_dir / f"{instance_name}.{ext}").as_posix()),  # noqa: E501
                layer.name,
                "-v4"
            ]

            self.log.info("Exporting: %s", list2cmdline(args))
            run_subprocess(list2cmdline(args), logger=self.log)

            filename = f"{instance_name}.{ext}"
            path = process_info.staging_dir / filename

            if not path.exists():
                msg = f"Exported file {path} does not exist."
                raise KnownPublishError(msg)

            representations.append({
                "name": self._exporter_name_to_representation_name(
                    exporter_info.label),
                "ext": ext,
                "files": path.name,
                "stagingDir": path.parent.as_posix(),
            })

        return representations

    @staticmethod
    def _get_extension(exporter_info: ExporterInfo) -> Optional[str]:
        """Get the extension of the exporter.

        This is used only if the exporter name contains the extension.
        From Mocha 2025 the extension is not part of the exporter name
        anymore.

        Returns:
            Optional[str]: extension of the exporter if detected.

        """
        match = re.search(EXTENSION_PATTERN, exporter_info.label)
        return match["ext"] if match else None

    @staticmethod
    def _exporter_name_to_representation_name(
            exporter_name: str) -> str:
        """Convert the exporter name to representation name.

        Args:
            exporter_name (str): exporter name.

        Returns:
            str: exporter representation name.

        """
        version = get_mocha_version() or "2024"
        try:
            mapping = EXPORTER_MAPPING["tracking"][version]
        except KeyError:
            mapping = EXPORTER_MAPPING["tracking"]["2024.5"]
        return mapping.get(
            exporter_name, exporter_name)

add_to_resources(path, instance)

Add the path to the resources.

Source code in client/ayon_mocha/plugins/publish/export_tracking_points.py
307
308
309
310
311
312
313
314
def add_to_resources(
        self, path: Path, instance: pyblish.api.Instance) -> None:
    """Add the path to the resources."""
    self.log.debug("Adding to resources: %s", path)

    publish_dir_path = Path(instance.data["publishDir"])
    instance.data["transfers"].append(
        [path.as_posix(), (publish_dir_path / path.name).as_posix()])

export(product_name, project, exporters, layer, process_info)

Export the instance.

This is using in-process export but since the export times are pretty fast, it's easier and probably faster than using the external export.

Parameters:

Name Type Description Default
product_name str

used for naming the resulting files.

required
project Project

Mocha project.

required
exporters list[ExporterInfo]

exporters to use.

required
layer Layer

layer to export.

required
process_info ExporterProcessInfo

process information.

required

Returns:

Type Description
list[dict]

list[dict]: list of representations.

Raises:

Type Description
KnownPublishError

if the export fails.

Source code in client/ayon_mocha/plugins/publish/export_tracking_points.py
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
def export(
        self,
        product_name: str,
        project: Project,
        exporters: list[ExporterInfo],
        layer: Layer,
        process_info: ExporterProcessInfo
    ) -> list[dict]:
    """Export the instance.

    This is using in-process export but since the export
    times are pretty fast, it's easier and probably
    faster than using the external export.

    Args:
        product_name (str): used for naming the resulting
            files.
        project (Project): Mocha project.
        exporters (list[ExporterInfo]): exporters to use.
        layer (Layer): layer to export.
        process_info (ExporterProcessInfo): process information.

    Returns:
        list[dict]: list of representations.

    Raises:
        KnownPublishError: if the export fails.

    """
    views = [view_info.name for view_info in project.views]
    views_to_export = list(
        {
            View(num)
            for num, view_info in enumerate(project.views)
            if view_info.name in views or view_info.abbr in views
        }
    )
    output: list[dict] = []
    for exporter_info in exporters:
        exporter_name = exporter_info.label
        if not exporter_name:
            msg = ("Cannot get exporter name "
                   f"from {exporter_info.label} exporter.")
            raise KnownPublishError(msg)

        """
        ext = self._get_extension(exporter_info)
        if not ext:
            msg = ("Cannot get extension "
                   f"from {exporter_info.label} exporter.")
            raise KnownPublishError(msg)
        """

        options = process_info.options

        exporter_short_hash = exporter_info.id[:8]

        version = get_mocha_version() or "2024"

        # exporters were rewritten in 2025. For older version
        # we need to parse the file extension from the exporter
        # label. We add it here so it is later on used from the
        # resulted file name.
        file_name = f"{product_name}_{exporter_short_hash}"
        if int(version.split(".")[0]) < MOCHA_2025:
            ext = ExportTrackingPoints._get_extension(exporter_info)
            if not ext:
                msg = ("Cannot get extension "
                       f"from {exporter_info.label} exporter.")
                raise KnownPublishError(msg)
            file_name += f".{ExportTrackingPoints._get_extension(exporter_info)}"  # noqa: E501

        tracking_file_path = (
                process_info.staging_dir / file_name
        )

        result = exporter_info.exporter.do_export(
            project,
            layer,
            tracking_file_path.as_posix(),
            options.get("frame_time", 0.0),
            views_to_export[0],
            {
                "Invert": options.get("invert", False),
                "RemoveLensDistortion": options.get(
                    "remove_lens_distortion", False)
            }
        )
        self.log.debug(
            "Selected exporter: %s", exporter_name)
        self.log.debug(
            "Exporting to: %s", tracking_file_path)
        if not result:
            msg = f"Export failed for {exporter_name}."
            raise KnownPublishError(msg)

        output_files = []

        ext = None
        for k, v in result.items():
            Path(k).write_bytes(v)
            output_files.append(Path(k).name)
            if ext is None:
                ext = Path(k).suffix[1:]

        output.append({
            "name": exporter_info.label,
            "ext": ext,
            "files": output_files,
            "stagingDir": process_info.staging_dir.as_posix(),
            "outputName": exporter_short_hash,
        })

    return output

external_export_process(instance_name, exporters, layer, process_info)

Process the instance using external export.

This will prepare the arguments and run the external mocha exporter script to export the tracking data.

Returns:

Type Description
list[dict]

list[dict]: list of representations.

Raises:

Type Description
KnownPublishError

if the export fails.

Source code in client/ayon_mocha/plugins/publish/export_tracking_points.py
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
def external_export_process(self,
    instance_name: str,
    exporters: list[ExporterInfo],
    layer: Layer,
    process_info: ExporterProcessInfo) -> list[dict]:
    """Process the instance using external export.

    This will prepare the arguments and run the external mocha exporter
    script to export the tracking data.

    Returns:
        list[dict]: list of representations.

    Raises:
        KnownPublishError: if the export fails.

    """
    invert: bool = process_info.options.get(
        "invert", False)
    remove_lens_distortion: bool = process_info.options.get(
        "remove_lens_distortion", False)

    args = [
        process_info.mocha_python_path.as_posix(),
        process_info.mocha_exporter_path.as_posix(),
        "--export-type=tracking",
        "--project={}".format(path_to_subprocess_arg(
            process_info.current_project_path.as_posix())),
    ]

    if invert:
        args += "--invert"

    if remove_lens_distortion:
        args += "--remove-lens-distortion"

    self.log.debug(
        "Exporting data using %s exporters",
        len(exporters))

    exporter_info: ExporterInfo
    representations: list[dict] = []
    for exporter_info in exporters:

        exporter_name = exporter_info.label
        if not exporter_name:
            msg = ("Cannot get exporter name "
                   f"from {exporter_info.label} exporter.")
            raise KnownPublishError(msg)

        ext = self._get_extension(exporter_info)
        if not ext:
            msg = ("Cannot get extension "
                   f"from {exporter_info.label} exporter.")
            raise KnownPublishError(msg)

        args += [
            f"--exporter-name={exporter_info.label}",
            "--file-path", path_to_subprocess_arg(
                (process_info.staging_dir / f"{instance_name}.{ext}").as_posix()),  # noqa: E501
            layer.name,
            "-v4"
        ]

        self.log.info("Exporting: %s", list2cmdline(args))
        run_subprocess(list2cmdline(args), logger=self.log)

        filename = f"{instance_name}.{ext}"
        path = process_info.staging_dir / filename

        if not path.exists():
            msg = f"Exported file {path} does not exist."
            raise KnownPublishError(msg)

        representations.append({
            "name": self._exporter_name_to_representation_name(
                exporter_info.label),
            "ext": ext,
            "files": path.name,
            "stagingDir": path.parent.as_posix(),
        })

    return representations

process(instance)

Process the instance.

Source code in client/ayon_mocha/plugins/publish/export_tracking_points.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def process(self, instance: pyblish.api.Instance) -> None:
    """Process the instance."""
    dir_path = Path(self.staging_dir(instance))
    project: Project = instance.context.data["project"]
    layer: Layer = instance.data["layer"]

    process_info = ExporterProcessInfo(
        mocha_python_path=instance.context.data["mocha_python_path"],
        mocha_exporter_path=instance.context.data["mocha_exporter_path"],
        current_project_path=instance.context.data["currentFile"],
        staging_dir=dir_path,
        options=instance.data["exporter_options"]
    )

    """
    representations = self.external_export_process(
        instance.name,
        instance.data["use_exporters"],
        layer,
        process_info
    )
    """
    outputs = self.export(
        instance.data["productName"],
        project,
        instance.data["use_exporters"],
        layer,
        process_info,
    )

    representations = self.process_outputs_to_representations(
        outputs, instance)

    instance.data.setdefault(
        "representations", []).extend(representations)

    self.log.debug(instance.data["representations"])

process_outputs_to_representations(outputs, instance)

Process the output to representations.

This will process output from the exporters to representations.

Parameters:

Name Type Description Default
outputs list[dict]

list of outputs.

required
instance Instance

instance.

required

Returns:

Type Description
list[dict]

list[dict]: list of representations.

Raises:

Type Description
KnownPublishError

if the exporter produced multiple sequences and single files.

Source code in client/ayon_mocha/plugins/publish/export_tracking_points.py
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
def process_outputs_to_representations(
        self, outputs: list[dict],
        instance: pyblish.api.Instance) -> list[dict]:
    """Process the output to representations.

    This will process output from the exporters to representations.

    Args:
        outputs (list[dict]): list of outputs.
        instance (pyblish.api.Instance): instance.

    Returns:
        list[dict]: list of representations.

    Raises:
        KnownPublishError: if the exporter produced multiple
            sequences and single files.

    """
    representations = []
    staging_dir = Path(self.staging_dir(instance))

    for output in outputs:
        # if there are multiple files in one representation
        # we need to check if it is sequence or not as current
        # integration does not support multiple files that are not
        # in sequences.
        repre_name = self._exporter_name_to_representation_name(
            output["name"])

        cols, rems = clique.assemble(output["files"])
        if rems and cols:
            # there are both sequences and single files
            if cols > 1:
                # the extractor produced multiple sequences
                # and single files. This is not supported now
                # due to the complexity.
                msg = ("The exporter produced multiple sequences "
                       "and single files. This is not supported.")
                raise KnownPublishError(msg)
            output_files = cols[0]
            for reminder in rems:
                self.add_to_resources(
                    Path(self.staging_dir(instance)) / reminder, instance)
            representations.append({
                "name": repre_name,
                "ext": output["ext"],
                "files": output_files,
                "stagingDir": output["stagingDir"],
                "outputName": output["outputName"],
            })
        if rems and not cols:
            if len(rems) > 1:
                # if there are only non-sequence files
                for reminder in rems:
                    self.add_to_resources(
                        Path(self.staging_dir(instance)) / reminder, instance)  # noqa: E501
                manifest_file = self._create_manifest_file(
                    staging_dir, rems, repre_name)
                representations.append({
                    "name": repre_name,
                    "ext": output["ext"],
                    "files": manifest_file,
                    "stagingDir": output["stagingDir"],
                    "outputName": output["outputName"],
                })
            else:
                # if there is only one non-sequence file
                representations.append({
                    "name": repre_name,
                    "ext": output["ext"],
                    "files": rems[0],
                    "stagingDir": output["stagingDir"],
                    "outputName": output["outputName"],
                })
        if cols and not rems:
            # if there are only sequences
            if len(cols) > 1:
                # the extractor produced multiple sequences
                # and single files. This is not supported now
                # due to the complexity.
                msg = ("The exporter produced multiple sequences "
                       "and single files. This is not supported.")
                raise KnownPublishError(msg)
            representations.append({
                "name": repre_name,
                "ext": output["ext"],
                "files": list(cols[0]),
                "stagingDir": output["stagingDir"],
                "outputName": output["outputName"],
            })
    return representations