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

Add Plate Tectonic Tools command line as gplately subcommands #129

Closed
michaelchin opened this issue Nov 8, 2023 · 6 comments · Fixed by #148
Closed

Add Plate Tectonic Tools command line as gplately subcommands #129

michaelchin opened this issue Nov 8, 2023 · 6 comments · Fixed by #148
Assignees
Labels

Comments

@michaelchin
Copy link
Contributor

michaelchin commented Nov 8, 2023

fix_crossovers and remove_plate_rotations have been done in da681cf

@michaelchin michaelchin self-assigned this Nov 10, 2023
@michaelchin
Copy link
Contributor Author

Hi @jcannon-gplates ,

I will gradually add Plate Tectonic Tools commands into gplately as subcommands. Two of them have been done - fix-crossovers and remove-plate-rotations. See the code below. Let me know if you have any concerns or anything I should pay attention to. Thanks.

# add fix crossovers sub-command
fix_crossovers_cmd = subparser.add_parser(
"fix_crossovers",
help="fix crossovers",
add_help=True,
)
fix_crossovers.add_arguments(fix_crossovers_cmd)
# add remove plate rotations sub-command
remove_plate_rotations_cmd = subparser.add_parser(
"remove_rotations",
help="remove plate rotations",
add_help=True,
)
remove_plate_rotations.add_arguments(remove_plate_rotations_cmd)

@jcannon-gplates
Copy link
Contributor

That looks good!

I can confirm that python -m gplately fix_crossovers -d -c 0.01 rotations.rot worked as intended.

So it looks like the following PlateTectonicTools commands remain (ie, the only ones with command-line options):

Thanks!

@michaelchin
Copy link
Contributor Author

That looks good!

I can confirm that python -m gplately fix_crossovers -d -c 0.01 rotations.rot worked as intended.

So it looks like the following PlateTectonicTools commands remain (ie, the only ones with command-line options):

Thanks!

Thanks @jcannon-gplates

In my Conda environment, the python -m part is not needed. Simply gplately fix_crossovers -d -c 0.01 rotations.rot works.

@jcannon-gplates
Copy link
Contributor

In my Conda environment, the python -m part is not needed. Simply gplately fix_crossovers -d -c 0.01 rotations.rot works.

Interesting, thanks, that works for me too.

An interesting side observation on Windows: before I upgraded my conda environment to gplately 1.1, typing gplately --version in my conda env would find the gplately 1.1 installed via pip into a non-conda Python (since there was a gplately.exe in Python\Scripts which is in PATH) whereas python -m gplately --version would look up the conda gplately only (which, before upgrading to 1.1, would understandably fail with No module named gplately.__main__; 'gplately' is a package and cannot be directly executed - but would work when upgraded to 1.1). But once upgrading to 1.1 this becomes a non-issue since a conda environment always puts itself first in the PATH.

@michaelchin
Copy link
Contributor Author

would understandably fail with No module named gplately.__main__; 'gplately' is a package and cannot be directly executed - but would work when upgraded to 1.1).

I added gplately.main; after gplately 1.0.

It is here

gplately/pyproject.toml

Lines 53 to 54 in 181c058

[project.scripts]
gplately = "gplately.__main__:main"

@jcannon-gplates
Copy link
Contributor

Thanks, yes I saw that. Just noting that some subtle differences between using and not using python -m can occasionally happen (especially on Windows) - which is why I tend to prefer python -m (even though it's more verbose).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants