Skip to content

Conversation

@HungKNguyen
Copy link
Collaborator

@HungKNguyen HungKNguyen commented Aug 14, 2025

Brought the Python library to full feature parity with the TypeScript client. Updated documentations and GitHub Workflow. Up the version number to 2.0.0 due to breaking features

@HungKNguyen HungKNguyen marked this pull request as ready for review August 15, 2025 16:45
@HungKNguyen HungKNguyen requested a review from nickwinder August 15, 2025 16:45
if self.is_executed:
raise ValidationError(
"This workflow has already been executed. Create a new workflow builder for additional operations."
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we really only execute the workflow once? It'd be nice to have workflows being more flexible and executed multipe times, for example in the original input PDF changes, you can execute the workflow again.
I believe this is how the TS version was designed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see how this is used now. :S I still feel we should be able to update a workflow even after it is run. As see them as blueprints, they are not the executors, but just guidelines on how to run. That means we should be able update those blueprints at a later date.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was also implemented in the TypeScript version.
https://github.com/PSPDFKit-labs/nutrient-dws-client-typescript/blob/626f7fe652867e16171b65648c66f6444b61b978/src/builders/workflow.ts#L362

Regarding the design itself, I think the reason it was designed this way is because the documentation (our documentation) is unclear whether the workflow clean up after running only clean up the file parts or also the instructions

self.assets.clear()
self.asset_index = 0
self.current_step = 0
self.is_executed = True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar thoughts about "blueprints" and "executors"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the blueprint-executor design is not compatible with the staged builder design since the stage builder doesn't make it clear which part in each stage is static (blueprint) and dynamic (executors)


def workflow(
api_key: str | Callable[[], str],
base_url: str | None = None,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could default this to https://api.nutrient.io/ for simplicity.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping it as None is better, This pattern also appears here

base_url: str | None = None,

And if we change it we will add another location where the default URL is hardcoded, versus rightnow we only hard code it in one location

base_url: str = client_options.get("baseUrl") or "https://api.nutrient.io"

5. Open a Pull Request
## Python Version Support

This library supports Python 3.10 and higher. The async-first design requires modern Python features for optimal performance and type safety.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it really need 3.10? I know the default on macos is 3.9, it'd be nice to support standard distributions out there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using match statement and typing syntax (|) that is introduced in 3.10

Match syntax here:

3.9 is also near end-of-life so I think it's okay if we drop it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sure. Let's no overthink this.

@HungKNguyen HungKNguyen requested a review from nickwinder August 20, 2025 15:38
Copy link

@nickwinder nickwinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all good with your explanations. LGTM

@HungKNguyen HungKNguyen merged commit 862119c into main Aug 22, 2025
17 checks passed
@HungKNguyen HungKNguyen deleted the austin/match-ts-parity branch August 22, 2025 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants