...
 
Commits (2071)
......@@ -3,6 +3,7 @@
*.pyc
*.pyo
*~
*.py,cover
*.bck
build
*.swp
......@@ -24,3 +25,8 @@ htmlcov/
.pytest_cache/
.vscode/*
*.so
bliss/release.py
prof
.mypy_cache/
graph.dot
graph.png
image: docker-registry.esrf.fr/bcu/ci-conda
before_script:
# set pip cache to the Docker volume
- echo ${CI_PROJECT_DIR}
- export PIP_CACHE_DIR="/opt/cache/pip"
- /opt/conda/bin/conda init && source /root/.bashrc
- conda config --append channels conda-forge
- conda config --add channels defaults
- conda config --add channels http://bcu-ci.esrf.fr/stable
- conda config --add channels tango-controls
stages:
- style
- tests
- build_user_doc
- build_doc
- build
- package_tests
- deploy
style:
check_style:
stage: style
image: continuumio/miniconda3:latest
before_script:
- source activate tango3.6
- pip install black==18.6b4
- pip install -r requirements-dev.txt
script:
# run black
- LC_ALL=C.UTF-8 black --check --safe .
tests:
stage: tests
check_lint:
stage: style
image: continuumio/miniconda3:latest
before_script:
- conda create --quiet --name testenv --channel http://bcu-ci.esrf.fr/stable python=3 --file requirements-conda.txt --file requirements-test-conda.txt
- pip install -r requirements-dev.txt
script:
# run flake8 on diff between current branch and last common ancestor with master
- git diff -U0 origin/master...$CI_COMMIT_SHA | flake8 --diff
# allow failure without impacting the rest of the CI (will show an orange warning in the UI)
allow_failure: true
.run_tests:source:
stage: tests
image: continuumio/miniconda3:latest
script:
# install Xvfb and opengl libraries (needed for test_flint)
- apt-get update && apt-get -y install xvfb libxi6
# create test env and install BLISS
- conda create --quiet --name testenv --file requirements-conda.txt --file requirements-test-conda.txt
- source activate testenv
# Get louie from github for python 3 compatibility
- conda install -q --yes git
# Install bliss and its pip-only dependencies
- pip install git+https://github.com/manahl/pytest-plugins#subdirectory=pytest-profiling
- pip install .
script:
- python setup.py test --addopts "--cov bliss --cov-report html --cov-report term"
# run tests on source
- python setup.py test --addopts "--cov bliss --cov nexus_writer_service --cov-report html --cov-report term --profile --durations=30"
after_script:
- python scripts/profiling2txt.py
- sh scripts/print_test_profiling.sh
artifacts:
paths:
- htmlcov/
expire_in: 7 days
only:
changes: # skip tests for doc changes
- "bin/**/*"
- "**/*.{py}"
- "extensions/**/*"
- "scripts/**/*"
- "spec/**/*"
- "tests/**/*"
- ".gitlab-ci.yml"
- "requirements*"
- "setup.*"
build_doc:
stage: build_doc
before_script:
- conda create -q --yes --name docenv --channel http://bcu-ci.esrf.fr/stable python=3 --file requirements-conda.txt --file requirements-doc-conda.txt
run_tests:branch:
extends: .run_tests:source
only:
refs:
- branches
except:
refs:
- merge_requests
run_tests:merge_request:
extends: .run_tests:source
only:
refs:
- merge_requests
package:
stage: build
image: continuumio/miniconda3:latest
script:
# create package env and install all requirements and conda-build, (gcc and g++ compiler required for flint)
- conda create --quiet --name buildenv --file requirements-conda.txt --file requirements-test-conda.txt conda-build
- source activate buildenv
# create links to reach prefixed compilers of conda
- ln -s /opt/conda/envs/buildenv/bin/x86_64-conda_cos6-linux-gnu-gcc /opt/conda/envs/buildenv/bin/gcc
- ln -s /opt/conda/envs/buildenv/bin/x86_64-conda_cos6-linux-gnu-g++ /opt/conda/envs/buildenv/bin/g++
# triggering the creation of bliss/release.py file
- python -c "from setup import generate_release_file;generate_release_file()"
# creating the meta.yaml file for conda packet generation
- cd scripts
- python create_recipe.py
- conda build . --prefix-length=80 --output-folder=../dist/
# creating a local conda channel to serve bliss packet for next stage
- cd ..
- mkdir conda-local-channel conda-local-channel/linux-64
- cp -r dist/linux-64/*.tar.bz2 conda-local-channel/linux-64/
- conda index conda-local-channel
artifacts:
paths:
- dist/
- conda-local-channel/
expire_in: 7 days
only:
- tags
create_doc:reference:
stage: build
image: continuumio/miniconda3:latest
script:
# install opengl libraries (needed to avoid problem with pyopengl dependency)
- apt-get update && apt-get -y install libgl1-mesa-glx
# create doc env and install all requirements
- conda create -q --yes --name docenv --file requirements-conda.txt --file requirements-doc-conda.txt
- source activate docenv
- pip install -r requirements-doc.txt
script:
# build of documentation
- python setup.py build_sphinx
artifacts:
paths:
- build/
expire_in: 7 days
build_user_doc:
stage: build_user_doc
before_script:
- conda install -q --yes --channel http://bcu-ci.esrf.fr/stable --file requirements-doc-conda.txt
- pip install -r requirements-doc.txt
create_doc:user:
stage: build
image: continuumio/miniconda3:latest
script:
# install opengl libraries (needed to avoid problem with pyopengl dependency)
- apt-get update && apt-get -y install libgl1-mesa-glx
# create doc env and install all requirements
- conda create -q --yes --name mkdocsenv --file requirements-conda.txt --file requirements-doc-conda.txt
- source activate mkdocsenv
- pip install -r requirements-doc.txt
# build of documentation
- cd doc && mkdocs build
artifacts:
paths:
- doc/site
paths:
- doc/site
expire_in: 7 days
run_tests:package:
stage: package_tests
image: continuumio/miniconda3:latest
script:
# install Xvfb and opengl libraries (needed for test_flint)
- apt-get update && apt-get -y install xvfb libxi6
- mv bliss source # to avoid import errors (we want to test the packet, not local bliss folder)
- conda create -y --name testenv
- source activate testenv
- conda install bliss==$CI_COMMIT_TAG --file requirements-test-conda.txt --channel file://${CI_PROJECT_DIR}/conda-local-channel
- pytest --cov=bliss --cov-report html --cov-report term
artifacts:
paths:
- htmlcov/
expire_in: 7 days
only:
- tags
pages:
stage: deploy
dependencies:
- build_user_doc
- build_doc
- tests
before_script:
- ''
tags:
- conda
- builder
- linux
script:
- mv doc/site/ public
- mv build/sphinx/html public/api
- mv htmlcov public/
# Publishing to intranet folders
# if we have a tag it will be published under the intranet gitlab page under /tag/ otherwhise under /master/
- if [[ ( $CI_COMMIT_REF_NAME == master && -z $CI_COMMIT_TAG ) ]]; then export DOC_DIR='master'; else export DOC_DIR=${CI_COMMIT_TAG}; fi
#- rm -rf public/* # target dir should be cleaned at first time
- rm -rf public/${DOC_DIR}
- mkdir -p public/${DOC_DIR}/api/
- mkdir -p public/${DOC_DIR}/htmlcov/
- cp -rT doc/site public/${DOC_DIR}/
- cp -rT build/sphinx/html public/${DOC_DIR}/api/
- 'cp -rT htmlcov public/${DOC_DIR}/htmlcov/ || :'
artifacts:
paths:
- public
expire_in: 7 days
only:
- tags
- master
deploy_bliss:
stage: deploy
before_script:
- ''
tags:
- conda
- builder
- linux
script:
# for tags with 'rc' the package will be published to http://bcu-ci.esrf.fr/stable/
# for other tags the package will be published to http://bcu-ci.esrf.fr/stable/
- if [[ $COMMIT_TAG == *rc* ]]; then export BASEDIR='/conda-devel'; else export BASEDIR='/conda'; fi
- cp -r dist/linux-64/*.tar.bz2 ${BASEDIR}/linux-64/
# Updating conda package index metadata
- conda index ${BASEDIR}
only:
- tags
[submodule "driver/ct2/linux"]
path = driver/ct2/linux
url = git://gitlab.esrf.fr/Hardware/p201.git
repos:
- repo: https://github.com/ambv/black
- repo: https://github.com/psf/black
rev: 18.6b4
hooks:
- id: black
language_version: python3 # Should be >= 3.6
\ No newline at end of file
language_version: python3 # Should be >= 3.6
- repo: local
hooks:
- id: flake8-diff
name: flake8-diff
description: Run flake8 linter on diff lines of stage area
language: script
entry: ./flake8-diff.sh
verbose: true # force output when the hook passes
[MASTER]
extension-pkg-whitelist=PyQt5
This diff is collapsed.
......@@ -6,4 +6,18 @@ Bliss
The bliss control library.
Latest documentation from master can be found [here](http://bliss.gitlab-pages.esrf.fr/bliss)
\ No newline at end of file
Latest documentation from master can be found [here](http://bliss.gitlab-pages.esrf.fr/bliss/master)
In short
========
To update BLISS from source:
```
conda install --file ./requirements-conda.txt
pip install --no-deps -e .
```
......@@ -3,7 +3,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import gevent
from gevent import socket
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""
Usage: bliss_webserver [-p <port> | --port=<port>]
bliss_webserver (-h | --help)
Options:
-p, --port=<port> Port number [default: 8099]
-h, --help Show this screen.
"""
import os
import docopt
import logging
import bliss
from bliss.shell.web import bliss_webserver
try:
arguments = docopt.docopt(__doc__)
port = int(arguments["--port"])
except docopt.DocoptExit as e:
print(e.message)
else:
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
bliss_webserver.serve_forever(port)
......@@ -3,7 +3,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""
......@@ -18,7 +18,7 @@ import gevent
import json
from bliss.common.utils import OrderedDict
from collections import OrderedDict
try:
import sps
......@@ -135,9 +135,9 @@ def watch_data(scan_node, session_name):
):
if not is_zerod(zerod):
continue
if event_type is scan_data_iterator.NEW_CHILD_EVENT:
if event_type is scan_data_iterator.EVENTS.NEW_CHILD:
copy_data(zerod, zerod_index, session_name, nbcounters, npoints)
elif event_type is scan_data_iterator.NEW_DATA_IN_CHANNEL_EVENT:
elif event_type is scan_data_iterator.EVENTS.NEW_DATA_IN_CHANNEL:
copy_data(zerod, zerod_index, session_name, nbcounters, npoints)
except _MaxCounterReach:
nbcounters *= 2
......@@ -164,7 +164,7 @@ def watch_session(session_name):
for event_type, scan_node in data_iterator.wait_for_event(
pubsub, filter="scan"
):
if event_type != data_iterator.NEW_CHILD_EVENT:
if event_type != data_iterator.EVENTS.NEW_CHILD:
continue
if watch_data_task:
watch_data_task.kill()
......
......@@ -3,7 +3,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import argparse
......
......@@ -2,16 +2,11 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""Bliss main package
For your convenience, configuration motion and scan APIs have been made available
directly at this level.
Here are the main bliss sub-systems:
.. autosummary::
:toctree:
......@@ -25,7 +20,6 @@ Here are the main bliss sub-systems:
shell
tango
"""
from . import release
__version__ = release.version
......@@ -33,6 +27,65 @@ __author__ = release.author
__license__ = release.license
version_info = release.version_info
from gevent import monkey
from gevent import monkey as _monkey
_monkey.patch_all(thread=False)
from bliss.common.proxy import Proxy as _Proxy
def get_current_session():
from bliss.common import session
return session.get_current_session()
current_session = _Proxy(get_current_session)
from bliss.common.alias import MapWithAliases as _MapWithAliases
global_map = _MapWithAliases(current_session)
from bliss.common.logtools import Log as _Log
global_log = _Log(map=global_map)
def logging_startup(
log_level="WARNING", fmt="%(levelname)s %(asctime)-15s %(name)s: %(message)s"
):
"""
Provides basicConfig functionality to bliss activating at proper level the root loggers
"""
import logging # this is not to pollute the global namespace
# save log messages format
global_log.set_log_format(fmt)
global_log._LOG_DEFAULT_LEVEL = log_level # to restore level of non-BlissLoggers
# setting startup level for session and bliss logger
logging.getLogger("session").setLevel(log_level)
logging.getLogger("bliss").setLevel(log_level)
# install an additional handler, only for debug messages
# (debugon / debugoff)
global_log.set_debug_handler(logging.StreamHandler())
# Bliss shell mode False indicates Bliss in running in library mode
_BLISS_SHELL_MODE = False
def set_bliss_shell_mode(mode=True):
"""
Set Bliss shell mode
"""
global _BLISS_SHELL_MODE
_BLISS_SHELL_MODE = mode
monkey.patch_all(thread=False)
def is_bliss_shell():
"""
Tells if Bliss is running in shell or library mode
"""
return _BLISS_SHELL_MODE
......@@ -2,14 +2,16 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
from warnings import warn
import logging
from .embl import ExporterClient
from bliss.common.logtools import *
from bliss import global_map
import gevent
from gevent.queue import Queue
from .embl import ExporterClient
exporter_clients = {}
......@@ -57,6 +59,10 @@ class Exporter(ExporterClient.ExporterClient):
self.events_queue = Queue()
self.events_processing_task = None
global_map.register(
self, parents_list=["comms"], tag=f"exporter: {address}:{port}"
)
def start(self):
pass
# self.started=True
......@@ -139,8 +145,9 @@ class Exporter(ExporterClient.ExporterClient):
try:
cb(self._to_python_value(value))
except:
logging.exception(
"Exception while executing callback %s for event %s", cb, name
log_exception(
self,
f"Exception while executing callback {cb} for event {name}",
)
continue
......
......@@ -2,7 +2,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""Communication (:class:`~bliss.comm.gpib.Gpib`, :class:`~bliss.comm.tcp.Tcp`, \
......@@ -21,3 +21,5 @@ This module gathers different communication interfaces
tcp
util
"""
from bliss.comm.util import get_comm
......@@ -2,7 +2,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import sys
......
......@@ -2,7 +2,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import sys
......
......@@ -2,7 +2,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Copyright (c) 2015-2019 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
"""Exception classes for communication"""
......
......@@ -2,7 +2,7 @@
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF