Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/parallelbuilder/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client/
109 changes: 109 additions & 0 deletions python/parallelbuilder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Auto-generated version file
**/_version.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# IDE settings
.vscode/
.idea/
10 changes: 10 additions & 0 deletions python/parallelbuilder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.10
WORKDIR /app
RUN python -m venv .venv && .venv/bin/pip install --no-cache-dir -U pip setuptools
COPY pyproject.toml ./
COPY src/parabuild /app/src/parabuild
RUN . ./.venv/bin/activate && pip install --no-cache-dir .
RUN groupadd --gid 5000 armonikuser && useradd --home-dir /home/armonikuser --create-home --uid 5000 --gid 5000 --shell /bin/sh --skel /dev/null armonikuser && mkdir /cache && chown armonikuser: /cache
USER armonikuser
ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1
ENTRYPOINT ["python", "src/parabuild/worker/worker.py"]
48 changes: 48 additions & 0 deletions python/parallelbuilder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# A Python Parallel Builder on ArmoniK

## Description

This project contains a worker and a client to interact with ArmoniK's Control Plane. The worker processes tasks sent by the Agent, transforming input data and sending results back to it.

In this case, the aim is to build a list made up of segments created asynchronously. Given the length of the list and the length of the segments, the client creates an amount of tasks. Each of these will create its own segment and when this is done, the role of the output task is to aggregate all the segments and output the final list.

For example, if you choose a list and segments with respective lengths of 10 and 3, the pipeline will look like this:

```mermaid

graph LR
I((Init)) ---> S1("[1, 1, 1]") & S2("[2, 2, 2]") & S3("[3, 3, 3]") & S4("  [4]  ") ---> F((Output)) -.-> out["[1, 1, 1, 2, 2, 2, 3, 3, 3, 4]"]

classDef fixedWidth width:90px;
class S1,S2,S3 fixedWidth;
style out fill-opacity:0,stroke-opacity:0

```

## Steps

1. Build the Docker image for the worker:
```bash
docker build -t parabuilder -f Dockerfile .
```

2. Deploy ArmoniK locally by following the instructions at [ArmoniK Documentation](https://aneoconsulting.github.io/ArmoniK/). Ensure you create a new partition named "parabuildpython" with the worker's image.

3. Create, activate a virtual environment and update useful dependencies:
```bash
python -m venv .venv
. .venv/bin/activate
pip install -U pip setuptools
```

4. Install the dependencies and build the package:
```bash
pip install .
```

## Usage

Run the Client with the name of the partition and the endpoint obtained after deployement. You have to specify the length of the final liste (-l) and the size of your segments (-s).

```bash
parabuild --partition parabuildpython --endpoint <ip>:<port> -s 100 -t 15
42 changes: 42 additions & 0 deletions python/parallelbuilder/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
requires = ["setuptools", "setuptools-scm","wheel"]
build-backend = "setuptools.build_meta"


[project]
name = "ParallelBuilder"
version = "0.0.1"
description = "Sample python where you can build a list with sub-lists built in parallel"
readme = {file = "README.txt", content-type = "text/markdown"}
requires-python = ">= 3.7"
keywords = ["ArmoniK", "Python", "Aneo"]
dependencies = [
"armonik>=3.25.0"
]

[project.scripts]
parabuild = "parabuild.client.client:main"

[tool.setuptools]
include-package-data = true
dynamic = {version = {attr = "undecided.__version__"}}

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

[project.optional-dependencies]
tests = [
'coverage',
'pytest',
'pytest-cov',
'pytest-benchmark[histogram]',
'requests',
]
dev = [
'mypy',
]

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]
Empty file.
Loading
Loading