Skip to content

Commit 6db322f

Browse files
Standardize Python exec commands to python -m (#340)
Replaced `python3 -m` usage with `python -m` across the codebase and documentation for consistency. This ensures alignment with modern Python practices.
1 parent 5f6b58f commit 6db322f

19 files changed

+77
-77
lines changed

.github/workflows/pytest-with-coverage.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ jobs:
3737
- name: Install editable-mode dependency packages
3838
shell: bash -l {0}
3939
run: |
40-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/43ravens/NEMO_Nowcast.git#egg=NEMO_Nowcast
41-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/UBC-MOAD/moad_tools#egg=moad_tools
42-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/UBC-MOAD/Reshapr#egg=Reshapr
43-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/SalishSeaCast/NEMO-Cmd.git#egg=NEMO-Cmd
44-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/SalishSeaCast/SalishSeaCmd.git#egg=SalishSeaCmd
45-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable "git+https://github.com/SalishSeaCast/tools#egg=SalishSeaTools&subdirectory=SalishSeaTools"
46-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/SalishSeaCast/FVCOM-Cmd.git#egg=FVCOM-Cmd
40+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/43ravens/NEMO_Nowcast.git#egg=NEMO_Nowcast
41+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/UBC-MOAD/moad_tools#egg=moad_tools
42+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/UBC-MOAD/Reshapr#egg=Reshapr
43+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/SalishSeaCast/NEMO-Cmd.git#egg=NEMO-Cmd
44+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/SalishSeaCast/SalishSeaCmd.git#egg=SalishSeaCmd
45+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable "git+https://github.com/SalishSeaCast/tools#egg=SalishSeaTools&subdirectory=SalishSeaTools"
46+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://github.com/SalishSeaCast/FVCOM-Cmd.git#egg=FVCOM-Cmd
4747
# OPPTools is a private GitLab repo, so an access token is required
48-
python3 -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://oauth2:${{ secrets.GITLAB_ACCESS_TOKEN }}@gitlab.com/mdunphy/OPPTools.git@6c784a4dc44dd9030aafe9a8519e5ae0b6cc3183#egg=OPPTools
49-
python3 -m pip install --editable $GITHUB_WORKSPACE
48+
python -m pip install --src $GITHUB_WORKSPACE/../vcs_pkgs/ --editable git+https://oauth2:${{ secrets.GITLAB_ACCESS_TOKEN }}@gitlab.com/mdunphy/OPPTools.git@6c784a4dc44dd9030aafe9a8519e5ae0b6cc3183#egg=OPPTools
49+
python -m pip install --editable $GITHUB_WORKSPACE
5050
5151
- name: pytest package with coverage
5252
shell: bash -l {0}

config/nowcast.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
checklist file: $(NOWCAST.ENV.NOWCAST_LOGS)/nowcast_checklist.yaml
55

66
# Python interpreter in environment with all dependencies installed
7-
python: $(NOWCAST.ENV.NOWCAST_ENV)/bin/python3
7+
python: $(NOWCAST.ENV.NOWCAST_ENV)/bin/python
88

99
# Filesystem group name to use for ownership of newly created files
1010
file group: sallen
@@ -627,7 +627,7 @@ run:
627627
# Python interpreter on compute host in an environment with all
628628
# dependencies installed. Used to, for example, launch run_NEMO and
629629
# watch_NEMO workers.
630-
python: /nemoShare/MEOPAR/nowcast-sys/nowcast-env/bin/python3
630+
python: /nemoShare/MEOPAR/nowcast-sys/nowcast-env/bin/python
631631
# Location on the compute host of the nowcast system config file
632632
config file: /nemoShare/MEOPAR/nowcast-sys/SalishSeaNowcast/config/nowcast.yaml
633633
# Directory on compute host where files (e.g. namelist.time) and symlinks

docs/deployment/optimum.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ Load the ``Miniconda/3`` module and create a Conda environment:
217217
$ conda create -n salishseacast -c conda-forge python=3 pip arrow \
218218
attrs cliff f90nml gitpython pyyaml
219219
$ source activate salishseacast
220-
(salishseacast)$ python3 -m pip install python-hglib
220+
(salishseacast)$ python -m pip install python-hglib
221221
222222
Install the SalishSeaCast NEMO-Cmd and SalishSeaCmd packages from their repo clones:
223223

224224
.. code-block:: bash
225225
226226
(salishseacast)$ cd $PROJECT/SalishSeaCast/hindcast-sys/
227-
(salishseacast)$ python3 -m pip install --editable NEMO-Cmd/
228-
(salishseacast)$ python3 -m pip install --editable SalishSeaCmd/
227+
(salishseacast)$ python -m pip install --editable NEMO-Cmd/
228+
(salishseacast)$ python -m pip install --editable SalishSeaCmd/
229229
230230
231231
Populate Run Preparation Directory

docs/deployment/skookum.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ For the `salishsea-site web app`_ that is mounted at https://salishsea.eos.ubc.c
109109
--prefix /SalishSeaCast/salishsea-site-env \
110110
-f salishsea-site/envs/environment-prod.yaml
111111
$ mamba activate /SalishSeaCast/salishsea-site-env
112-
(/SalishSeaCast/salishsea-site-env) $ python3 -m pip install --editable salishsea-site/
112+
(/SalishSeaCast/salishsea-site-env) $ python -m pip install --editable salishsea-site/
113113
114114
115115
Environment Variables

docs/figures/fig_dev_env.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ you can create and activate a figures development environment with these command
7070
$ cd SalishSeaNowcast
7171
$ conda env create -f envs/environment-fig-dev.yaml
7272
$ conda activate nowcast-fig-dev
73-
(nowcast-fig-dev)$ python3 -m pip install --editable ../NEMO_Nowcast
74-
(nowcast-fig-dev)$ python3 -m pip install --editable ../moad_tools
75-
(nowcast-fig-dev)$ python3 -m pip install --editable ../Reshapr
76-
(nowcast-fig-dev)$ python3 -m pip install --editable ../tools/SalishSeaTools
77-
(nowcast-fig-dev)$ python3 -m pip install --editable ../NEMO-Cmd
78-
(nowcast-fig-dev)$ python3 -m pip install --editable ../SalishSeaCmd
79-
(nowcast-fig-dev)$ python3 -m pip install --editable ../salishsea-site/
80-
(nowcast-fig-dev)$ python3 -m pip install --editable .
73+
(nowcast-fig-dev)$ python -m pip install --editable ../NEMO_Nowcast
74+
(nowcast-fig-dev)$ python -m pip install --editable ../moad_tools
75+
(nowcast-fig-dev)$ python -m pip install --editable ../Reshapr
76+
(nowcast-fig-dev)$ python -m pip install --editable ../tools/SalishSeaTools
77+
(nowcast-fig-dev)$ python -m pip install --editable ../NEMO-Cmd
78+
(nowcast-fig-dev)$ python -m pip install --editable ../SalishSeaCmd
79+
(nowcast-fig-dev)$ python -m pip install --editable ../salishsea-site/
80+
(nowcast-fig-dev)$ python -m pip install --editable .
8181
8282
The ``--editable`` option in the :command:`pip install` command above installs the packages from the cloned repos via symlinks so that the installed packages will be automatically updated as the repos evolve.
8383

docs/pkg_development.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,18 @@ the commands below install the packages into your ``salishsea-nowcast`` developm
163163
$ cd SalishSeaNowcast
164164
$ conda env create -f envs/environment-dev.yaml
165165
$ conda activate salishsea-nowcast
166-
(salishsea-nowcast)$ python3 -m pip install --editable ../NEMO_Nowcast
167-
(salishsea-nowcast)$ python3 -m pip install --editable ../moad_tools
168-
(salishsea-nowcast)$ python3 -m pip install --editable ../Reshapr
169-
(salishsea-nowcast)$ python3 -m pip install --editable ../tools/SalishSeaTools
166+
(salishsea-nowcast)$ python -m pip install --editable ../NEMO_Nowcast
167+
(salishsea-nowcast)$ python -m pip install --editable ../moad_tools
168+
(salishsea-nowcast)$ python -m pip install --editable ../Reshapr
169+
(salishsea-nowcast)$ python -m pip install --editable ../tools/SalishSeaTools
170170
(salishsea-nowcast)$ cd ../OPPTools
171171
(salishsea-nowcast)$ git switch SalishSeaCast-prod
172172
(salishsea-nowcast)$ cd ../SalishSeaNowcast
173-
(salishsea-nowcast)$ python3 -m pip install --editable OPPTools
174-
(salishsea-nowcast)$ python3 -m pip install --editable ../NEMO-Cmd
175-
(salishsea-nowcast)$ python3 -m pip install --editable ../SalishSeaCmd
176-
(salishsea-nowcast)$ python3 -m pip install --editable ../FVCOM-Cmd
177-
(salishsea-nowcast)$ python3 -m pip install --editable .
173+
(salishsea-nowcast)$ python -m pip install --editable OPPTools
174+
(salishsea-nowcast)$ python -m pip install --editable ../NEMO-Cmd
175+
(salishsea-nowcast)$ python -m pip install --editable ../SalishSeaCmd
176+
(salishsea-nowcast)$ python -m pip install --editable ../FVCOM-Cmd
177+
(salishsea-nowcast)$ python -m pip install --editable .
178178
179179
The ``--editable`` option in the :command:`pip install` command above installs the packages from the cloned repos via symlinks so that the installed packages will be automatically updated as the repos evolve.
180180

docs/worker_failures.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ then run the worker as follows:
8787

8888
.. code-block:: bash
8989
90-
(/SalishSeaCast/nowcast-env)skookum$ python3 -m nowcast.workers.download_weather $NOWCAST_YAML 12 2.5km --debug
90+
(/SalishSeaCast/nowcast-env)skookum$ python -m nowcast.workers.download_weather $NOWCAST_YAML 12 2.5km --debug
9191
9292
The command above downloads the 12 forecast.
9393
The ``--debug`` flag causes the logging output of the worker to be displayed

envs/environment-dev.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
#
77
# $ conda env create -f SalishSeaNowcast/envs/environment-dev.yaml
88
# $ conda activate salishsea-nowcast
9-
# $ python3 -m pip install --editable NEMO_Nowcast/
10-
# $ python3 -m pip install --editable moad_tools/
11-
# $ python3 -m pip install --editable tools/SalishSeaTools/
12-
# $ python3 -m pip install --editable Reshapr/
13-
# $ python3 -m pip install --editable OPPTools/
14-
# $ python3 -m pip install --editable NEMO-Cmd/
15-
# $ python3 -m pip install --editable SalishSeaCmd/
16-
# $ python3 -m pip install --editable FVCOM-Cmd/
17-
# $ python3 -m pip install --editable SalishSeaNowcast/
9+
# $ python -m pip install --editable NEMO_Nowcast/
10+
# $ python -m pip install --editable moad_tools/
11+
# $ python -m pip install --editable tools/SalishSeaTools/
12+
# $ python -m pip install --editable Reshapr/
13+
# $ python -m pip install --editable OPPTools/
14+
# $ python -m pip install --editable NEMO-Cmd/
15+
# $ python -m pip install --editable SalishSeaCmd/
16+
# $ python -m pip install --editable FVCOM-Cmd/
17+
# $ python -m pip install --editable SalishSeaNowcast/
1818

1919
name: salishsea-nowcast
2020

envs/environment-fig-dev.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
#
66
# $ conda env create -f SalishSeaNowcast/envs/environment-fig-dev.yaml
77
# $ conda activate nowcast-fig-dev
8-
# $ python3 -m pip install --editable NEMO_Nowcast/
9-
# $ python3 -m pip install --editable moad_tools/
10-
# $ python3 -m pip install --editable Reshapr/
11-
# $ python3 -m pip install --editable tools/SalishSeaTools/
12-
# $ python3 -m pip install --editable NEMO-Cmd/
13-
# $ python3 -m pip install --editable SalishSeaCmd/
14-
# $ python3 -m pip install --editable SalishSeaNowcast/
15-
# $ python3 -m pip install --editable salishsea-site/
8+
# $ python -m pip install --editable NEMO_Nowcast/
9+
# $ python -m pip install --editable moad_tools/
10+
# $ python -m pip install --editable Reshapr/
11+
# $ python -m pip install --editable tools/SalishSeaTools/
12+
# $ python -m pip install --editable NEMO-Cmd/
13+
# $ python -m pip install --editable SalishSeaCmd/
14+
# $ python -m pip install --editable SalishSeaNowcast/
15+
# $ python -m pip install --editable salishsea-site/
1616

1717
name: nowcast-fig-dev
1818

envs/environment-prod.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
#
77
# $ conda env create -f SalishSeaNowcast/envs/environment-prod.yaml
88
# $ conda activate nowcast-env
9-
# $ python3 -m pip install --editable NEMO_Nowcast/
10-
# $ python3 -m pip install --editable moad_tools/
11-
# $ python3 -m pip install --editable tools/SalishSeaTools/
12-
# $ python3 -m pip install --editable Reshapr/
13-
# $ python3 -m pip install --editable OPPTools/
14-
# $ python3 -m pip install --editable NEMO-Cmd/
15-
# $ python3 -m pip install --editable SalishSeaCmd/
16-
# $ python3 -m pip install --editable FVCOM-Cmd/
17-
# $ python3 -m pip install --editable SalishSeaNowcast/
9+
# $ python -m pip install --editable NEMO_Nowcast/
10+
# $ python -m pip install --editable moad_tools/
11+
# $ python -m pip install --editable tools/SalishSeaTools/
12+
# $ python -m pip install --editable Reshapr/
13+
# $ python -m pip install --editable OPPTools/
14+
# $ python -m pip install --editable NEMO-Cmd/
15+
# $ python -m pip install --editable SalishSeaCmd/
16+
# $ python -m pip install --editable FVCOM-Cmd/
17+
# $ python -m pip install --editable SalishSeaNowcast/
1818

1919
name: nowcast-env
2020

envs/requirements-sarracenia.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# to create an isolated production environment.
66
#
77
# Create/update this file with:
8-
# (sarracenia-env)$ python3 -m pip list --format=freeze >> envs/requirements-sarracenia.txt
8+
# (sarracenia-env)$ python -m pip list --format=freeze >> envs/requirements-sarracenia.txt
99

1010
amqp==5.1.0
1111
appdirs==1.4.4

notebooks/figures/fvcom/research/make_readme.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
or change the description of a notebook in its first Markdown cell,
2020
please generate a updated `README.md` file with:
2121
22-
python3 -m make_readme
22+
python -m make_readme
2323
2424
and commit and push the updated `README.md` to GitHub.
2525
"""

notebooks/make_readme.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
or change the description of a notebook in its first Markdown cell,
2020
please generate a updated `README.md` file with:
2121
22-
python3 -m make_readme
22+
python -m make_readme
2323
2424
and commit and push the updated `README.md` to GitHub.
2525
"""

nowcast/daily_river_flows.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def _calc_runoff_dataset(obs_date, runoff_array, config):
530530
"rivers_watersheds_proportions": "salishsea_tools.river_202108",
531531
"history": (
532532
f"[{arrow.now('local').format('ddd YYYY-MM-DD HH:mm:ss ZZ')}] "
533-
f"python3 -m nowcast.workers.make_runoff_file $NOWCAST_YAML "
533+
f"python -m nowcast.workers.make_runoff_file $NOWCAST_YAML "
534534
f"--run-date {obs_date.format('YYYY-MM-DD')}"
535535
),
536536
},

nowcast/workers/make_v202111_runoff_file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def _calc_runoff_dataset(obs_date, runoff_array, config):
613613
],
614614
"history": (
615615
f"[{arrow.now('local').format('ddd YYYY-MM-DD HH:mm:ss ZZ')}] "
616-
f"python3 -m nowcast.workers.make_v202111_runoff_file $NOWCAST_YAML "
616+
f"python -m nowcast.workers.make_v202111_runoff_file $NOWCAST_YAML "
617617
f"--run-date {obs_date_yyyymmdd}"
618618
),
619619
},

pyproject.toml

+10-10
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ dependencies = [
9292
"utm",
9393
"watchdog",
9494
"xarray == 2025.1.1",
95-
# 'NEMO_Nowcast', # use python3 -m pip install --editable NEMO_Nowcast/
96-
# 'moad_tools', # use python3 -m pip install --editable moad_tools
97-
# 'Reshapr', # use python3 -m pip install --editable Reshapr
98-
# 'SalishSeaTools', # use python3 -m pip install --editable tools/SalishSeaTools/
99-
# 'Reshapr', # use python3 -m pip install --editable Reshapr/
100-
# 'OPPTools', # use python3 -m pip install --editable OPPTools/
101-
# 'NEMO-Cmd', # use python3 -m pip install --editable NEMO-Cmd/
102-
# 'SalishSeaCmd', # use python3 -m pip install --editable SalishSeaCmd/
103-
# 'FVCOM-Cmd', # use python3 -m pip install --editable FVCOM-Cmd/
104-
# 'SalishSeaNowcast', # use python3 -m pip install -e SalishSeaNowcast/
95+
# 'NEMO_Nowcast', # use python -m pip install --editable NEMO_Nowcast/
96+
# 'moad_tools', # use python -m pip install --editable moad_tools
97+
# 'Reshapr', # use python -m pip install --editable Reshapr
98+
# 'SalishSeaTools', # use python -m pip install --editable tools/SalishSeaTools/
99+
# 'Reshapr', # use python -m pip install --editable Reshapr/
100+
# 'OPPTools', # use python -m pip install --editable OPPTools/
101+
# 'NEMO-Cmd', # use python -m pip install --editable NEMO-Cmd/
102+
# 'SalishSeaCmd', # use python -m pip install --editable SalishSeaCmd/
103+
# 'FVCOM-Cmd', # use python -m pip install --editable FVCOM-Cmd/
104+
# 'SalishSeaNowcast', # use python -m pip install -e SalishSeaNowcast/
105105
]
106106

107107
[project.urls]

tests/test_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_checklist_file(self, prod_config, tmpdir):
3434

3535
def test_python(self, prod_config, tmpdir):
3636
# Config.load() transforms NOWCAST.ENV part of envvars
37-
assert prod_config["python"] == f"{tmpdir}/nowcast-env/bin/python3"
37+
assert prod_config["python"] == f"{tmpdir}/nowcast-env/bin/python"
3838

3939

4040
class TestLoggingPublisher:

tests/test_daily_river_flows.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ def mock_now(tz):
14961496
)
14971497
assert runoff_ds.attrs["history"] == (
14981498
f"[Thu {obs_date.format('YYYY-MM-DD')} 14:51:43 -07:00] "
1499-
f"python3 -m nowcast.workers.make_runoff_file $NOWCAST_YAML "
1499+
f"python -m nowcast.workers.make_runoff_file $NOWCAST_YAML "
15001500
f"--run-date {obs_date.format('YYYY-MM-DD')}"
15011501
)
15021502

tests/workers/test_make_v202111_runoff_file.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ def mock_now(tz):
19201920
)
19211921
assert runoff_ds.attrs["history"] == (
19221922
f"[Thu {obs_date.format('YYYY-MM-DD')} 14:51:43 -07:00] "
1923-
f"python3 -m nowcast.workers.make_v202111_runoff_file $NOWCAST_YAML "
1923+
f"python -m nowcast.workers.make_v202111_runoff_file $NOWCAST_YAML "
19241924
f"--run-date {obs_date.format('YYYY-MM-DD')}"
19251925
)
19261926

0 commit comments

Comments
 (0)