Skip to content
Daniel Morcuende edited this page Oct 23, 2024 · 6 revisions

How to

How to run tests locally:

After installing lstosa run pytest --basetemp=test_osa from the root directory of the repository (where setup.py is placed). You can control verbosity with -v, -vv, etc. If you want to execute a given test use -k <test_name> or only some tests from a given subfolder with -m <path_to_subfolder>.

Tests should be self-contained, i.e., everything needed by the tests should be either within the extra subfolder or just produced by the test fixtures. Therefore, they should be able to run in any environment adequately set.

How to resume a job that failed to be launched and holds in the queue waiting for a user action:

The message in the queue output says: launch failed requeued held

             JOBID PARTITION     NAME      USER ST       TIME  NODES NODELIST(REASON) 
        323390_112      long LST1_089 user.name PD       0:00      1 (launch failed requeued held)

This job can be resumed by doing: scontrol release 323390_112

OSA database

How to create an osa database.

sqlite3 /your/path/to/osa.db

Create the processing table:

CREATE TABLE IF NOT EXISTS processing                               
            (telescope, date, prod_id, start, end, is_finished)

How to access processing information in the osa database.

sqlite3 /path/to/osa.db

To see the columns of the processing table:

sqlite> .schema processing
CREATE TABLE processing`
            `(telescope, date, prod_id, start, end, is_finished);

Content of the processing table

sqlite> select * from processing;
LST1|2022-06-05|v0.9|2022-06-09 19:58:03.124332|2022-06-09 21:10:10.637506|1

Access TCU database info:

Example to list the source/wobble info available from all runs. Note that sometimes info is missing and accessing that information for some runs is not possible in this way.

from pymongo import MongoClient


tcu_server = "lst101-int"
client = MongoClient(tcu_server)
database = client['lst1_obs_summary']
telescope_collection = database['telescope']
telescope_summaries = telescope_collection.find({})


for telescope_entry in telescope_summaries:
    try:
        data = telescope_entry["data"]
        structure_runs = data["structure"]
        camera_runs = data["camera"]
        
        for camera, structure in zip(camera_runs, structure_runs):
            source_name = structure["target"]["name"]
            # wobble = structure["target"]["wobble"]
            run_number = camera["run_number"]
            print(run_number, source_name) #, wobble)
    except (KeyError, TypeError) as err:
        print(f'Failed fetching observation info from entry: {err!r}')