# Optimizing PDF Transformation Workflow: How to Process Only the Latest Uploaded Document in a Media Set?

**URL:** <https://community.palantir.com/t/optimizing-pdf-transformation-workflow-how-to-process-only-the-latest-uploaded-document-in-a-media-set/864>\
**Category:** Ask the Community\
**Tags:** media-sets, ontology-management, pipeline-builder, code-repositories\
**Created:** [July 29, 2024, 2:56pm UTC](https://community.palantir.com/t/optimizing-pdf-transformation-workflow-how-to-process-only-the-latest-uploaded-document-in-a-media-set/864 "2024-07-29T14:56:02Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Joel](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/joel/32/3579_2.png) [@Joel](https://community.palantir.com/u/Joel)\
**Post date:** [March 3, 2025, 4:42am UTC](https://community.palantir.com/t/optimizing-pdf-transformation-workflow-how-to-process-only-the-latest-uploaded-document-in-a-media-set/864/4 "2025-03-03T04:42:30Z")

</div>

Hi @helenq,

Following up on this, is there a way to incrementally build a media set? I just gave it a try and received this error, but I’m not sure if there’s another method I should try:

 ![image](https://canada1.discourse-cdn.com/palantir/original/2X/0/0d1afa4959d03a1276a3690d7fae50b0963d86e2.png)

Full code:

```auto
from transforms.api import transform, Input, incremental # configure, ComputeBackend
from transforms.mediasets import MediaSetOutput

# @configure(profile=["EXECUTOR_MEMORY_MEDIUM", "EXECUTOR_MEMORY_OFFHEAP_FRACTION_HIGH"], backend=ComputeBackend.VELOX)
@incremental()
@transform(
    pdfs_dataset=Input("ri.foundry.main.dataset.acffb422-8df5-43a4-b26e-541ba8965715"),
    pdfs_media_set=MediaSetOutput(
        "ri.mio.main.media-set.6c60b58f-1186-4e54-bbdd-8fe57c6b569f"
    ),
)
def upload_to_media_set(pdfs_dataset, pdfs_media_set):
    pdfs_media_set.put_dataset_files(
        pdfs_dataset, ignore_items_not_matching_schema=False
    )

```

Thanks,  
Joel

---

_[View the full topic](https://community.palantir.com/t/optimizing-pdf-transformation-workflow-how-to-process-only-the-latest-uploaded-document-in-a-media-set/864)._
