Commit 7f313037 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

first working version

parent 0278018f
Pipeline #64120 failed with stages
in 3 seconds
# Hidden files
.*
# Byte / compiled / optimized
*.py[cod]
__pycache__/
*.so
/doc/_generated
# Distribution / packaging
/build/
/dist/
*.egg-info/
.eggs/
# Unittest / coverage
*.py,cover
.coverage.*
htmlcov/
.cache/
.pytest_cache/
results/*
image: python:3.8
stages:
- style
- test
.base:
only:
refs:
- main
- merge_requests
lint:
stage: style
extends: .base
script:
- pip install black flake8
- black --check .
- flake8
test:
stage: test
extends: .base
script:
- python -m pip install git+https://github.com/woutdenolf/dahu.git@server_entry_point
- pip install .[test]
- pytest --pyargs dahu
- pytest -v
# dahu-demo
Demo of job triggering with [Dahu](https://github.com/kif/dahu)
## Installation
```bash
conda install -c tango-controls pytango
python -m pip install . # dahu
```
## With database
Register tango device with database
```bash
TANGO_HOST=localhost:10000 dahu-register
```
Start tango server which has the device
```bash
DAHU_PLUGINS=./dahu_demo/plugins TANGO_HOST=localhost:10000 dahu-server dahu
```
Use the tango device
```python
from PyTango import DeviceProxy
p = DeviceProxy("tango://localhost:10000/id00/dahu/1")
```
## Without database
Start tango device without database
```bash
DAHU_PLUGINS=./dahu_demo/plugins dahu-server dahu -ORBendPoint giop:tcp::10000 -nodb -dlist id00/dahu/1 -v4
```
Use the tango device
```python
from PyTango import DeviceProxy
p = DeviceProxy("tango://localhost:10000/id00/dahu/1#dbase=no")
```
Demo of job triggering with [Dahu](https://github.com/kif/dahu) ([docs](http://www.silx.org/doc/dahu/dev/))
## Demo scripts
* demo/create.sh: create an environment (conda)
* demo/install.sh: install dependencies
* demo/start_tangodb.sh: start tango database (docker)
* demo/start_dahu.sh: start Dahu server
* demo/run.py: run a job
## Dependencies
Packages
* pytango
* dahu
* ewoks (for the plugin)
Infrastructure
* Tango database (docker)
......@@ -6,5 +6,8 @@ from ewoks import execute_graph
@register
class ExecuteGraph(Plugin):
def process(self):
execute_graph(**self.input)
kwargs = {
k: v for k, v in self.input.items() if k not in ("job_id", "plugin_name")
}
execute_graph(**kwargs)
# self.output["result"] = ...
#!/bin/bash
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${SCRIPT_ROOT}/utils.sh
function create_conda_env {
$(conda_root)/bin/conda config --env --add channels conda-forge
$(conda_root)/bin/conda create --prefix $(conda_env)
}
function main {
create_conda_env
}
main
#!/bin/bash
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${SCRIPT_ROOT}/utils.sh
function main {
source $(conda_root)/bin/activate $(conda_env)
# install what we can with conda instead of pip
conda install --file $SCRIPT_ROOT/requirements-conda.txt
# install dahu
local dahu_source=$HOME/dev/dahu
find $dahu_source| grep -E "(__pycache__|\.pyc|\.pyo|\.egg-info$)" | xargs rm -rf
python -m pip install -e $dahu_source
# install the demo project
python -m pip install -e $SCRIPT_ROOT/..
}
main
python=3.8
pytango
numpy
import json
from time import sleep
from tango import DeviceProxy
from ewokscore.tests.examples.graphs import get_graph
plugin = "workflow.executegraph"
workflow, _ = get_graph("acyclic1")
varinfo = {"root_uri": "results"}
kwargs = {"graph": workflow, "binding": None, "varinfo": varinfo}
proxy = DeviceProxy("tango://localhost:10000/id00/dahu/1")
pid = proxy.startJob([plugin, json.dumps(kwargs)])
while proxy.getJobState(pid) == "starting":
sleep(0.01)
proxy.waitJob(pid)
print("Output: %s" % proxy.getJobOutput(pid))
#!/bin/bash
export TANGO_HOST=localhost:10000
export DAHU_PLUGINS=$(python -c "from dahu_demo import plugins;print(plugins.__path__[0])")
dahu-register --instance dahu
dahu-server dahu -v3
#!/bin/bash
export DAHU_PLUGINS=$(python -c "from dahu_demo import plugins;print(plugins.__path__[0])")
dahu-server dahu -ORBendPoint giop:tcp::10000 -nodb -dlist id00/dahu/1 -v3
#!/bin/bash
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function print_endpoints {
sleep 10
echo ""
echo "Tango database: http://localhost:10000"
}
function main {
print_endpoints &
sudo docker-compose -f ${SCRIPT_ROOT}/tango/docker-compose.yml up
}
main
version: '2'
services:
tango-db:
image: tangocs/mysql:9.2.2
ports:
- "9999:3306"
environment:
- MYSQL_ROOT_PASSWORD=root
tango-cs:
image: tangocs/tango-cs:9
ports:
- "10000:10000"
environment:
- TANGO_HOST=localhost:10000
- MYSQL_HOST=tango-db:3306
- MYSQL_USER=tango
- MYSQL_PASSWORD=tango
- MYSQL_DATABASE=tango
depends_on:
- tango-db
\ No newline at end of file
function conda_root {
echo $HOME/miniconda3/ubuntu_20_04
}
function conda_env {
echo $HOME/virtualenvs/dahu/ubuntu_20_04
}
......@@ -16,7 +16,7 @@ install_requires =
test =
pytest
ewoks[test]
dahu[pytest]
dahu[tango]
dev =
%(test)s
black
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment