Commit Graph

101 Commits

Author SHA1 Message Date
D. Berge
a101542bc2 Do not import gun data if sequence has no shots.
Doing otherwise will result in the gun data file
appearing has having been read, but no data will
have been saved as there was nowhere to save to.

Fixes #29.
2020-10-03 00:44:55 +02:00
D. Berge
c013073104 Save deferred import data as a single transaction.
Each of the save_* operations starts a transaction
(which is automatically commited if all goes well).

The main reason for this is to ensure that by the
time raw_lines and final_lines events fire, the
corresponding entries in raw_shots and final_shots
have already been populated.
2020-10-02 19:31:14 +02:00
D. Berge
3c1a5da1a8 Suspend trigger during system data import 2020-09-30 15:39:37 +02:00
D. Berge
19db65c999 Change configuration paths for SSE export 2020-09-30 15:39:10 +02:00
D. Berge
65c26f56c7 Import proper UTF-8.
What's the point of Python defaulting to ASCII
when JSON is explicitly defined as a binary
format with a default character encoding of
UTF-8? 🙄
2020-09-29 17:46:56 +02:00
D. Berge
a05ecfd41c Add functions to export/import specific columns from DB.
Unlike system_imports.py and system_exports.py, which
deal with whole tables via COPY, this allows us to
export / import *either* whole tables or specific
columns only.

The data will be exported to text files containing
the selected columns + the primary key columns for
the table.

When importing, those tables for which a selection
of columns was exported must already be populated.
The import process will overwrite the data of the
non primary key columns it knows about. If whole
tables are exported, on the other hand, when
re-importing rows will be appended rather than
updated. It is the user's responsibility to make
sure that this will not cause any conflicts.
2020-09-27 19:29:48 +02:00
D. Berge
a7b4b70d59 Remove spurious semicolon 2020-09-27 19:19:19 +02:00
D. Berge
3bd8cbe860 Handle projects for which there is (yet) no QC data 2020-09-27 19:18:19 +02:00
D. Berge
5a74953739 Add vars() method to configuration.py.
Returns some shell variables that are used
by various deferred import processes.
2020-09-27 19:16:44 +02:00
D. Berge
303befef3b Add human exports to runner 2020-09-26 23:41:09 +02:00
D. Berge
4e70090b40 Export structured sequence data to JSON files.
Script meant to be run by runner.sh.

It will not overwrite existing files. If a
sequence is modified after the first export,
the resulting file needs to be removed by the
user before a re-export will occur.

The idea is to eventually export on demand
when a new raw is added to final_lines.
2020-09-26 22:57:36 +02:00
D. Berge
0e5e54b680 Ensure views are synchronised after re-import 2020-09-23 15:48:42 +02:00
D. Berge
6b52383056 Reset sequences after re-import 2020-09-23 15:48:21 +02:00
D. Berge
97104556b7 Do not hard fail if imports fail for one project.
It may be the case that we have already re-imported
some of the data, so we just move on to the next
project.
2020-09-23 15:46:17 +02:00
D. Berge
c9b9a009af Speed up the events view.
We do this with the help of some denormalisation
and a handy trigger.

Closes #35.
2020-09-14 03:01:55 +02:00
D. Berge
b5b91d41c9 Reset event serial ids after re-import.
When the database is recreated, the sequences
used in the events_timed and events_seq tables
will be at their initial values, which will
almost certainly conflict with existing data
when it is imported via COPY.

With this commit, we set the current value for
those sequences to something usable.

Fixes #33.
2020-09-14 01:36:40 +02:00
D. Berge
606f1b8125 Export QC results to text files.
Script meant to be run by runner.sh, either directly
or via an intermediate script that consolidates all
the user outputs in one place.
2020-09-10 23:24:11 +02:00
D. Berge
d192eb3668 Add CRUD operations for project info table 2020-09-10 20:39:06 +02:00
D. Berge
3b5b200f08 Change address of system exports path 2020-09-10 20:37:52 +02:00
D. Berge
351d2a474b Fix NTBP detection.
Fixes #25.
2020-09-08 18:36:30 +02:00
D. Berge
19ce158329 Import SmartSource header data.
Provided that the SmartSource headers are being
saved to file, and that the path to those files
is present in the survey configuration, we now
import SmartSource information as metadata in
raw_shots.meta->'smsrc'.

Closes #19.
2020-09-06 13:45:56 +02:00
D. Berge
c6285e881e Add function to delete data by file hash 2020-09-06 13:38:37 +02:00
D. Berge
1124a48e8c Add function to convert regex flags string to Python 2020-09-06 13:33:32 +02:00
D. Berge
0fc795d1c4 Add commit after copy_from calls 2020-09-03 17:08:25 +02:00
D. Berge
0cd1b30e29 Let create_survey take an explicity schema name 2020-09-02 18:57:42 +02:00
D. Berge
f708410e47 Conditionally enable / disable system import / export 2020-09-02 15:05:43 +02:00
D. Berge
a8830c9a05 Add system data import module 2020-09-02 15:05:43 +02:00
D. Berge
cf477c921e Add data export task to bin/runner.sh 2020-09-02 09:08:10 +02:00
D. Berge
4c103fafca Add system data export module.
It exports the data that is entered directly into
Dougal as opposed to being read from an external
source.

As of this commit, not all direct data is exported.
Specifically, sequence comments (raw and final),
sequence and shot NTBA and shot NTBP statuses are not
exported.
2020-09-02 09:07:06 +02:00
D. Berge
1fc069a0bd Fix path to NTBP regexp pattern 2020-09-01 10:59:29 +02:00
D. Berge
c4c09f0a9d Delete online data before importing sequence.
The deferred import routing will delete any online
data for any raw sequences that it imports.
2020-08-31 13:09:57 +02:00
D. Berge
5363ce8bab Handle NTBP flags in raw data.
This works by matching a regular expression against
the full path name (not just the file name). If it
matches, the NTBP flag is set to true.
2020-08-31 13:04:46 +02:00
D. Berge
c32c408d12 Import .profile into runner.sh.
So that it has access to the right environment
when run by cron.
2020-08-31 12:57:55 +02:00
D. Berge
54a717dc91 Do not fail hard if preplots do not exist.
They might not have been done yet, and it will be obvious
to the user if they're not there.
2020-08-29 13:14:20 +02:00
D. Berge
71e0326141 Add missing import 2020-08-29 10:40:55 +02:00
D. Berge
91d4059cdf Make send_alert usable as a module 2020-08-28 17:33:32 +02:00
D. Berge
22f806e81e Warn on import problems.
If there is a problem with files matching the capture
globs but not matching the file name regexp patterns,
these routines will emit a message to stderr and skip
the non-matching file.
2020-08-28 17:31:25 +02:00
D. Berge
639ac237e3 Replace Python globbing library.
This was motivated by the need to recurse down paths.
2020-08-28 13:49:43 +02:00
D. Berge
0c7b3146ae Update label definitions when updating survey config.
It will not delete any labels that have been removed
from the configuration, as those may be used, but it
will add new labels and modify existing ones if they
changed.
2020-08-25 17:52:17 +02:00
D. Berge
3ce6f1dce6 Add tasks runner script.
This script runs the deferred imports. It is meant to
be called from a cronjob at regular intervals – every
one or two minutes is probably a good setting.

It checks if another instance is already running before
doing its thing.

If anything goes wrong (any of the called processes exits
with non-zero condition) it will send an alert to GitLab,
provided that the authorisation key is known.
2020-08-24 21:01:47 +02:00
D. Berge
b4b06c8744 Instrument alerts for deferred imports.
In case of errors (or anything else of note), send_alert.py
can be used to push information to a GitLab alerts endpoint.

It is generic enough that it can be used with anything else, though.
2020-08-24 20:02:12 +02:00
D. Berge
bc784989f6 Make P1 imports not fail if called needlessly.
If their respective configuration keys are not
defined in a survey configuration, the import
routines will print an informational message
and exit successfully.
2020-08-24 19:45:59 +02:00
D. Berge
f2373a0454 Use environment variables for DB connection if possible 2020-08-12 18:18:47 +02:00
D. Berge
b1a088da36 Prefer environment variables to connect to DB 2020-08-12 14:38:31 +02:00
D. Berge
9c58ec30b5 Add function to import final P1/11.
Based on the analogous import_final_p190.py code.
2020-08-10 22:58:31 +02:00
D. Berge
3755564414 Add function to import raw P1/11.
Based on the analogous import_raw_p190.py code.
2020-08-10 22:58:31 +02:00
D. Berge
4c54b7002a Add DB functions to save raw and final data from P1/11 2020-08-10 22:58:31 +02:00
D. Berge
b36c8b97d1 Add P1/11 parsing Python library.
This is a super-simple library that does the minimum required
to get things going for the specific operations where this
code is foreseen to be used in the immediate future. It is not
and it does not aim to be a complete, generic or universal P1/11
parsing solution.
2020-08-10 22:50:07 +02:00
D. Berge
a0faa51602 Fix PREFIX usage 2020-08-10 22:41:37 +02:00
D. Berge
ed6b051669 Add DOUGAL_ROOT environment variable support.
When searching for configuration files, we look in the
following places:

1. $DOUGAL_ROOT/etc/
2. $HOME/software/etc/
3. ./software/etc/
2020-08-09 16:43:51 +02:00