Skip to content

Conversation

@dgellow
Copy link
Collaborator

@dgellow dgellow commented Apr 17, 2025

Part of #11

@dgellow dgellow requested a review from zeke April 17, 2025 14:56
@dgellow
Copy link
Collaborator Author

dgellow commented Apr 17, 2025

@zeke It's the same version that has been discussed in the staging repo. Do you want to already merge it as-is?

@dgellow dgellow marked this pull request as ready for review April 17, 2025 17:16
@dtmeadows
Copy link
Collaborator

@zeke / @dgellow tested this live and this was the result!

image

@zeke
Copy link
Member

zeke commented Apr 18, 2025

what was the prompt!!? haha

@mpatankar
Copy link
Collaborator

Added context from staging repo: https://github.com/stainless-sdks/replicate-client-python/pull/5

Copy link
Member

@zeke zeke left a comment

Choose a reason for hiding this comment

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

Thanks for opening this, @dgellow

A few thoughts:

  • Can you add a description to the PR body with a summary of the changes? What's covered? What's missing?
  • There seem to be a lot of changes to the auto-generated code here. Are there any mitigations we can make here to minize that? Moving code to lib, adding code comments around human code, moving human code to a separate block in the file, etc.?
  • Is it possible to add some tests?

@dgellow
Copy link
Collaborator Author

dgellow commented Apr 23, 2025

There seem to be a lot of changes to the auto-generated code here. Are there any mitigations we can make here to minize that? Moving code to lib, adding code comments around human code, moving human code to a separate block in the file, etc.?

I think that we already extracted to ./lib everything that could be. For example the new error class ModelError cannot be extracted to ./lib without resulting in an import cycle (./lib imports _exceptions.py, which itself imports ./lib) due to the inheritance.

But I can add comments around the custom code if you would find this helpful

Edit: Paraphrasing what I said in Slack:

I'm really not too sure about adding region comments to delimitate human code vs generated code. The main issue I see is that there is no guarantee they will stay correct over time, it is possible that a git operation ends up with generated code between those comments. So that would be something that you have to maintain yourself.

What I would instead recommend is to document branch comparison in CONTRIBUTING.md, such as https://github.com/replicate/replicate-typescript-stainless/compare/generated..next.
By comparing generated and next you always get the current state of human-code (aka custom code).

@dgellow
Copy link
Collaborator Author

dgellow commented Apr 23, 2025

Still a bit of work to do on tests — I'm using https://github.com/replicate/replicate-python/blob/main/tests/test_run.py for the list of test cases.
Then I will add a PR description to clarify the scope of this PR.

@zeke
Copy link
Member

zeke commented Apr 24, 2025

Awesome! Excited to see the progress.

@zeke
Copy link
Member

zeke commented May 5, 2025

I've created an issue to track this work:

I know this PR has been tossed around a bit as folks move on and off of projects, or are on leave.

@mpatankar who is the current owner of this?

@mpatankar
Copy link
Collaborator

@RobertCraigie is the assignee and the one who will see this through! Assigned him to the issue you created

@dtmeadows dtmeadows requested a review from RobertCraigie May 6, 2025 16:37
pyproject.toml Outdated
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
"asyncio>=3.4.3",
Copy link
Collaborator

Choose a reason for hiding this comment

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

this isn't quite right, asyncio is stdlib

Copy link
Collaborator

Choose a reason for hiding this comment

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

fixed!

@zeke
Copy link
Member

zeke commented May 6, 2025

Thanks for the update, @dtmeadows. Great to see this getting close!

@dtmeadows
Copy link
Collaborator

@zeke this is ready for your review! The only remaining pending item is the file upload functionality that we discussed here: https://stainless-workspace.slack.com/archives/C08H2L2E0KT/p1745613017872449

Would your preference be for us to wait and have that be code-generated (once it's added to your OpenAPI spec) or to just manually create the endpoint for now?

@zeke
Copy link
Member

zeke commented May 7, 2025

Amazing! Great timing.

I actually just shipped a change to our OpenAPI schema to document the Files API, so we can generate them. That should be live in production within the next few minutes.

Screenshot 2025-05-07 at 10 52 05


from replicate import AsyncReplicate

client = AsyncReplicate()
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename client to replicate here? Will that work?

Copy link
Collaborator

Choose a reason for hiding this comment

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

done!

(we can't change the from replicate import AsyncReplicate unfortunately though here, since the module client only returns the sync client)

Copy link
Member

@zeke zeke left a comment

Choose a reason for hiding this comment

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

This is looking great. Left a few small suggestions but nothing major.

Happy to ship this without File upload support. It would probably be easier to review that in a separate PR anyway.

@dtmeadows dtmeadows linked an issue May 7, 2025 that may be closed by this pull request
5 tasks
@dtmeadows
Copy link
Collaborator

This is looking great. Left a few small suggestions but nothing major.

Happy to ship this without File upload support. It would probably be easier to review that in a separate PR anyway.

Sounds good! I've added file upload support on this branch: dmeadows/use-files-in-run. I'll open a PR for that once this goes in.

@dtmeadows dtmeadows requested review from RobertCraigie and zeke May 8, 2025 17:16
@dtmeadows
Copy link
Collaborator

@zeke I think this is good to merge in now! You okay blessing it with your approval?

Copy link
Member

@zeke zeke left a comment

Choose a reason for hiding this comment

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

Whoop whoop! :shipit:

@zeke zeke merged commit 686d4d7 into next May 8, 2025
2 checks passed
@dgellow dgellow deleted the sam/run-helper branch July 31, 2025 14:34
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.

Implement replicate.run() method for Python client

6 participants