Metadata-Version: 2.4
Name: athena-pyworker
Version: 2.0.1
Summary: Athena Python worker runtime (app container for athectl: pyworker).
Home-page: http://www.ingris.com
Author: Kiro Lee
Author-email: kiroly@ingris.com
License: Proprietary
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: pynng>=0.8.0
Requires-Dist: PyYAML>=6.0.1
Requires-Dist: watchdog>=6.0.0
Requires-Dist: aiomysql>=0.2.0
Requires-Dist: asyncpg>=0.30.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# athena-pyworker

- distribution: `athena-pyworker 2.0.0`
- import package: `athena_pyworker`
- Python: 3.9 이상
- service token: `pyworker`

Athena Broker에서 작업을 받아 Python 앱을 실행하는 Pipeline worker다.

## 의존성

- NNG 1.11 native library
- pynng
- PyYAML
- watchdog
- async database drivers
- `athena_messaging` SDK

## 설치

```bash
python3 -m pip install .
```

운영 배치는 repository에서 직접 기동하지 않고 다음 installer를 사용한다.

```bash
bash "$SOURCE_HOME/infra/scripts/install-py-runtime"
$ATHENA_HOME/bin/athectl start pyworker
```

## 설정

`$ATHENA_HOME/config/athena-agent.yaml`의 `broker`, `worker`, `log` section을
C/Java worker와 공유한다. broker host와 port가 없으면 fail-fast다.

## 앱 규약

앱은 `app_main()`을 구현하고 `examples/registry.py`와 같은 registry에서
action app key에 연결한다.

```python
from athena_pyworker.status import AppStatus

class ExampleApp:
    def __init__(self, *, logger, channel, context):
        self.logger = logger
        self.channel = channel
        self.context = context

    async def app_main(self):
        await self.channel.publish_progress(
            self.context, "done", message="completed"
        )
        return AppStatus.OK
```

실행 start/success/failure lifecycle event는 worker executor가 소유한다. 앱은
lifecycle을 직접 중복 발행하지 않고 진행률만 보고한다.

## 빌드·검증

```bash
python3 -m compileall athena_pyworker
python3 setup.py bdist_wheel
```

실 broker 잡 왕복은 NNG와 broker가 있는 대상 환경에서 검증한다.
