Skip to content
Snippets Groups Projects
Verified Commit bf49fc04 authored by David Hoese's avatar David Hoese
Browse files

Update for InfluxDB v2

parent 85ea3778
No related branches found
No related tags found
No related merge requests found
# Mendota Buoy Processing
## Create operation processing conda environment
On rain01:
```bash
# log in as root
sudo su -
# activate base environment
eval "$(/opt/miniconda3_20200609/bin/conda shell.bash hook)"
# create conda environment
conda create -p /opt/metobs/mendota_buoy -c conda-forge --strict-channel-priority python=3.7 pandas matplotlib netcdf4 h5py sh
# activate new environment
conda activate /opt/metobs/mendota_buoy
# prepare extra directories
cd /opt/metobs/mendota_buoy
mkdir log lock
chmown metobs.metobsgrp log lock
mkdir -p repos/git
# install each package
#git clone https://gitlab.ssec.wisc.edu/metobs/MetObsData.git
#cd MetObsData
#pip install -e . --no-deps
git clone https://gitlab.ssec.wisc.edu/metobs/MetObsCommon.git
cd MetObsCommon
pip install -e . --no-deps
git clone https://gitlab.ssec.wisc.edu/metobs/MendotaBuoy.git
cd MendotaBuoy
pip install -e . --no-deps
```
\ No newline at end of file
## Operational conda environment
These instructions assume the operational "standard practice" that is current
at the time of writing. This practice is to create a conda environment using
the "root" user under `/opt/metobs/mendota_buoy`.
1. Get and install the conda environment:
```bash
cd /tmp
curl -O "https://gitlab.ssec.wisc.edu/metobs/MendotaBuoy/-/raw/master/environment.yaml"
sudo /opt/miniconda3/condabin/conda env create --file environment.yaml --prefix /opt/metobs/mendota_buoy
```
2. Clone the git repository into the environment and other setup:
```bash
cd /opt/metobs/mendota_buoy
sudo mkdir -p repos/git log lock
sudo chown metobs:metobsgrp log lock
sudo git clone "https://gitlab.ssec.wisc.edu/metobs/MendotaBuoy.git" repos/git/MendotaBuoy
sudo ln -s repos/git/MendotaBuoy/scripts ./scripts
sudo git clone "https://gitlab.ssec.wisc.edu/metobs/MetObsCommon.git" repos/git/MetObsCommon
```
3. Install the metobsapi python package:
```bash
sudo /opt/metobs/mendota_buoy/bin/pip install -e repos/git/MetObsCommon/
sudo /opt/metobs/mendota_buoy/bin/pip install -e repos/git/MendotaBuoy/
```
4. Copy `etc` files from MetObsCommon if necessary:
```bash
sudo cp repos/git/MetObsCommon/etc/... /etc/...
```
name: mendota_buoy
channels:
- conda-forge
dependencies:
- influxdb-client
- matplotlib
- netcdf4
- numpy
- pandas
- pytest
- requests
- sh
- python=3.11
......@@ -107,6 +107,7 @@ def convert_to_influx_frame(record_gen, symbols, debug=False):
def main():
import argparse
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
influxdb.add_influxdb_command_line_arguments(parser)
parser.add_argument('--logfn', help='Log to rotating file (Not Implemented)')
parser.add_argument('--debug', action='store_true',
help='Don\'t submit records to the database, print them to stdout')
......@@ -119,12 +120,6 @@ def main():
'(port: 1024)')
parser.add_argument('--tables', nargs='*', default=['metdata', 'limnodata'],
help="LoggerNet LDMP tables to read in")
parser.add_argument("--host", default=influxdb.DB_HOST,
help="Hostname of database connection")
parser.add_argument("--port", default=influxdb.DB_PORT,
help="Port of database connection")
parser.add_argument("--dbname", default=influxdb.DB_NAME,
help="Name of database to modify")
parser.add_argument('-s', '--station', dest='station', default='Mendota Buoy', choices=STATIONS.keys(),
help='Name of station to use to determine symbols')
parser.add_argument('-v', '--verbose', dest='verbosity', action="count", default=0,
......@@ -145,6 +140,7 @@ def main():
LOG.info("source: %s", args.src)
LOG.info("tail: %s", args.tail)
station_tags = STATIONS[args.station]
influxdb_conn_params = influxdb.convert_influxdb_args_to_kwargs(args)
if args.ldmp:
from mendotabuoy.level_00.metdata import LDMPGenerator
......@@ -168,7 +164,7 @@ def main():
influx_gen = influxdb.grouper(influx_gen, args.bulk)
for record in influx_gen:
lines = influxdb.frame_records(record, **station_tags)
influxdb.insert(lines, host=args.host, port=args.port, dbname=args.dbname)
influxdb.insert(lines, influxdb_conn_params)
if args.sleep_interval:
time.sleep(args.sleep_interval)
......
......@@ -16,6 +16,6 @@ SCRN=$(screen -list | grep $NAME | awk '{print $1}')
if [ -n "$SCRN" ]; then
echo Screen already running: $SCRN
else
screen -S $NAME -d -m $PYENV/bin/python -m mendotabuoy.level_00.influxdb -vvv --ldmp MendotaBuoy
screen -S $NAME -d -m $PYENV/bin/python -m mendotabuoy.level_00.influxdb -vvv --influxdb-token $(</home/metobs/influxdbv2_metobs_rw.txt) --ldmp MendotaBuoy
echo Started in screen $(screen -list | grep $NAME | awk '{print $1}')
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment