Skip to content

Commit

Permalink
Fixed package
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrasseur-aneo committed Mar 21, 2023
1 parent 44a423d commit 9b051fe
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[packages/python/**]
[{packages/python/** , examples/python/**}]
indent_size = 4
max_line_length = off
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,4 @@ packages/web/LICENSE


**/launchSettings.json
**/.idea
4 changes: 2 additions & 2 deletions examples/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM python:3.7-slim AS builder
WORKDIR /app
RUN python -m venv .venv && .venv/bin/pip install --no-cache-dir -U pip setuptools
COPY *.whl ./
RUN ( .venv/bin/pip install --no-cache-dir *.whl || .venv/bin/pip install --no-cache-dir armonik ) && find /app/.venv \( -type d -a -name test -o -name tests \) -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf '{}' \+
COPY worker-requirements.txt *.whl ./
RUN .venv/bin/pip install --no-cache-dir $( ( find . -type f -name "*.whl" | grep . ) || echo armonik ) -r worker-requirements.txt && find /app/.venv \( -type d -a -name test -o -name tests \) -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) -exec rm -rf '{}' \+

FROM python:3.7-slim
WORKDIR /app
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions examples/python/worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from armonik.worker import ArmoniKWorker, TaskHandler
from armonik.common import Output


# Actual computation
def processor(task_handler: TaskHandler) -> Output:
return Output()


def main():

2 changes: 1 addition & 1 deletion packages/python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkg/
armonik/protogen
src/armonik/protogen
build/
*.egg-info
**/_version.py
Empty file.
13 changes: 7 additions & 6 deletions packages/python/proto2python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ fi;
source ../common/protofiles.sh

export PATH=$HOME/.local/bin:$PATH
export ARMONIK_PYTHON_SRC="armonik"
export ARMONIK_PYTHON_SRC="src"
export PACKAGE_PATH="pkg"
export ARMONIK_WORKER=$ARMONIK_PYTHON_SRC"/protogen/worker"
export ARMONIK_CLIENT=$ARMONIK_PYTHON_SRC"/protogen/client"
export ARMONIK_COMMON=$ARMONIK_PYTHON_SRC"/protogen/common"
export GENERATED_PATH=$ARMONIK_PYTHON_SRC"/armonik/protogen"
export ARMONIK_WORKER=$GENERATED_PATH"/worker"
export ARMONIK_CLIENT=$GENERATED_PATH"/client"
export ARMONIK_COMMON=$GENERATED_PATH"/common"

mkdir -p $ARMONIK_WORKER $ARMONIK_CLIENT $ARMONIK_COMMON $PACKAGE_PATH

Expand All @@ -30,7 +31,7 @@ mkdir -p $ARMONIK_WORKER $ARMONIK_CLIENT $ARMONIK_COMMON $PACKAGE_PATH
python -m pip install --upgrade pip
python -m venv $PYTHON_VENV
source $PYTHON_VENV/bin/activate
python -m pip install build grpcio grpcio-tools
python -m pip install build grpcio grpcio-tools click

unset proto_files
for proto in ${armonik_worker_files[@]}; do
Expand Down Expand Up @@ -61,6 +62,6 @@ touch $ARMONIK_CLIENT/__init__.py
touch $ARMONIK_COMMON/__init__.py

# Need to fix the relative import
python fix_imports.py $ARMONIK_PYTHON_SRC/protogen
python fix_imports.py $GENERATED_PATH

python -m build -s -w -o $PACKAGE_PATH
4 changes: 2 additions & 2 deletions packages/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ dependencies = [
"Bug Tracker" = "https://github.com/aneoconsulting/ArmoniK/issues"

[tool.setuptools_scm]
write_to = "packages/python/armonik/_version.py"
write_to = "packages/python/src/_version.py"
root="../.."
local_scheme = "no-local-version"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where= ["armonik"]
where= ["src"]

[tool.setuptools.package-data]
"*" = ["*.pyi"]
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/python/src/armonik/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .submitter import ArmoniKSubmitter
from .tasks import ArmoniKTasks
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/python/src/armonik/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .helpers import datetime_to_timestamp, timestamp_to_datetime, duration_to_timedelta, timedelta_to_duration
from .objects import Task, TaskDefinition, TaskOptions, Output
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,10 @@
from client.tasks import ArmoniKTasks
from protogen.common.tasks_common_pb2 import TaskRaw
from .helpers import duration_to_timedelta, timedelta_to_duration, timestamp_to_datetime
from ..protogen.common.objects_pb2 import Empty, Configuration as ProtoConfig, Output as WorkerOutput
from ..protogen.common.objects_pb2 import Empty, Output as WorkerOutput
from ..protogen.common.task_status_pb2 import *


@dataclass()
class Configuration:
data_chunk_max_size: int
_message: ProtoConfig

def __init__(self, config: ProtoConfig):
self._message = config
self.data_chunk_max_size = self._message.data_chunk_max_size


@dataclass()
class TaskOptions:
max_duration: timedelta
Expand Down
2 changes: 2 additions & 0 deletions packages/python/src/armonik/worker/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .worker import ArmoniKWorker
from .taskhandler import TaskHandler
File renamed without changes.

0 comments on commit 9b051fe

Please sign in to comment.