-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from adybbroe/add-s3stalker-daemon
Add an s3stalker daemon
- Loading branch information
Showing
15 changed files
with
796 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,86 @@ | ||
name: Run tests | ||
name: CI | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
continue-on-error: ${{ matrix.experimental }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10"] | ||
os: ["ubuntu-latest"] | ||
python-version: ["3.9", "3.10", "3.11"] | ||
experimental: [false] | ||
include: | ||
- python-version: "3.11" | ||
os: "ubuntu-latest" | ||
experimental: true | ||
|
||
env: | ||
PYTHON_VERSION: ${{ matrix.python-version }} | ||
OS: ${{ matrix.os }} | ||
UNSTABLE: ${{ matrix.experimental }} | ||
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | ||
|
||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
|
||
- name: Setup Conda Environment | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
mamba-version: "*" | ||
channels: conda-forge,defaults | ||
environment-file: continuous_integration/environment.yaml | ||
activate-environment: test-environment | ||
|
||
- name: Install unstable dependencies | ||
if: matrix.experimental == true | ||
shell: bash -l {0} | ||
run: | | ||
pip install -U pytest pytest-cov trollsift netifaces watchdog posttroll pyyaml pyinotify pyresample \ | ||
pytroll-schedule s3fs fsspec python-dateutil paramiko | ||
python -m pip install \ | ||
--no-deps --pre --upgrade \ | ||
numpy; \ | ||
python -m pip install \ | ||
--no-deps --upgrade \ | ||
git+https://github.com/pytroll/posttroll \ | ||
git+https://github.com/pytroll/pytroll-schedule \ | ||
git+https://github.com/pytroll/trollsift; | ||
- name: Install pytroll-collectors | ||
run: | | ||
pip install --no-deps -e . | ||
- name: Run tests | ||
- name: Run unit tests | ||
shell: bash -l {0} | ||
run: | | ||
pytest --cov=pytroll_collectors pytroll_collectors/tests --cov-report=xml | ||
- name: Upload coverage to Codecov | ||
- name: Upload unittest coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
flags: unittests | ||
file: ./coverage.xml | ||
env_vars: PYTHON_VERSION | ||
env_vars: OS,PYTHON_VERSION,UNSTABLE | ||
fail_ci_if_error: false | ||
|
||
- name: Coveralls Parallel | ||
uses: AndreMiras/coveralls-python-action@develop | ||
with: | ||
flag-name: run-${{ matrix.test_number }} | ||
parallel: true | ||
if: runner.os == 'Linux' | ||
|
||
coveralls: | ||
needs: [test] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Coveralls Finished | ||
uses: AndreMiras/coveralls-python-action@develop | ||
with: | ||
parallel-finished: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright (c) 2022 Pytroll developers | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
"""S3stalker daemon/runner. | ||
This is a daemon supposed to stay up and running "forever". It will regularly | ||
fetch fresh filenames from an S3 object store and publish the urls of those new | ||
filenames. It is a daemon version of the s3stalker.py script which needs to be | ||
run as a cronjob. | ||
""" | ||
|
||
import argparse | ||
import logging | ||
import logging.config | ||
import sys | ||
|
||
from pytroll_collectors.s3stalker import get_configs_from_command_line | ||
from pytroll_collectors.s3stalker_daemon_runner import S3StalkerRunner | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def arg_parse(): | ||
"""Handle input arguments.""" | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("bucket", help="The bucket to retrieve from.") | ||
parser.add_argument("config", help="Config file to be used") | ||
parser.add_argument("-l", "--log", | ||
help="Log configuration file", | ||
default=None) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
"""Stalk an s3 bucket.""" | ||
bucket, config, log_config = get_configs_from_command_line() | ||
|
||
if log_config: | ||
logging.config.dictConfig(log_config) | ||
|
||
logger.info("Try start the s3-stalker runner:") | ||
try: | ||
s3runner = S3StalkerRunner(bucket, config) | ||
s3runner.start() | ||
s3runner.join() | ||
except KeyboardInterrupt: | ||
logger.debug("Interrupting") | ||
except Exception as err: | ||
logger.error('The S3 Stalker Runner crashed: %s', str(err)) | ||
sys.exit(1) | ||
finally: | ||
s3runner.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: test-environment | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- distributed | ||
- toolz | ||
- sphinx | ||
- pyyaml | ||
- pyproj | ||
- coveralls | ||
- coverage | ||
- codecov | ||
- behave | ||
- mock | ||
- numpy | ||
- pyresample | ||
- pyorbital | ||
- pycrs | ||
- cartopy | ||
- geopy | ||
- freezegun | ||
- paramiko | ||
- responses | ||
- netifaces | ||
- watchdog | ||
- s3fs | ||
- pyinotify | ||
- requests | ||
- openssl | ||
- pytz | ||
- python-dateutil | ||
- pytest | ||
- pytest-cov | ||
- pip | ||
- pip: | ||
- trollsift | ||
- posttroll | ||
- pytroll-schedule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: 1 | ||
disable_existing_loggers: false | ||
formatters: | ||
pytroll: | ||
format: '[%(asctime)s %(levelname)-8s %(name)s] %(message)s' | ||
handlers: | ||
console: | ||
class: logging.StreamHandler | ||
level: DEBUG | ||
formatter: pytroll | ||
stream: ext://sys.stdout | ||
loggers: | ||
posttroll: | ||
level: INFO | ||
root: | ||
level: DEBUG | ||
handlers: [console] |
Oops, something went wrong.