googleapis / googleapis/python-aiplatform

BatchPredictionJob.completion_stats should be a method and not a property

Open
#5,067 0 comments 0 reactions 0 assignees View on GitHub
api: vertex-ai
Dominant language
Python
Stars
905
Forks
465
Avg merge
1d 13h
Merged PRs (30d)
44

Description

The below bit of code I suspect incorrectly has the `@property` decorator. This is caching, so when you've created a BatchPredictionJob instance and called submit or create. the first time you call `.completion_stats` is the value that this instance will have forever. For obvious reasons this is extremely irritating and means you either have to keep creating fresh instances of BatchPredictionJob to get updated completion numbers. Or you have to copy the private code and call yourself, which isn't super great from a user maintenance PoV. It would be extremely useful to have the total number of input instances somewhere cached based on if its BQ or a GCS folder, in a similar way that this class provides an iterator to outputs. Then you can get a %age progress through the job rather than predictions output, again one has to write all this themselves on the outside of this class which is just kind of horrible aesthetics as a user.

https://github.com/googleapis/python-aiplatform/blob/96d2ecbb527cc52c71bbeddc2394eaf9c4f91e06/google/cloud/aiplatform/jobs.py#L385-L390

I'd happily raise an MR around these changes if they're seen as a good change that might get accepted. The change from being a property will be breaking, but I suspect *anyone* using this feature as is either has broken code that incorrectly states progress, or they are doing something horrible they would like to remove to work around it being a property.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.