Skip to content

Commit

Permalink
Bump [skip actions]
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 1, 2024
1 parent 11aaf3b commit 85caa3b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 33 deletions.
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
<!-- insertion marker -->
## Unreleased

<small>[Compare with latest](https://github.com/AllenInstitute/npc_lims/compare/v0.1.175...HEAD)</small>
<small>[Compare with latest](https://github.com/AllenInstitute/npc_lims/compare/v0.1.176...HEAD)</small>

### Added

- Add sessions from notebook ([cd40392](https://github.com/AllenInstitute/npc_lims/commit/cd40392c77a6ca66c12c2111e893d4f04b884e08) by bjhardcastle).

### Fixed

- Fix previous ([f12d318](https://github.com/AllenInstitute/npc_lims/commit/f12d3184042d16e98918a4f64b62fefbe24ea77c) by bjhardcastle).
- Fix type ([11aaf3b](https://github.com/AllenInstitute/npc_lims/commit/11aaf3b36b4e396127748b535d57f0e4897c90a0) by bjhardcastle).
- Fix getting `is_templeton` from tracked_sessions.yaml ([05e9d84](https://github.com/AllenInstitute/npc_lims/commit/05e9d848d998154b9da7ac545a28f19169200ced) by bjhardcastle).

### Removed

- Remove duplicate sessions ([c90c4d0](https://github.com/AllenInstitute/npc_lims/commit/c90c4d0c78f3de5999cec9d86dfbc3b95e5d2091) by bjhardcastle).
- Remove hard-coded sorted data asset for session ([95dec71](https://github.com/AllenInstitute/npc_lims/commit/95dec71033c9bda9064f818060fb0d01a61f368c) by bjhardcastle).

<!-- insertion marker -->
## [v0.1.176](https://github.com/AllenInstitute/npc_lims/releases/tag/v0.1.176) - 2024-09-21

<small>[Compare with v0.1.175](https://github.com/AllenInstitute/npc_lims/compare/v0.1.175...v0.1.176)</small>

### Fixed

- Fix previous ([f12d318](https://github.com/AllenInstitute/npc_lims/commit/f12d3184042d16e98918a4f64b62fefbe24ea77c) by bjhardcastle).

## [v0.1.175](https://github.com/AllenInstitute/npc_lims/releases/tag/v0.1.175) - 2024-09-18

<small>[Compare with v0.1.174](https://github.com/AllenInstitute/npc_lims/compare/v0.1.174...v0.1.175)</small>
Expand Down
2 changes: 1 addition & 1 deletion npc_lims
Submodule npc_lims updated from f12d31 to 11aaf3
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "npc_lims"
version = "0.1.176"
version = "0.1.177"
description = "Tools to fetch and update paths, metadata and state for Mindscope Neuropixels sessions, in the cloud."
authors = [
{ name = "Arjun Sridhar", email = "[email protected]" },
Expand Down
71 changes: 42 additions & 29 deletions src/npc_lims/status/tracked_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,14 @@ def _get_session_info_from_file(ttl_hash: int | None = None) -> tuple[SessionInf
f"Add loader for {_TRACKED_SESSIONS_FILE.suffix}"
) # pragma: no cover


def _add_session_to_file(
platform: Literal['ephys', 'behavior', 'behavior_with_sync'],
project: Literal['DynamicRouting', 'TempletonPilotSession'],
k: str, v: dict[str, Any],
platform: Literal["ephys", "behavior", "behavior_with_sync"],
project: Literal["DynamicRouting", "TempletonPilotSession"],
k: str,
v: dict[str, Any],
) -> None:
f = yaml.load(
_TRACKED_SESSIONS_FILE.read_bytes(), Loader=yaml.FullLoader
)
f = yaml.load(_TRACKED_SESSIONS_FILE.read_bytes(), Loader=yaml.FullLoader)
if any(k in entry for entry in f[platform][project]):
print(f"Session {k} already exists in {_TRACKED_SESSIONS_FILE} - skipping")
return
Expand All @@ -614,47 +614,60 @@ def _add_session_to_file(
new[platform][project].append({k: v})
new_path.write_text(yaml.dump(new))


def add_tracked_ephys_sessions_from_spreadsheet(
csv_path: str | upath.UPath = "C:/Users/ben.hardcastle/OneDrive - Allen Institute/Shared Documents - Dynamic Routing/Mouse and experiment tracking/Ephys Experiment Tracking.csv"
csv_path: (
str | upath.UPath
) = "C:/Users/ben.hardcastle/OneDrive - Allen Institute/Shared Documents - Dynamic Routing/Mouse and experiment tracking/Ephys Experiment Tracking.csv",
) -> None:
try:
import polars as pl
except ImportError:
raise ImportError("Optional dependencies are required to use this function: reinstall with `pip install npc_lims[polars]`")
df = (
pl.read_csv(csv_path, infer_schema_length=1000)
.with_columns(
pl.col('Date').cum_count().over('Mouse').alias("day"),
raise ImportError(
"Optional dependencies are required to use this function: reinstall with `pip install npc_lims[polars]`"
)
df = pl.read_csv(csv_path, infer_schema_length=1000).with_columns(
pl.col("Date").cum_count().over("Mouse").alias("day"),
)
upath.UPath("new_sessions.yaml").unlink(missing_ok=True)
project = 'DynamicRouting'
platform = 'ephys'
project = "DynamicRouting"
platform = "ephys"
for row in df.iter_rows(named=True):
info = {}
session_kwargs = {}
dc = row['Date'].split('/')
date: str = f"{dc[2]}{'0' if len(dc[0])<2 else ''}{dc[0]}{'0' if len(dc[1]) < 2 else ''}{dc[1]}"
dc = row["Date"].split("/")
date: str = (
f"{dc[2]}{'0' if len(dc[0])<2 else ''}{dc[0]}{'0' if len(dc[1]) < 2 else ''}{dc[1]}"
)
session_id = f"{row['Mouse']}_{date}"
k: str = f'//allen/programs/mindscope/workgroups/dynamicrouting/PilotEphys/Task 2 pilot/DRpilot_{row["Mouse"]}_{date}'
probes = ''.join(npc_session.extract_probe_letter(v) or '' for v in row['Probes in brain'])
k: str = (
f'//allen/programs/mindscope/workgroups/dynamicrouting/PilotEphys/Task 2 pilot/DRpilot_{row["Mouse"]}_{date}'
)
probes = "".join(
npc_session.extract_probe_letter(v) or "" for v in row["Probes in brain"]
)
if not probes:
print(f"Skipping {session_id} - no probes")
continue
session_kwargs['probe_letters_to_skip'] = ''.join(letter for letter in 'ABCDEF' if letter not in probes)
if (x := row.get('Injection substance', '')) or row.get('is perturbation experiment', None) is not None:
session_kwargs["probe_letters_to_skip"] = "".join(
letter for letter in "ABCDEF" if letter not in probes
)
if (x := row.get("Injection substance", "")) or row.get(
"is perturbation experiment", None
) is not None:
if x:
if 'control' in x.lower() or 'acsf' in x.lower():
session_kwargs['is_injection_control'] = True # type: ignore [assignment]
if "control" in x.lower() or "acsf" in x.lower():
session_kwargs["is_injection_control"] = True # type: ignore [assignment]
else:
session_kwargs['is_injection_perturbation'] = True # type: ignore [assignment]
session_kwargs["is_injection_perturbation"] = True # type: ignore [assignment]
else:
session_kwargs['is_perturbation'] = 'unknown_type'

info['day'] = row['day']
info['session_kwargs'] = session_kwargs
_add_session_to_file(platform, project, k, info) # type: ignore [arg-type]

session_kwargs["is_perturbation"] = "unknown_type"

info["day"] = row["day"]
info["session_kwargs"] = session_kwargs
_add_session_to_file(platform, project, k, info) # type: ignore [arg-type]


def _session_info_from_file_contents(contents: FileContents) -> tuple[SessionInfo, ...]:
sessions: MutableSequence[SessionInfo] = []
for session_type, projects in contents.items():
Expand Down

0 comments on commit 85caa3b

Please sign in to comment.