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

Notify user if continent contouring is activated in the age gridding workflow #286

Open
michaelchin opened this issue Oct 11, 2024 · 7 comments
Assignees

Comments

@michaelchin
Copy link
Contributor

As it appears, continent contouring is activated silently by default as part of the age gridding workflow in GPlately.

However, this is problematic, because unsuspecting users would not understand that this is happening, and might also not understand the potential shortcomings of using continent contouring.

This needs to be made more transparent, such that users need to be forced to make a deliberate choice between either using continent contouring or supplying a COB masking file. In other words, a message needs to pop up and users need to at least be made aware that if they do not supply a cob masking file, continent contouring will be used, and the message should also point them to the documentation for continent contouring so that they understand what it is actually doing.

The relevant code is here.

gplately/gplately/oceans.py

Lines 613 to 621 in da56af8

if (
os.path.isfile(self.continent_mask_filepath.format(self._max_time))
and self.continent_mask_is_provided
):
# If a set of continent masks was passed, we can use max_time's continental
# mask to build the initial profile of seafloor age.
ocean_points = self._get_ocean_points_from_continent_mask()
else:
ocean_points = self._generate_ocean_points()

@michaelchin
Copy link
Contributor Author

If we just print a warning message, the message may be buried in other messages on screen and user may not notice it. Should we print the message and pause the program to wait for user's confirmation(something like "Are you sure/do you consent/would you like to proceed? y/N") ? 

@michaelchin
Copy link
Contributor Author

The following text is from DM.

Yes, you need to pause the program and force the user to make a choice, like:

If want to proceed with default age gridding using cob’s generated by “continent contouring” select “yes”

If you want to use an existing COB file, select “no” and provide a cob filename.

@michaelchin
Copy link
Contributor Author

Some comments from BM

Alternatively, an additional flag could be supplied (e.g. --continent-contouring) to enable continent contouring without the prompt. The second is my preferred option rather than have the workflow pause every time it’s run, waiting for user input.

For the python API it would make sense to have an additional argument in the SeafloorGrid class (e.g. continent_contouring=True) to specify that continent contouring should be run, if continent_contouring is False (default) and no COBs are supplied then the workflow would raise an error.

@michaelchin
Copy link
Contributor Author

Maybe we can have both, like "apt install -y something", if user provide the "-y" argument, apt will not ask, otherwise apt will ask user's confirmation.

@jcannon-gplates
Copy link
Contributor

I agree. Having a way to bypass the prompts is worthwhile (for advanced users). And the Python API raising an error if no COBs provided (in default case).

@Hojat-Shirmard
Copy link
Contributor

Added use_continent_contouring to the constructor. This parameter can be set to True to skip the user prompt.
If no continent_mask_filename is provided and use_continent_contouring is not set, prompt the user to confirm if they want to use continent contouring. If the user does not consent, raise a ValueError.

    use_continent_contouring: bool = False,  # New parameter to bypass prompt

    # Notify the user if continent contouring is activated
    if not continent_mask_filename:
        if use_continent_contouring:
            warnings.warn("Using continent contouring to generate COBs.")
        else:
            user_response = input(
                "No COB masking file provided. Would you like to proceed with continent contouring? (y/N): "
            ).strip().lower()
            if user_response != 'y':
                raise ValueError("User opted not to proceed without a COB masking file.")
        self.continent_mask_is_provided = False
    else:
        self.continent_mask_filepath = continent_mask_filename
        self.continent_mask_is_provided = True

    self._setup_output_paths(save_directory)

@michaelchin
Copy link
Contributor Author

@Hojat-Shirmard

Could you please create a branch, make code change on the branch and create a pull request from the branch? Thanks.

Screenshot 2024-12-03 at 3 02 43 pm

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

3 participants