civisanalytics / civis-python

Civis API Python Client
BSD 3-Clause "New" or "Revised" License
34 stars 26 forks source link

ENH Add job_id and run_id property attributes to CivisFuture #290

Closed jacksonllee closed 5 years ago

jacksonllee commented 5 years ago

From time to time, it is necessary to pull out the job ID and run ID from a CivisFuture object (e.g., for debugging). Based on internal user experience from both co-workers and myself, it wasn't immediately clear how the IDs can be retrieved, until one realizes that (as of civis v1.9.4) CivisFuture subclasses PollableResult, which in turn subclasses CivisAsyncResultBase that has the poller_args attribute which is a tuple of (job_id, run_id). It would be nice to expose the IDs at CivisFuture and do so without the language of "polling" or similar.

In terms of implementation, it looks like ContainerFuture, which subclasses CivisFuture, already has the property attributes job_id and run_id. This PR moves the relevant code from ContainerFuture to CivisFuture; class inheritance preserves the job_id and run_id behavior at ContainerFuture. (The only other class that inherits from CivisFuture is SubscribableResult, which is just CivisFuture and has been marked to be deprecated.)

jacksonllee commented 5 years ago

Could you mention these in an "Attributes" section of the docstring?

Done!

jacksonllee commented 5 years ago

What do you think of changing the example to get_runs?

Sounds good -- done at bf7be00