Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] Misleading and wrong type hinting for boolean parameters in jobs.list and jobs.list_runs #555

Closed
dreilstad opened this issue Feb 22, 2024 · 1 comment

Comments

@dreilstad
Copy link

Description
The expected type for the parameters expand_tasks, completed_only, and active_only in the functions list() and list_runs() in the JobsAPI class is boolean. This is misleading and wrong in terms of what the Databricks API expects.

When supplying a True boolean value for any of these parameters, they are not applied correctly and does not return the expected values.

The reason for this is because the Databricks API expects a lowercase string: "true" or "false"
Either the conversion from boolean to lowercase string has to be implemented in the functions (list() and list_runs()) or change the type hinting of these parameters to be correct.

I do not know if this is an issue for other API endpoints.

Reproduction
The following code shows an example with the expand_tasks parameter.
The only difference between the two examples is value supplied to the parameter True and "true".

Code where list_runs does NOT return tasks:

host ="..."
token = "..."

w = WorkspaceClient(host=host, token=token)

for job in w.jobs.list():
    for run in w.jobs.list_runs(job_id=job.job_id, expand_tasks=True):
        assert "tasks" in run.as_dict(), "Did not find 'tasks' in returned job run dict"

Code where list_runs does return tasks:

host ="..."
token = "..."

w = WorkspaceClient(host=host, token=token)

for job in w.jobs.list():
    for run in w.jobs.list_runs(job_id=job.job_id, expand_tasks="true"):
        assert "tasks" in run.as_dict(), "Did not find 'tasks' in returned job run dict"

Expected behavior
I expect no missing values returned from functions when supplied with the correct parameters and that the parameters are actually applied.

Is it a regression?
I have not tested multiple versions. Only the latest.

Other Information

  • OS: macOS
@dreilstad
Copy link
Author

I realized after some investigation that my issue was the same as Issue #142 and that a fix had been implemented. I mistakenly assumed that I had the latest version of the SDK installed. Updating the version to the latest version (0.20.0) fixed the issue.

@dreilstad dreilstad closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
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

No branches or pull requests

1 participant