Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear all CI checks on all platforms #402

Merged
merged 38 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9637fb4
Apply all safe ruff fixes
glopesdev Sep 6, 2024
97389bd
Black formatting
glopesdev Sep 6, 2024
e60b766
Move top-level linter settings to lint section
glopesdev Sep 6, 2024
d2a5104
Ignore missing docs in __init__ and magic methods
glopesdev Sep 6, 2024
743324a
Apply ruff recommendations to low-level API
glopesdev Sep 6, 2024
257d9cd
Ignore missing docs for module, package and tests
glopesdev Sep 6, 2024
e4fe028
Ignore missing docs for schema classes and streams
glopesdev Sep 6, 2024
0927a9a
Apply more ruff recommendations to low-level API
glopesdev Sep 6, 2024
be5d3c1
Update pre-commit-config
lochhh Apr 26, 2024
38aeeba
Remove black dependency
lochhh Apr 26, 2024
53e88c2
Temporarily disable ruff and pyright in pre-commit
lochhh Sep 12, 2024
6798e07
Auto-fix mixed lined endings and trailing whitespace
lochhh Sep 12, 2024
cc9c924
Ruff autofix
lochhh Sep 12, 2024
f225406
Fix D103 Missing docstring in public function
lochhh Sep 12, 2024
c7e74f7
Fix D415 First line should end with a period, question mark, or excla…
lochhh Sep 12, 2024
d9d0287
Ignore deprecated PT004
lochhh Sep 12, 2024
c866ab9
Fix D417 Missing argument description in the docstring
lochhh Sep 12, 2024
75af9b8
Ignore E741 check for `h, l, s` assignment
lochhh Sep 12, 2024
12abfcb
Use redundant import alias as suggested in F401
lochhh Sep 12, 2024
a5d88a2
Re-enable ruff in pre-commit
lochhh Sep 12, 2024
7fe4837
Re-enable pyright in pre-commit
lochhh Sep 12, 2024
b0714ab
Configure ruff to ignore .ipynb files
lochhh Sep 12, 2024
68e4344
Remove ruff `--config` in build_env_run_tests workflow
lochhh Sep 12, 2024
038f118
Merge pull request #409 from SainsburyWellcomeCentre/lint-format
glopesdev Sep 13, 2024
9c9a88b
Merge remote-tracking branch 'origin/main' into gl-ruff-check
glopesdev Sep 18, 2024
df20e9f
Apply remaining ruff recommendations
glopesdev Sep 18, 2024
6e64c83
Exclude venv folder from pyright checks
glopesdev Sep 19, 2024
8d0c03f
Remove obsolete and unused qc module
glopesdev Sep 19, 2024
97bc21c
Apply pyright recommendations
glopesdev Sep 19, 2024
6bacc43
Disable useLibraryCodeForTypes
glopesdev Sep 19, 2024
d1180a8
Remove unused function call
glopesdev Sep 19, 2024
23c440f
Ensure all roots are Path objects
glopesdev Sep 19, 2024
5dfd4a4
Exclude dj_pipeline tests from online CI
glopesdev Sep 19, 2024
f557c48
Exclude dj_pipeline tests from coverage report
glopesdev Sep 19, 2024
81bbfa1
Fix macOS wheel build for `datajoint` (Issue #249) (#406)
MilagrosMarin Sep 20, 2024
a678b8d
Run CI checks using pip env and pyproject.toml
glopesdev Sep 20, 2024
2107691
Run code checks and tests on all platforms
glopesdev Sep 20, 2024
1de5c25
Activate venv for later steps and remove all conda dependencies (#413)
lochhh Sep 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions aeon/analysis/block_plotting.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import os
import pathlib
from colorsys import hls_to_rgb, rgb_to_hls
from contextlib import contextmanager
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly
import plotly.express as px
import plotly.graph_objs as go
import seaborn as sns
from numpy.lib.stride_tricks import as_strided

"""Standardize subject colors, patch colors, and markers."""

Expand All @@ -35,27 +25,21 @@
"star",
]
patch_markers_symbols = ["●", "⧓", "■", "⧗", "♦", "✖", "×", "▲", "★"]
patch_markers_dict = {
marker: symbol for marker, symbol in zip(patch_markers, patch_markers_symbols)
}
patch_markers_dict = dict(zip(patch_markers, patch_markers_symbols, strict=False))
patch_markers_linestyles = ["solid", "dash", "dot", "dashdot", "longdashdot"]


def gen_hex_grad(hex_col, vals, min_l=0.3):
"""Generates an array of hex color values based on a gradient defined by unit-normalized values."""
# Convert hex to rgb to hls
h, l, s = rgb_to_hls(
*[int(hex_col.lstrip("#")[i: i + 2], 16) / 255 for i in (0, 2, 4)]
)
h, l, s = rgb_to_hls(*[int(hex_col.lstrip("#")[i : i + 2], 16) / 255 for i in (0, 2, 4)])
grad = np.empty(shape=(len(vals),), dtype="<U10") # init grad
for i, val in enumerate(vals):
cur_l = (l * val) + (
min_l * (1 - val)
) # get cur lightness relative to `hex_col`
cur_l = (l * val) + (min_l * (1 - val)) # get cur lightness relative to `hex_col`
cur_l = max(min(cur_l, l), min_l) # set min, max bounds
cur_rgb_col = hls_to_rgb(h, cur_l, s) # convert to rgb
cur_hex_col = "#%02x%02x%02x" % tuple(
int(c * 255) for c in cur_rgb_col
cur_hex_col = "#{:02x}{:02x}{:02x}".format(
*tuple(int(c * 255) for c in cur_rgb_col)
) # convert to hex
grad[i] = cur_hex_col

Expand Down
18 changes: 11 additions & 7 deletions aeon/analysis/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@


def gridframes(frames, width, height, shape=None):
"""Arranges a set of frames into a grid layout with the specified
pixel dimensions and shape.
"""Arranges a set of frames into a grid layout with the specified pixel dimensions and shape.

:param list frames: A list of frames to include in the grid layout.
:param int width: The width of the output grid image, in pixels.
Expand Down Expand Up @@ -65,7 +64,7 @@ def groupframes(frames, n, fun):
i = i + 1


def triggerclip(data, events, before=pd.Timedelta(0), after=pd.Timedelta(0)):
def triggerclip(data, events, before=None, after=None):
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
"""Split video data around the specified sequence of event timestamps.

:param DataFrame data:
Expand All @@ -76,10 +75,16 @@ def triggerclip(data, events, before=pd.Timedelta(0), after=pd.Timedelta(0)):
:return:
A pandas DataFrame containing the frames, clip and sequence numbers for each event timestamp.
"""
if before is not pd.Timedelta:
if before is None:
before = pd.Timedelta(0)
elif before is not pd.Timedelta:
before = pd.Timedelta(before)
if after is not pd.Timedelta:

if after is None:
after = pd.Timedelta(0)
elif after is not pd.Timedelta:
after = pd.Timedelta(after)
glopesdev marked this conversation as resolved.
Show resolved Hide resolved

if events is not pd.Index:
events = events.index

Expand Down Expand Up @@ -107,8 +112,7 @@ def collatemovie(clipdata, fun):


def gridmovie(clipdata, width, height, shape=None):
"""Collates a set of video clips into a grid movie with the specified pixel dimensions
and grid layout.
"""Collates a set of video clips into a grid movie with the specified pixel dimensions and grid layout.

:param DataFrame clipdata:
A pandas DataFrame where each row specifies video path, frame number, clip and sequence number.
Expand Down
17 changes: 11 additions & 6 deletions aeon/analysis/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from matplotlib import colors
from matplotlib.collections import LineCollection

from aeon.analysis.utils import *
from aeon.analysis.utils import rate, sessiontime
glopesdev marked this conversation as resolved.
Show resolved Hide resolved


def heatmap(position, frequency, ax=None, **kwargs):
Expand Down Expand Up @@ -60,16 +60,17 @@ def rateplot(
ax=None,
**kwargs,
):
"""Plot the continuous event rate and raster of a discrete event sequence, given the specified
window size and sampling frequency.
"""Plot the continuous event rate and raster of a discrete event sequence.

The window size and sampling frequency can be specified.

:param Series events: The discrete sequence of events.
:param offset window: The time period of each window used to compute the rate.
:param DateOffset, Timedelta or str frequency: The sampling frequency for the continuous rate.
:param number, optional weight: A weight used to scale the continuous rate of each window.
:param datetime, optional start: The left bound of the time range for the continuous rate.
:param datetime, optional end: The right bound of the time range for the continuous rate.
:param datetime, optional smooth: The size of the smoothing kernel applied to the continuous rate output.
:param datetime, optional smooth: The size of the smoothing kernel applied to the rate output.
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
:param DateOffset, Timedelta or str, optional smooth:
The size of the smoothing kernel applied to the continuous rate output.
:param bool, optional center: Specifies whether to center the convolution kernels.
Expand Down Expand Up @@ -108,8 +109,8 @@ def colorline(
x,
y,
z=None,
cmap=plt.get_cmap("copper"),
norm=plt.Normalize(0.0, 1.0),
cmap=None,
norm=None,
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
ax=None,
**kwargs,
):
Expand All @@ -128,6 +129,10 @@ def colorline(
ax = plt.gca()
if z is None:
z = np.linspace(0.0, 1.0, len(x))
if cmap is None:
cmap = plt.get_cmap("copper")
if norm is None:
norm = plt.Normalize(0.0, 1.0)
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
z = np.asarray(z)
points = np.array([x, y]).T.reshape(-1, 1, 2)
segments = np.concatenate([points[:-1], points[1:]], axis=1)
Expand Down
21 changes: 12 additions & 9 deletions aeon/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@


def distancetravelled(angle, radius=4.0):
"""Calculates the total distance travelled on the wheel, by taking into account
its radius and the total number of turns in both directions across time.
"""Calculates the total distance travelled on the wheel.

Takes into account the wheel radius and the total number of turns in both directions across time.

:param Series angle: A series of magnetic encoder measurements.
:param float radius: The radius of the wheel, in metric units.
Expand All @@ -22,10 +23,11 @@ def distancetravelled(angle, radius=4.0):


def visits(data, onset="Enter", offset="Exit"):
"""Computes duration, onset and offset times from paired events. Allows for missing data
by trying to match event onset times with subsequent offset times. If the match fails,
event offset metadata is filled with NaN. Any additional metadata columns in the data
frame will be paired and included in the output.
"""Computes duration, onset and offset times from paired events.

Allows for missing data by trying to match event onset times with subsequent offset times.
If the match fails, event offset metadata is filled with NaN. Any additional metadata columns
in the data frame will be paired and included in the output.

:param DataFrame data: A pandas data frame containing visit onset and offset events.
:param str, optional onset: The label used to identify event onsets.
Expand Down Expand Up @@ -69,16 +71,17 @@ def visits(data, onset="Enter", offset="Exit"):


def rate(events, window, frequency, weight=1, start=None, end=None, smooth=None, center=False):
"""Computes the continuous event rate from a discrete event sequence, given the specified
window size and sampling frequency.
"""Computes the continuous event rate from a discrete event sequence.

The window size and sampling frequency can be specified.

:param Series events: The discrete sequence of events.
:param offset window: The time period of each window used to compute the rate.
:param DateOffset, Timedelta or str frequency: The sampling frequency for the continuous rate.
:param number, optional weight: A weight used to scale the continuous rate of each window.
:param datetime, optional start: The left bound of the time range for the continuous rate.
:param datetime, optional end: The right bound of the time range for the continuous rate.
:param datetime, optional smooth: The size of the smoothing kernel applied to the continuous rate output.
:param datetime, optional smooth: The size of the smoothing kernel applied to the rate output.
:param DateOffset, Timedelta or str, optional smooth:
The size of the smoothing kernel applied to the continuous rate output.
:param bool, optional center: Specifies whether to center the convolution kernels.
Expand Down
5 changes: 2 additions & 3 deletions aeon/dj_pipeline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ def dict_to_uuid(key) -> uuid.UUID:


def fetch_stream(query, drop_pk=True):
"""
Provided a query containing data from a Stream table,
fetch and aggregate the data into one DataFrame indexed by "time"
"""Provided a query containing data from a Stream table,
fetch and aggregate the data into one DataFrame indexed by "time"
"""
df = (query & "sample_count > 0").fetch(format="frame").reset_index()
cols2explode = [
Expand Down
4 changes: 1 addition & 3 deletions aeon/dj_pipeline/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,7 @@ def _match_experiment_directory(experiment_name, path, directories):


def create_chunk_restriction(experiment_name, start_time, end_time):
"""
Create a time restriction string for the chunks between the specified "start" and "end" times
"""
"""Create a time restriction string for the chunks between the specified "start" and "end" times"""
start_restriction = f'"{start_time}" BETWEEN chunk_start AND chunk_end'
end_restriction = f'"{end_time}" BETWEEN chunk_start AND chunk_end'
start_query = Chunk & {"experiment_name": experiment_name} & start_restriction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@
"computer = \"AEON3\"\n",
"\n",
"acquisition.Experiment.Directory.insert1(\n",
" {\n",
" \"experiment_name\": experiment_name,\n",
" \"repository_name\": \"ceph_aeon\",\n",
" \"directory_type\": \"raw\",\n",
" \"directory_path\": f\"aeon/data/raw/{computer}/social0.1\"\n",
" },\n",
" {\n",
" \"experiment_name\": experiment_name,\n",
" \"repository_name\": \"ceph_aeon\",\n",
" \"directory_type\": \"raw\",\n",
" \"directory_path\": f\"aeon/data/raw/{computer}/social0.1\",\n",
" },\n",
" skip_duplicates=True,\n",
")\n",
"\n",
Expand All @@ -315,12 +315,12 @@
"computer = \"AEON4\"\n",
"\n",
"acquisition.Experiment.Directory.insert1(\n",
" {\n",
" \"experiment_name\": experiment_name,\n",
" \"repository_name\": \"ceph_aeon\",\n",
" \"directory_type\": \"raw\",\n",
" \"directory_path\": f\"aeon/data/raw/{computer}/social0.1\"\n",
" },\n",
" {\n",
" \"experiment_name\": experiment_name,\n",
" \"repository_name\": \"ceph_aeon\",\n",
" \"directory_type\": \"raw\",\n",
" \"directory_path\": f\"aeon/data/raw/{computer}/social0.1\",\n",
" },\n",
" skip_duplicates=True,\n",
")\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions aeon/dj_pipeline/docs/notebooks/diagram.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
],
"source": [
"_db_prefix = 'aeon_'\n",
"_db_prefix = \"aeon_\"\n",
"\n",
"lab = dj.create_virtual_module(\"lab\", _db_prefix + \"lab\")\n",
"subject = dj.create_virtual_module(\"subject\", _db_prefix + \"subject\")\n",
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -488,7 +488,7 @@
" + acquisition.FoodPatchWheel\n",
" + acquisition.FoodPatchEvent\n",
" + acquisition.WheelState\n",
" + acquisition.EventType \n",
" + acquisition.EventType\n",
" + acquisition.WeightMeasurement\n",
" + qc.CameraQC\n",
" + tracking.CameraTracking.Object\n",
Expand Down Expand Up @@ -857,7 +857,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"datajoint_analysis_diagram.svg datajoint_overview_diagram.svg \u001B[0m\u001B[01;34mnotebooks\u001B[0m/\r\n"
"datajoint_analysis_diagram.svg datajoint_overview_diagram.svg \u001b[0m\u001b[01;34mnotebooks\u001b[0m/\r\n"
]
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"execution_count": null,
"outputs": [],
"source": [
"analysis_vm = dj.create_virtual_module('aeon_block_analysis', 'aeon_block_analysis')"
"analysis_vm = dj.create_virtual_module(\"aeon_block_analysis\", \"aeon_block_analysis\")"
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
],
"metadata": {
"collapsed": false,
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -83,7 +83,7 @@
"outputs": [],
"source": [
"# Pick a block of interest\n",
"block_key = {'experiment_name': 'social0.1-aeon3', 'block_start': '2023-11-30 18:49:05.001984'}"
"block_key = {\"experiment_name\": \"social0.1-aeon3\", \"block_start\": \"2023-11-30 18:49:05.001984\"}"
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
],
"metadata": {
"collapsed": false,
Expand Down
3 changes: 2 additions & 1 deletion aeon/dj_pipeline/populate/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def ingest_environment_visits():
"""Extract and insert complete visits for experiments specified in AutomatedExperimentIngestion."""
experiment_names = AutomatedExperimentIngestion.fetch("experiment_name")
# analysis.ingest_environment_visits(experiment_names)
pass


# ---- Define worker(s) ----
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -111,6 +110,8 @@ def ingest_environment_visits():
analysis_worker(block_analysis.BlockSubjectAnalysis, max_calls=6)
analysis_worker(block_analysis.BlockSubjectPlots, max_calls=6)


def get_workflow_operation_overview():
from datajoint_utilities.dj_worker.utils import get_workflow_operation_overview

glopesdev marked this conversation as resolved.
Show resolved Hide resolved
return get_workflow_operation_overview(worker_schema_name=worker_schema_name, db_prefixes=[db_prefix])
2 changes: 1 addition & 1 deletion aeon/dj_pipeline/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def make(self, key):
"devices_schema_name"
),
)
stream_reader = getattr(getattr(devices_schema, device_name), "Video")
stream_reader = getattr(devices_schema, device_name).Video
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
glopesdev marked this conversation as resolved.
Show resolved Hide resolved

videodata = io_api.load(
root=data_dirs,
Expand Down
1 change: 1 addition & 0 deletions aeon/dj_pipeline/scripts/clone_and_freeze_exp01.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""March 2022
Cloning and archiving schemas and data for experiment 0.1.
"""

import os

import datajoint as dj
Expand Down
10 changes: 5 additions & 5 deletions aeon/dj_pipeline/scripts/clone_and_freeze_exp02.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The pipeline code associated with this archived data pipeline is here
https://github.com/SainsburyWellcomeCentre/aeon_mecha/releases/tag/dj_exp02_stable
"""

import os
import inspect
import datajoint as dj
Expand Down Expand Up @@ -57,11 +58,10 @@ def data_copy(restriction, table_block_list, batch_size=None):


def validate():
"""
Validation of schemas migration
1. for the provided list of schema names - validate all schemas have been migrated
2. for each schema - validate all tables have been migrated
3. for each table, validate all entries have been migrated
"""Validation of schemas migration
1. for the provided list of schema names - validate all schemas have been migrated
2. for each schema - validate all tables have been migrated
3. for each table, validate all entries have been migrated
"""
missing_schemas = []
missing_tables = {}
Expand Down
1 change: 1 addition & 0 deletions aeon/dj_pipeline/scripts/update_timestamps_longblob.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""July 2022
Upgrade all timestamps longblob fields with datajoint 0.13.7.
"""

from datetime import datetime

import datajoint as dj
Expand Down
2 changes: 1 addition & 1 deletion aeon/dj_pipeline/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def make(self, key):
"devices_schema_name"
),
)
stream_reader = getattr(getattr(devices_schema, device_name), "Pose")
stream_reader = getattr(devices_schema, device_name).Pose
glopesdev marked this conversation as resolved.
Show resolved Hide resolved
glopesdev marked this conversation as resolved.
Show resolved Hide resolved

pose_data = io_api.load(
root=data_dirs,
Expand Down
Loading
Loading