Skip to content

Session.virtualfile_in: Deprecate parameter 'required_data' to 'required' (will be removed in v0.20.0) #3931

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

Merged
merged 6 commits into from
May 5, 2025

Conversation

seisman
Copy link
Member

@seisman seisman commented Apr 28, 2025

Address #3836.

@seisman seisman force-pushed the virtualfile_in/required_data branch from 12e35e2 to 0c68337 Compare April 28, 2025 10:39
@seisman seisman added deprecation Deprecating a feature needs review This PR has higher priority and needs review. labels Apr 28, 2025
@seisman seisman added this to the 0.16.0 milestone Apr 28, 2025
Comment on lines 1861 to +1862
if check_kind:
valid_kinds = ("file", "arg") if required_data is False else ("file",)
valid_kinds = ("file", "arg") if required is False else ("file",)
Copy link
Member

@weiji14 weiji14 Apr 28, 2025

Choose a reason for hiding this comment

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

I feel that required by itself isn't a very descriptive parmeter name. This required_data parameter was added in #2493 to better handle optional virtual files (via the 'arg' kind). Would a name like optional_vfile (default to True) or something along those lines work? Then the check would be:

            valid_kinds = ("file", "arg") if optional_vfile is False else ("file",)

Or we could also just keep the required_data name as is? Thoughts?

Copy link
Member Author

@seisman seisman May 4, 2025

Choose a reason for hiding this comment

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

Would a name like optional_vfile (default to True) or something along those lines work?

You meant optional_vfile default to False?

The data_kind takes two parameters data and required. Here, required_data is renamed to required to match the parameter name in that function. If we rename it to optional_vfile, then we should use data_kind(data, required=not optional_vfile).

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, I meant optional_vfile=False by default, but that's probably not a great name either. On second thought, let's go with the required parameter name then. Using just required in data_kind makes sense because we're only passing in an argument to data, and I guess we do validate whether data/x/y are not None in virtualfile_in so there shouldn't be any ambiguity, but need to update the docstring a bit.

check_kind="vector",
data=textfiles or data,
required_data=required_data,
check_kind="vector", data=textfiles or data, required=required_data
Copy link
Member

Choose a reason for hiding this comment

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

At L193 and L194 above. The required_data variable wasn't changed to required?

Copy link
Member Author

@seisman seisman May 5, 2025

Choose a reason for hiding this comment

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

Yes, required_data at L193-L194 is a local variable, and required is not a good name for it. Perhaps rename it to data_is_required?

Done in 4ea2ecb.

@seisman seisman removed the needs review This PR has higher priority and needs review. label May 1, 2025
@seisman seisman marked this pull request as draft May 1, 2025 04:25
Comment on lines 1861 to +1862
if check_kind:
valid_kinds = ("file", "arg") if required_data is False else ("file",)
valid_kinds = ("file", "arg") if required is False else ("file",)
Copy link
Member

Choose a reason for hiding this comment

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

Ah yes, I meant optional_vfile=False by default, but that's probably not a great name either. On second thought, let's go with the required parameter name then. Using just required in data_kind makes sense because we're only passing in an argument to data, and I guess we do validate whether data/x/y are not None in virtualfile_in so there shouldn't be any ambiguity, but need to update the docstring a bit.

@seisman seisman added the needs review This PR has higher priority and needs review. label May 5, 2025
@seisman seisman marked this pull request as ready for review May 5, 2025 02:25
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Just one other suggestion. Tests failing appear unrelated, was there an update to the earth_relief grids again?

Comment on lines 1788 to 1790
mincols
Number of minimum required columns. Default is 2 (i.e. require x and y
columns).
Copy link
Member

Choose a reason for hiding this comment

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

Also move this docstring to below required.

@seisman seisman merged commit 33fadc3 into main May 5, 2025
12 of 24 checks passed
@seisman seisman deleted the virtualfile_in/required_data branch May 5, 2025 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation Deprecating a feature needs review This PR has higher priority and needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants