Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Create custom conda environment for 8ID #2

Closed
jkirchman opened this issue Jul 9, 2019 · 9 comments
Closed

Create custom conda environment for 8ID #2

jkirchman opened this issue Jul 9, 2019 · 9 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jkirchman
Copy link
Collaborator

create a custom conda environment, local to the 8ID workstation to
insulate the beam line against unexpected changes in the /APSshare
installation of bluesky. There is some sensitivity to this at the beam
line and we should try to be conservative here.

@prjemian prjemian added the enhancement New feature or request label Jul 9, 2019
@prjemian prjemian added this to the initial setup milestone Jul 9, 2019
@prjemian
Copy link
Collaborator

prjemian commented Jul 9, 2019

first, check that there is not a conda environment already named bluesky with command: conda env list

snow% which conda
/APSshare/anaconda/x86_64/bin/conda
snow% conda env list
# conda environments:
#
base                  *  /APSshare/anaconda/x86_64
                         /home/beams10/8IDIUSER/xicam2_py_VE

Good, we can proceed with commands to build and populate with BS

conda create -n bluesky python=3

you might get a warning that conda needs to be updated on the server, that's ok for now

@prjemian
Copy link
Collaborator

prjemian commented Jul 9, 2019

This is a good time to add some conda channels (web sites with software) for our upcoming downloads and maintenance. Here's what I have used elsewhere:

(base) jemian@wow ~ $ conda env list
# conda environments:
#
base                  *  /APSshare/anaconda/x86_64
apspy27                  /home/oxygen/JEMIAN/.conda/envs/apspy27
bluesky                  /home/oxygen/JEMIAN/.conda/envs/bluesky
pydm                     /home/oxygen/JEMIAN/.conda/envs/pydm
pymca_python3_qt5        /home/oxygen/JEMIAN/.conda/envs/pymca_python3_qt5

(base) jemian@wow ~ $ cat /home/oxygen/JEMIAN/.conda/envs/bluesky/.condarc 
channels:
  - prjemian
  - aps-anl-tag
  - aps-anl-dev
  - conda-forge
  - lightsource2-tag
  - lightsource2-dev
  - pydm-tag
  - pydm-dev
  - defaults

@prjemian
Copy link
Collaborator

prjemian commented Jul 9, 2019

install bluesky and friends, see what else comes along, create a requirements file and install from that:

bluesky
ophyd
databroker
event-model
apstools
ipython
jupyter
tornado<5
pyepics

@prjemian
Copy link
Collaborator

prjemian commented Jul 9, 2019

be sure to activate the new bluesky environment from a bash shell

snow% source /APSshare/anaconda/x86_64/bin/activate 
_CONDA_ROOT=/APSshare/anaconda/x86_64: Command not found.
_CONDA_ROOT: Undefined variable.
snow% bash
bash-4.2$ source /APSshare/anaconda/x86_64/bin/activate bluesky
(bluesky) bash-4.2$ 

Could be faster if we already used bash and had some conda environment already activated:

conda activate bluesky

installation command (using the requirements file from previous step)

conda install --file requirements.txt

@prjemian
Copy link
Collaborator

prjemian commented Jul 9, 2019

Note in our requirements that the tornado package must be kept at the latest version before major version 5 (see ContinuumIO/anaconda-issues#8789). We imposed that at the installation but we want to keep it from being updated later. We'll add a pinned file to our conda environment to maintain that rule for us during updates:

touch /home/beams/S8IDIUSER/.conda/envs/bluesky/conda-meta/pinned
# edit that file adding just this next line
tornado<5

@prjemian
Copy link
Collaborator

prjemian commented Jul 9, 2019

Now we can test if we have installed enough software to be useful. Might still need more...

import apstools.devices as APS_devices
aps = APS_devices.ApsMachineParametersDevice(name="aps")

We need to wait for those PVs to connect. Check that aps.connected returns True before continuing. Test by looking at the APS storage ring current:

aps.current.value

The complete structure is: aps.summary()

In [3]: aps.summary()                                                                                      
data keys (* hints)
-------------------
 aps_current
 aps_fill_number
 aps_global_feedback
 aps_global_feedback_h
 aps_global_feedback_v
 aps_lifetime
 aps_machine_status
 aps_operating_mode
 aps_operator_messages_fill_pattern
 aps_operator_messages_floor_coordinator
 aps_operator_messages_last_problem_message
 aps_operator_messages_last_trip_message
 aps_operator_messages_message6
 aps_operator_messages_message7
 aps_operator_messages_message8
 aps_operator_messages_operators
 aps_orbit_correction
 aps_shutter_permit

read attrs
----------
current              EpicsSignalRO       ('aps_current')
lifetime             EpicsSignalRO       ('aps_lifetime')
machine_status       EpicsSignalRO       ('aps_machine_status')
operating_mode       EpicsSignalRO       ('aps_operating_mode')
shutter_permit       EpicsSignalRO       ('aps_shutter_permit')
fill_number          EpicsSignalRO       ('aps_fill_number')
orbit_correction     EpicsSignalRO       ('aps_orbit_correction')
global_feedback      EpicsSignalRO       ('aps_global_feedback')
global_feedback_h    EpicsSignalRO       ('aps_global_feedback_h')
global_feedback_v    EpicsSignalRO       ('aps_global_feedback_v')
operator_messages    ApsOperatorMessagesDevice('aps_operator_messages')
operator_messages.operators EpicsSignalRO       ('aps_operator_messages_operators')
operator_messages.floor_coordinator EpicsSignalRO       ('aps_operator_messages_floor_coordinator')
operator_messages.fill_pattern EpicsSignalRO       ('aps_operator_messages_fill_pattern')
operator_messages.last_problem_message EpicsSignalRO       ('aps_operator_messages_last_problem_message')
operator_messages.last_trip_message EpicsSignalRO       ('aps_operator_messages_last_trip_message')
operator_messages.message6 EpicsSignalRO       ('aps_operator_messages_message6')
operator_messages.message7 EpicsSignalRO       ('aps_operator_messages_message7')
operator_messages.message8 EpicsSignalRO       ('aps_operator_messages_message8')

config keys
-----------

configuration attrs
----------
operator_messages    ApsOperatorMessagesDevice('aps_operator_messages')

Unused attrs
------------

Current values are: aps.read()

In [8]: aps.read()                                                                                         
Out[8]: 
OrderedDict([('aps_current',
              {'value': 88.52652776860398, 'timestamp': 1562701828.753756}),
             ('aps_lifetime',
              {'value': 52.583085617905894, 'timestamp': 1562701826.753587}),
             ('aps_machine_status',
              {'value': 'USER OPERATIONS', 'timestamp': 1562331601.371168}),
             ('aps_operating_mode',
              {'value': 'Delivered Beam', 'timestamp': 1562500392.942352}),
             ('aps_shutter_permit',
              {'value': 'PERMIT', 'timestamp': 1562500392.940957}),
             ('aps_fill_number',
              {'value': 25.0, 'timestamp': 1562500392.94135}),
             ('aps_orbit_correction',
              {'value': 0.0, 'timestamp': 1562701594.270834}),
             ('aps_global_feedback',
              {'value': 'On', 'timestamp': 1562701594.553689}),
             ('aps_global_feedback_h',
              {'value': 'On', 'timestamp': 1562701594.553689}),
             ('aps_global_feedback_v',
              {'value': 'On', 'timestamp': 1562701594.553689}),
             ('aps_operator_messages_operators',
              {'value': 'Dee Weyer and Steven LaBuda',
               'timestamp': 1562677538.647096}),
             ('aps_operator_messages_floor_coordinator',
              {'value': 'Shane Flood (2-0101)',
               'timestamp': 1562677404.908362}),
             ('aps_operator_messages_fill_pattern',
              {'value': '0+324x1 RHB', 'timestamp': 1561382181.863053}),
             ('aps_operator_messages_last_problem_message',
              {'value': '', 'timestamp': 1562500477.95326}),
             ('aps_operator_messages_last_trip_message',
              {'value': '', 'timestamp': 1562586730.877042}),
             ('aps_operator_messages_message6',
              {'value': 'Scheduled Fill on Fill at 07:45 & 19:45',
               'timestamp': 1562500507.033807}),
             ('aps_operator_messages_message7',
              {'value': '', 'timestamp': 1558051460.483074}),
             ('aps_operator_messages_message8',
              {'value': '', 'timestamp': 1558051455.619456})])

@prjemian
Copy link
Collaborator

prjemian commented Jul 9, 2019

Good, our initial tests showed that we forgot to install PyEpics. That has been added to the requirements above now.

@prjemian
Copy link
Collaborator

@jkirchman
Copy link
Collaborator Author

Done with this conda environment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants