Skip to content

Commit

Permalink
Merge pull request #117 from simonsobs/develop
Browse files Browse the repository at this point in the history
Release v0.1.0
  • Loading branch information
BrianJKoopman authored Oct 30, 2020
2 parents 4d6976b + d4ae11d commit 4dac21c
Show file tree
Hide file tree
Showing 51 changed files with 2,485 additions and 122 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ jobs:
# Fetch all history for all tags and branches
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

# Test
# Test (steps from pytest workflow)
- name: Build docker images
run: |
docker-compose build
Expand All @@ -23,6 +27,19 @@ jobs:
run: |
docker run -v $PWD:/coverage --rm socs sh -c "COVERAGE_FILE=/coverage/.coverage.docker python3 -m pytest -p no:wampy --cov /app/socs/socs/ ./tests/"
- name: Report test coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install coveralls
coverage combine
coverage report
coveralls
- name: Test documentation build
run: |
docker run --rm socs sh -c "make -C docs/ html"
# Dockerize
- name: Build and push development docker image
env:
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/official-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,25 @@ jobs:
# Fetch all history for all tags and branches
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

# Test
# Build
- name: Build docker images
run: |
docker-compose build
# Test (already been run by pytest workflow, but they don't take long...)
- name: Test with pytest wtihin a docker container
run: |
docker run -v $PWD:/coverage --rm socs sh -c "COVERAGE_FILE=/coverage/.coverage.docker python3 -m pytest -p no:wampy --cov /app/socs/socs/ ./tests/"
- name: Test documentation build
run: |
docker run --rm socs sh -c "make -C docs/ html"
# Dockerize
- name: Build and push official docker image
env:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run Tests

on:
push:
branches-ignore: [ develop ]
pull_request:

jobs:
build:
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Build docker images
run: |
docker-compose build
- name: Test with pytest wtihin a docker container
run: |
docker run -v $PWD:/coverage --rm socs sh -c "COVERAGE_FILE=/coverage/.coverage.docker python3 -m pytest -p no:wampy --cov /app/socs/socs/ ./tests/"
- name: Report test coverage
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pip install coveralls
coverage combine
coverage report
coveralls
- name: Test documentation build
run: |
docker run --rm socs sh -c "make -C docs/ html"
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# A container setup with an installation of socs.

# Use the ocs image as a base
FROM simonsobs/ocs:v0.6.0-67-g5993b6a-dev
FROM simonsobs/ocs:v0.7.1

# Copy the current directory contents into the container at /app
COPY . /app/socs/
Expand Down
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
SOCS - Simons Observatory Control System
========================================

.. image:: https://travis-ci.com/simonsobs/socs.svg?branch=master
:target: https://travis-ci.com/simonsobs/socs
.. image:: https://img.shields.io/github/workflow/status/simonsobs/socs/Build%20Develop%20Images
:target: https://github.com/simonsobs/socs/actions?query=workflow%3A%22Build+Develop+Images%22
:alt: GitHub Workflow Status

.. image:: https://readthedocs.org/projects/socs/badge/?version=latest
:target: https://socs.readthedocs.io/en/latest/?badge=latest
Expand Down
2 changes: 1 addition & 1 deletion agents/bluefors/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WORKDIR /app/socs/agents/bluefors/
COPY . .

# Run registry on container startup
ENTRYPOINT ["python3", "-u", "bluefors_log_tracker.py"]
ENTRYPOINT ["dumb-init", "python3", "-u", "bluefors_log_tracker.py"]

# Sensible default instance-id
CMD ["--instance-id=bluefors"]
9 changes: 8 additions & 1 deletion agents/bluefors/bluefors_log_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,13 @@ def __init__(self, tracker):
'tc400errorcode_2', 'tc400ovtempelec_2',
'tc400ovtemppump_2', 'tc400setspdatt_2',
'tc400pumpaccel_2', 'tc400commerr_2',
'nxdsf', 'nxdsct', 'nxdst', 'nxdsbs', 'nxdstrs',
'ctrl_pres', 'cpastate', 'cparun', 'cpawarn',
'cpaerr', 'cpatempwi', 'cpatempwo', 'cpatempo',
'cpatemph', 'cpalp', 'cpalpa', 'cpahp', 'cpahpa',
'cpadp', 'cpacurrent', 'cpahours', 'cpapscale',
'cpatscale', 'cpasn', 'cpamodel'],
'cpascale', 'cpatscale', 'cpasn', 'cpamodel',
'ctrl_pres_ok', 'ctr_pressure_ok'],
'heater': ["a1_u", "a1_r_lead", "a1_r_htr", "a2_u",
"a2_r_lead", "a2_r_htr", "htr", "htr_range"]}

Expand Down Expand Up @@ -235,6 +237,11 @@ def _parse_multi_value_log(self, new_line, log_type, log_name):
for pattern in self.patterns[log_type]:
regex = re.compile(rf'{pattern},([0-9\.\+\-E]+)')
m = regex.search(new_line)

# skip patterns that don't exist in this log
if not m:
continue

if log_type == 'channels':
data_array[pattern.replace('-', '_')] = int(m.group(1))
else:
Expand Down
6 changes: 3 additions & 3 deletions agents/cryomech_cpa/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ COPY . /app/socs/agents/cryomech-cpa/

# Run agent on container startup

ENTRYPOINT ["python3", "-u", "cryomech_cpa_agent.py"]
ENTRYPOINT ["dumb-init", "python3", "-u", "cryomech_cpa_agent.py"]

CMD ["--site-hub=ws://sisock-crossbar:8001/ws", \
"--site-http=http://sisock-crossbar:8001/call"]
CMD ["--site-hub=ws://crossbar:8001/ws", \
"--site-http=http://crossbar:8001/call"]
19 changes: 16 additions & 3 deletions agents/labjack/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,23 @@ WORKDIR /app/socs/agents/labjack/

## Copy this agent into the app/agents directory
COPY . .
RUN pip3 install -r requirements.txt

# Install ljm module from labjack, copied from the labjack ljm dockerfile
# located at https://hub.docker.com/r/labjack/ljm/dockerfile
RUN apt-get update
RUN apt-get install -y wget python3-pip libusb-1.0-0-dev udev

RUN wget https://labjack.com/sites/default/files/software/labjack_ljm_minimal_2020_03_30_x86_64_beta.tar.gz
RUN tar zxf ./labjack_ljm_minimal_2020_03_30_x86_64_beta.tar.gz
RUN ./labjack_ljm_minimal_2020_03_30_x86_64/labjack_ljm_installer.run -- --no-restart-device-rules

RUN pip3 install --no-cache-dir https://labjack.com/sites/default/files/software/Python_LJM_2019_04_03.zip


# Run registry on container startup
ENTRYPOINT ["python3", "-u", "labjack_agent.py"]
ENTRYPOINT ["dumb-init", "python3", "-u", "labjack_agent.py"]

# Sensible default arguments
CMD ["--site-hub=ws://sisock-crossbar:8001/ws", \
"--site-http=http://sisock-crossbar:8001/call"]
CMD ["--site-hub=ws://crossbar:8001/ws", \
"--site-http=http://crossbar:8001/call"]
3 changes: 2 additions & 1 deletion agents/labjack/labjack_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __init__(self, agent, ip_address, active_channels, function_file,
if active_channels == 'T7-all':
self.sensors = ['Channel_{}'.format(i+1) for i in range(14)]
elif active_channels == 'T4-all':
self.sensors = ['Channel_{}'.format(i+1) for i in range(12)]
self.sensors = ['Channel_{}'.format(i+1) for i in range(12)]
else:
self.sensors = ['Channel_{}'.format(ch) for ch in active_channels]
self.ljf = LabJackFunctions()
Expand All @@ -167,6 +167,7 @@ def __init__(self, agent, ip_address, active_channels, function_file,
function_file)
with open(function_file_path, 'r') as stream:
self.functions = yaml.safe_load(stream)
print(f"Applying conversion functions: {self.functions}")

self.initialized = False
self.take_data = False
Expand Down
2 changes: 2 additions & 0 deletions agents/labjack/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numexpr
scipy
6 changes: 3 additions & 3 deletions agents/lakeshore240/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WORKDIR /app/socs/agents/lakeshore240/
COPY . .

# Run registry on container startup
ENTRYPOINT ["python3", "-u", "LS240_agent.py"]
ENTRYPOINT ["dumb-init", "python3", "-u", "LS240_agent.py"]

CMD ["--site-hub=ws://sisock-crossbar:8001/ws", \
"--site-http=http://sisock-crossbar:8001/call"]
CMD ["--site-hub=ws://crossbar:8001/ws", \
"--site-http=http://crossbar:8001/call"]
35 changes: 32 additions & 3 deletions agents/lakeshore240/LS240_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ def start_acq(self, session, params=None):
Method to start data acquisition process.
The most recent data collected is stored in session.data in the
structure::
>>> session.data
{"fields":
{"Channel_1": {"T": 99.26, "V": 99.42},
"Channel_2": {"T": 99.54, "V": 101.06},
"Channel_3": {"T": 100.11, "V":100.79},
"Channel_4": {"T": 98.49, "V": 100.77},
"Channel_5": {"T": 97.75, "V": 101.45},
"Channel_6": {"T": 99.58, "V": 101.75},
"Channel_7": {"T": 98.03, "V": 100.82},
"Channel_8": {"T": 101.14, "V":101.01}},
"timestamp":1601925677.6914878}
Args:
sampling_frequency (float):
Sampling frequency for data collection. Defaults to 2.5 Hz
Expand All @@ -218,20 +233,34 @@ def start_acq(self, session, params=None):

self.take_data = True

session.data = {"fields": {}}

while self.take_data:
current_time = time.time()
data = {
'timestamp': time.time(),
'timestamp': current_time,
'block_name': 'temps',
'data': {}
}

for chan in self.module.channels:
# Read sensor on channel
chan_string = "Channel_{}".format(chan.channel_num)
data['data'][chan_string + '_T'] = chan.get_reading(unit='K')
data['data'][chan_string + '_V'] = chan.get_reading(unit='S')
temp_reading = chan.get_reading(unit='K')
sensor_reading = chan.get_reading(unit='S')

# For data feed
data['data'][chan_string + '_T'] = temp_reading
data['data'][chan_string + '_V'] = sensor_reading

# For session.data
field_dict = {chan_string: {"T": temp_reading, "V": sensor_reading}}
session.data['fields'].update(field_dict)

self.agent.publish_to_feed('temperatures', data)

session.data.update({'timestamp': current_time})

time.sleep(sleep_time)

self.agent.feeds['temperatures'].flush_buffer()
Expand Down
6 changes: 3 additions & 3 deletions agents/lakeshore372/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ WORKDIR /app/socs/agents/lakeshore372/
COPY . .

# Run registry on container startup
ENTRYPOINT ["python3", "-u", "LS372_agent.py"]
ENTRYPOINT ["dumb-init", "python3", "-u", "LS372_agent.py"]

# Sensible default arguments
CMD ["--site-hub=ws://sisock-crossbar:8001/ws", \
"--site-http=http://sisock-crossbar:8001/call"]
CMD ["--site-hub=ws://crossbar:8001/ws", \
"--site-http=http://crossbar:8001/call"]
Loading

0 comments on commit 4dac21c

Please sign in to comment.