-
Notifications
You must be signed in to change notification settings - Fork 4
Ska3 runtime environment for users
The Ska3 runtime environment consists of an integrated suite of Python-3 packages and associated applications. The installation and update of these packages is done using the Anaconda Python distribution and the Conda package manager. This allows simple installation on linux machines or Mac laptops. Similar support for Windows is under consideration.
- Installing Ska3 runtime environment
- Testing Ska3
- Ska Data
- Maintaining Ska3 runtime environment
- Installing Ska3 development environment
For discussion about motivation for Python 3, new features, and converting from Python 2.7 to Python 3, see:
Power users note: on the HEAD linux network there can be a substantial improvement in package import
times if you install and maintain your own Ska3 installation on a local disk. The production
installation on /proj/sot
is served via a remote NetApp which can be quite slow.
The basis for installing, managing, and using Ska3 is the Conda package
manager and this needs to be installed before anything
else can be done. If you already have the conda package manager installed
with version 4.8 or higher (conda --version
), then you can skip these steps and go to the
Create Ska3 environment section.
Important note about older conda
If you have a version of conda older than 4.8, this is not compatible with ska3. We recommend deleting that old conda and the associated environment.
The steps for creating a new conda environment are as follows:
- Get one of the following files by URL:
https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh
https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.3-MacOSX-x86_64.sh
https://repo.continuum.io/miniconda/Miniconda3-py38_4.8.3-Windows-x86_64.exe
For Windows follow the instructions for Installing on Windows or consult your local Windows expert.
For linux and MacOSX proceed with the following steps.
-
Open a terminal window and change to the downloads directory for your browser.
-
The installer is called something like
Miniconda--py38_4.8.3-<OS>.sh
. Find it and then enter the following (without the%
, which is used as the linux prompt in all these examples):
% bash Miniconda3-py38_4.8.3-MacOSX-x86_64.sh
-
Hit ENTER, then agree to the license terms, and finally specify the installation directory. This will be created by the installer and needs to be a directory that doesn t currently exist. A fine choice is the default of
~/miniconda3
(which is what is assumed for the rest of the installation), but you may want to install to a different directory depending on the details of your system. -
At the end it asks about updating your
.bashrc
or.bash-profile
or.cshrc
file. We recommend accepting (say yes). -
Now create a new terminal window.
This gives you a minimal working Python along with the package manager utility conda. Check hat this is working by doing:
% which python
--> shows the expected path, e.g. $HOME/miniconda3/bin/python
Now you can install all the Ska3 packages and required dependencies to an environment
named ska3
by copy-pasting this long command:
% conda create -n ska3 ska3-flight --override-channels -c https://icxc.cfa.harvard.edu/aspect/ska3-conda/flight
On linux and MacOSX you can optionally install ska3-perl
as well. This is mostly for aspect-specific apps like starcheck.
After you see the list of packages, accept, and see that the install finished. Then you can get into the Ska3 environment
% conda activate ska3
It's done and now you have a ska3
flight environment! The name ska3
is not magic, and you
could have called it my-ska
or whatever you want.
If you make a new shell window then you need to conda activate ska3
to get into Ska3
again.
Congratulations, you should now have all the Ska3 packages installed!
As a quick smoke test that things are working, confirm that the following works and makes a line plot:
% ipython --matplotlib
>>> import matplotlib.pyplot as plt
>>> from Chandra.Time import DateTime
>>> import ska_path
>>>
>>> plt.plot([1, 2])
>>> DateTime(100).date
'1998:001:00:00:36.816'
A comprehensive check that everything is working can be done by running the full Ska3 integration test suite. This will take up to a half hour. Before starting this you must ensure that the standard Ska data are installed.
# Change to a directory for git repos, or a temporary directory
cd ~/git # Or whatever
git clone https://github.com/sot/ska_testr.git
cd ska_testr
run_testr --test-spec test_spec_standalone
This will provide a summary of test results at the end, with detailed logs available in the outputs/logs
directory.
To make full use of the Ska environment you need various package data, e.g.:
- Ska engineering archive
- Kadi databases
- Commanded states databases
- AGASC star catalog
- Telemetry database (MSIDs)
The very first thing to do is define the disk location where you want to store the Ska data. Packages and applications in the Ska runtime environment use an environment variable SKA to define the root directory of data and other shared resources. On the HEAD or GRETA networks this root is the familiar /proj/sot/ska3/flight.
For a machine (e.g. your laptop) not on the HEAD or GRETA networks you need to make a directory that will hold the Ska data. A reasonable choice is putting this in a ska directory in your home directory:
% mkdir ~/ska
% setenv SKA ${HOME}/ska # csh / tcsh
% export SKA=${HOME}/ska # bash
If you have made a local Ska environment on a machine on the HEAD or GRETA networks, you can just set the SKA environment variable to point at the existing root:
% setenv SKA /proj/sot/ska # csh / tcsh
% export SKA=/proj/sot/ska # bash
For a machine not on the HEAD or GRETA networks you need to get at least a subset of the data on your machine. FOT users may want to start up MATLAB which will run a task to update the Ska data used by those tools. Other users or FOT users with different data needs will use a script called ska_sync that is installed as part of Ska. This assume you have set the SKA environment variable and created a directory as shown above.
The first thing is to try running it and getting the online help:
% ska_sync --help
usage: ska_sync [-h] [--user USER] [--install] [--force]
Synchronize data files for Ska runtime environment
Arguments
=========
optional arguments:
-h, --help show this help message and exit
--user USER User name for remote host
--install Install sync config file in default location
--force Force overwrite of sync config file
Next you need to install a copy of the template configuration file into your Ska root directory. This will let you customize which data you want and how to get it. This installation is done with:
% echo $SKA # Check the SKA root directory
/Users/aldcroft/ska
% ska_sync --install
Wrote ska sync config file to /Users/aldcroft/ska/ska_sync_config
Now you need to edit the file it just created and set the remote host for getting data and the remote host user name. Choose either kadi.cfa.harvard.edu (HEAD) or the IP address for cheru (OCC) and edit accordingly. Likewise put in the corresponding user name:
# Host machine to supply Ska data (could also be chimchim but kadi works
# from OCC VPN just as well).
host: kadi.cfa.harvard.edu
# Remote host user name. Default is local user name.
# user: name
If you want Ska engineering archive access then following the instructions in Syncing Ska engineering archive data
Finally do the sync step:
% ska_sync
Loaded config from /Users/aldcroft/ska/ska_sync_config
This prints something like below:
COPY and PASTE the following at your terminal command line prompt:
rsync -arzv --progress --size-only --files-from="/Users/aldcroft/ska/ska_sync_files" \
aldcroft@kadi.cfa.harvard.edu:/proj/sot/ska/ "/Users/aldcroft/ska/"
As instructed copy and paste the rsync line, after which you will need to enter your password. At this point it will sync the relevant Ska data files into your local Ska root.
NOTE for Windows users (but not on FOT laptops): one possibility for running the rsync
command is to use Windows Subsystem for Linux. This has been successfully demonstrated
for a standalone Windows machine.
As long as you don t change your config file, you can just re-run that same command to re-sync as needed.
To test that the data are really there make sure you can reproduce the following:
% ipython --matplotlib
>>> from Ska.tdb import msids
>>> msids.find('tephin')
[<MsidView msid="TEPHIN" technical_name="EPHIN SENSOR HOUSING TEMP">]
>>> from kadi import events
>>> events.normal_suns.filter('2014:001')
<NormalSun: start=2014:207:07:04:09.331 dur=65207>
>>> from Chandra.cmd_states import fetch_states
>>> fetch_states('2011:100', '2011:101', vals=['obsid'])
...
SOME WARNINGS WHICH ARE OK and will get patched up later
...
[ ('2011:100:11:53:12.378', '2011:101:00:26:01.434', 418823658.562, 418868827.618, 13255)
('2011:101:00:26:01.434', '2011:102:13:39:07.421', 418868827.618, 419002813.605, 12878)]
Syncing Ska engineering data to your standalone installation (laptop) is feasible. Circa mid-2019, the archive about 170 Gb. Copying the entire archive over VPN network will take a while, but it has been done.
Keeping the archive up to date should be done using cheta_sync
, which is documented
in the Cheta telemetry archive tutorial.
rsync -av --prune-empty-dirs --exclude='/*/*/*/' --include='*/' \
--include='???????/ofls?/*.backstop' --include='???????/ofls?/*.or' --exclude='*' \
kady:/data/mpcrit1/mplogs/2019/ $SKA/data/mpcrit1/mplogs/2019/
Maintaining your environment is straightforward. When there is a new release (or just periodically) do:
% conda update ska3-flight --override-channels -c https://icxc.cfa.harvard.edu/aspect/ska3-conda/flight
Users that want to work in an environment that contains the latest development version
(the master
branch) of all Ska3 packages can do so as follows. This takes advantage of a distribution channel
named masters
that has the latest conda build for the master branch of all Ska3 packages.
The command below will select packages from masters
where the version is greater than
the release version.
# Mac / linux (note: ska3-perl-latest is optional)
conda create -n ska3-dev --override-channels \
-c https://icxc.cfa.harvard.edu/aspect/ska3-conda/masters \
-c https://icxc.cfa.harvard.edu/aspect/ska3-conda/flight \
ska3-core-latest ska3-flight-latest ska3-perl-latest
# Windows
conda create -n ska3-dev --override-channels `
-c https://icxc.cfa.harvard.edu/aspect/ska3-conda/masters `
-c https://icxc.cfa.harvard.edu/aspect/ska3-conda/flight `
ska3-core-latest ska3-flight-latest
For a Ska3-dev environment you can easily update a single Ska3 package. For instance if
you wanted to revert to version 3.1.0 of dea_check
(since master of dea_check
is ahead of that),
you would do the following:
conda install -c $ska3conda/flight --override-channels dea_check=3.1.0
The commands below to update all packages to the latest would undo this.
Getting a bit braver, if you wanted to install numpy 1.19 then this would work:
conda install --override-channels \
-c https://icxc.cfa.harvard.edu/aspect/ska3-conda/flight -c defaults \
numpy=1.19
If you have your own development version of a package and you want to install it
into your dev environment, this is easily done with pip
:
pip install .
This will override the existing conda package (if it exists). Doing a conda list
will now show the package as being pip-installed and will show the appropriate
dev version.
You can update to the latest version in the master branch for all Ska3 packages with the following:
# Mac / linux
conda update --update-deps --override-channels \
-c https://icxc.cfa.harvard.edu/aspect/ska3-conda/masters \
ska3-flight-latest
# Windows
conda create -n ska3-dev --override-channels `
-c https://icxc.cfa.harvard.edu/aspect/ska3-conda/masters `
ska3-flight-latest