Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Migrate to Python 3 #1173

Merged
merged 111 commits into from
Aug 8, 2019
Merged

Migrate to Python 3 #1173

merged 111 commits into from
Aug 8, 2019

Conversation

reszelaz
Copy link
Collaborator

@reszelaz reszelaz commented Jul 20, 2019

This PR migrates Sardana from Python 2 to Python 3.

Sardana version gets bumped to 3.0.0 alpha.

From now on Sardana requires at least:

  • Taurus 4.5 Taurus 4.5.5a
  • PyTango 9.2.5
  • Python 3.5

MacroServer environment created with Python 2 needs to be manually migrated to Python 3.
Pleas use the scripts/upgrade/upgrade_env.py script to do so.

In the migration process we found a serious problem with the Taurus and PyTango, more details in: tango-controls/pytango#292.
Whenever this issue gets clarified we will need to revert 2f0a36a.

Also whenever taurus-org/taurus#945 gets clarified we will need to adapt usage of JSONCodec (related to 25dce83). This is already done.

I take a profit of this message to ask @sardana-org/integrators and anyone else interested in helping to test this PR. Whenever you find an issue with this branch please report it starting the issue summary with "Py3: ". If you have any question about the migration either comment on #1089 or open a dedicated issue for that.

Before integration we need to perform the release manual tests. I will try to extend the manual test scenarios to cover more features which are not tested automatically.

We plan to test the following platforms:

  • Debian 9
  • Centos 7
  • Windows 10

The reszelaz/sardana-test:py3 docker image or the following conda environment can serve as inspiration for preparing the testing environment:

conda config --add channels conda-forge
conda config --add channels tango-controls
conda create -n sdn-py3
# optional if someone install in user site: export PYTHONNOUSERSITE=1
conda activate sdn-py3
conda install python=3.5 pyqt=5 itango pytango lxml future guidata ipython pillow pint ply pyqtgraph pythonqwt numpy scipy click h5py matplotlib
pip install --no-deps -e . # for taurus and sardana

Many thanks in advance for help in the migration process!

Fixes #1089.

reszelaz and others added 18 commits July 25, 2019 23:38
All parameters have been initializing their min and max value.
This is an unimplemented feature and nowadays only make sense in
paramrepeats.

Fix it.
Basically do the same as in 1eb511a but also for new API of repeat parameters.

All parameters have been initializing their min and max value.
This is an unimplemented feature and nowadays only make sense in
paramrepeats.
mimeData method  works with bytes in Py3. Encode/Decode the
sting data.
PEP352 removed backwards compatibility for indexing of BaseException.
Now one needs to use args member get item based on index.
os.write method requires bytes instead of str.

Fix it.
The current implementation of formatResult method
for file type is broken.

Add TODO to formalize api and documentation

Fix it.
- ensure script is run in python 2
- use dbm instead of dumbdb
PEP352 removed backwards compatibility for indexing of BaseException.
Now one needs to use args member get item based on index.py3: user Exception
Macrobutton editors are text editors (QLineEdit) and requires strings.
Macro parameter default values can be however of different types e.g. int,
float. Cast them all to strings.
ndbm backend does not work correctly in the way Sardana uses shelve.
This backedn does not store data on disk when process receives SIGKILL or
SIGABRT. gnu and dumb however works much better.
ndbm backend does not work correctly in the way Sardana uses shelve.
This backend does not store data on disk when process receives SIGKILL or
SIGABRT. gnu and dumb however works much better.

Add MS_ENV_SHELVE_BACKEND to sardanacustomseetings in order to select between
gnu and dumb backends. In case it is not specified, first try to use gnu
and if not available use dumb.
Sardana requires taurus-org/taurus#960 (JSON and UTF-8 coding).
Bump taurus requirement to > 4.5.4.
@reszelaz
Copy link
Collaborator Author

reszelaz commented Jul 30, 2019

  • Manual tests on Debian 9 (Py3: manual tests on Debian 9 #1175) revealed some problems which are already fixed. These tests included the standard release manual tests plus some extra test scenarios.
  • The Windows platform can not be tested since we lack of working conda environment - we need to wait for PyTango 9.3.1 conda package due to Spock blocks when using tango 9.3 #1152.
  • The original plan was also to test it on CentOS 7 before integration of this PR into develop.

What do you think if we consider that the Debian 9 tests are enough? And we test both CentOS 7 and Windows ASAP but already after integrating this PR? Could you please express your opinions, especially @sardana-org/integrators ?

This is a summary of issues of high importance that we need to have in mind:

  1. Your custom plugins (controllers/macros/recorders/widgets using Taurus extension) needs to be ported to Python 3.
  2. The MacroServer environment created with Python 2 needs to be ported to Python 3: see sardana/scritps/upgrade/upgrade_env.py.
    This requires a choice of the shelve backend (either gnu or dumb) at the moment of migration. The same decission is also important for new Sardana systems. In this last case it can be tuned with this sardanacustomsetting.MS_ENV_SHELVE_BACKEND.
  3. Online scan trend does not work yet in this branch - Qwt5 is not available for Python 3. We plan to use taurus_pyqtgraph and will start to implent this ASAP. Already implemente in Make online scan work with pyqtgraph reszelaz/sardana#25.

There are also some technical debts that we took already and we need to pay ASAP:

  1. We were forced to not use taurus.Device with the Sardana extensions in some places of the MacroServer (see commit 2f0a36a) due to DS crashes when unsubscribing from events in __del__ tango-controls/pytango#292.
  2. Device_4Impl.delete_device is not called due to Import taurus in PyTango DS causes that delete_device is not called at shutdown taurus-org/taurus#982.

@teresanunez
Copy link

Hi @reszelaz, many thanks for all this work, I agree with you that it can be integrated.

Allow str record data in NXscanH5_FileRecorder.
@amilan
Copy link

amilan commented Aug 8, 2019

As agreed in today's sardana follow-up meeting, this PR is ready to be merge.

@amilan amilan merged commit b934281 into sardana-org:develop Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support python3 in sardana
5 participants