Skip to content

Commit 1aa5d81

Browse files
authored
Merge pull request #29 from mraspaud/update_python_versions
Migrate ci to newer python
2 parents 9bd270a + 70f66ca commit 1aa5d81

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: true
1212
matrix:
13-
python-version: ["3.9", "3.10", "3.11"]
13+
python-version: ["3.11", "3.12", "3.13"]
1414
steps:
1515
- name: Checkout source
1616
uses: actions/checkout@v2

pytroll_runner/__init__.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from functools import partial
3232
from glob import glob
3333
from multiprocessing.pool import ThreadPool
34+
from pathlib import Path
3435
from subprocess import PIPE, Popen
3536

3637
import yaml
@@ -41,7 +42,7 @@
4142
logger = logging.getLogger("pytroll-runner")
4243

4344

44-
def main(args=None):
45+
def main(args: list[str] | None = None):
4546
"""Main script."""
4647
parsed_args = parse_args(args=args)
4748
setup_logging(parsed_args.log_config)
@@ -50,7 +51,7 @@ def main(args=None):
5051
return run_and_publish(parsed_args.config_file, parsed_args.message_file)
5152

5253

53-
def setup_logging(config_file):
54+
def setup_logging(config_file: str | None):
5455
"""Setup the logging from a log config yaml file."""
5556
if config_file is not None:
5657
with open(config_file) as fd:
@@ -59,12 +60,13 @@ def setup_logging(config_file):
5960
return
6061

6162

62-
def parse_args(args=None):
63+
def parse_args(args: list[str] | None = None):
6364
"""Parse command line arguments."""
6465
parser = argparse.ArgumentParser("Pytroll Runner",
6566
description="Automate third party software in a pytroll environment")
6667
parser.add_argument("config_file",
67-
help="The configuration file to run on.")
68+
help="The configuration file to run on.",
69+
type=Path)
6870
parser.add_argument("-l", "--log_config",
6971
help="The log configuration yaml file.",
7072
default=None)
@@ -74,7 +76,7 @@ def parse_args(args=None):
7476
return parser.parse_args(args)
7577

7678

77-
def run_and_publish(config_file, message_file=None):
79+
def run_and_publish(config_file: Path, message_file: str | None = None):
7880
"""Run the command and publish the expected files."""
7981
command_to_call, subscriber_config, publisher_config = read_config(config_file)
8082
with suppress(KeyError):
@@ -109,20 +111,20 @@ def check_existing_files(publisher_config):
109111
return set(glob(filepattern))
110112

111113

112-
def read_config(config_file):
114+
def read_config(config_file: Path):
113115
"""Read the configuration file."""
114116
with open(config_file) as fd:
115-
config = yaml.safe_load(fd.read())
116-
return validate_config(config)
117+
config: dict[str, object] = yaml.safe_load(fd.read())
118+
return curate_config(config)
117119

118120

119-
def validate_config(config):
121+
def curate_config(config):
120122
"""Validate the configuration file."""
121123
publisher_config = config["publisher_config"]
122124
if "output_files_log_regex" not in publisher_config and "expected_files" not in publisher_config:
123125
raise KeyError("Missing ways to identify output files. "
124-
"Either provide 'expected_files' or "
125-
"'output_files_log_regex' in the config file.")
126+
"Either provide 'expected_files' or "
127+
"'output_files_log_regex' in the config file.")
126128

127129
subscriber_config = config["subscriber_config"]
128130
logger.debug("Subscriber config settings: ")

0 commit comments

Comments
 (0)