Skip to main content

User-friendly tools for accessing paths, metadata and assets related to AIND sessions.

Project description

aind-session

User-friendly tools for accessing paths, metadata and assets related to AIND sessions.

PyPI Python version

Coverage CI/CD GitHub issues

Under development!

Please check this out and make feature requests, but don't rely on the API to remain stable just yet..

Aim

This package is meant to provide easy access to session-related stuff required for common tasks in CodeOcean and beyond.

  • when interacting with the CodeOcean API, it uses and returns objects from the official Python library - we will avoid duplicating functionality provided by that package, except to make convenience functions with assumptions baked-in (for example, getting a client with environment variables and a default domain; finding all the assets for a particular session)
  • the core Session class should have a minimal set of methods and attributes that are common to sessions from all platforms - it should be fast to initialize and not do unnecessary work
  • extensions provide additional functionality (e.g. for specific modalities, metadata, databases) - at the moment, this is implemented via registration of namespaces (like Pandas), which allows for extending without subclassing
  • when searching for session data or information, methods should be exhaustive: for example, as naming conventions change, this package should support current and previous versions of names
  • when searching is unsuccessful, as much information as possible should be provided to the user via logging messages and exceptions, so they can understand the reasons for failure

Usage

User secrets

Credentials are required for:

  • S3
    • using the "assumable role" in CodeOcean should suffice
    • alternatively, access keys as environment variables or in a config file will be found by boto3 (see docs)
  • CodeOcean API
    • an access token is required with at least "Datasets - Read" scope:
      • see CodeOcean's docs on how to create a token
      • CODE_OCEAN_API_TOKEN is the preferred environment variable name
      • if not found, the first environment variable with a value starting COP_ is used (case-insensitive)
    • domain name defaults to https://codeocean.allenneuraldynamics.org, but can be overridden by setting CODE_OCEAN_DOMAIN

For development, environment variables can be provided in a .env file in the project root directory or the user's home directory.

Install

pip install aind_session

Python

>>> from aind_session import Session

# Common attributes available for all sessions:
>>> session = Session('ecephys_676909_2023-12-13_13-43-40')
>>> session.platform
'ecephys'
>>> session.subject_id
'676909'
>>> session.dt
datetime.datetime(2023, 12, 13, 13, 43, 40)
>>> session.raw_data_asset.id
'16d46411-540a-4122-b47f-8cb2a15d593a'
>>> session.raw_data_folder.as_posix()
's3://aind-ephys-data/ecephys_676909_2023-12-13_13-43-40'

# Additional functionality in namespace extensions:
>>> session.metadata.subject['genotype']
'Pvalb-IRES-Cre/wt;Ai32(RCL-ChR2(H134R)_EYFP)/wt'
>>> session.ecephys.sorted_data_asset.name
'ecephys_676909_2023-12-13_13-43-40_sorted_2024-03-01_16-02-45'

Development

See instructions in CONTRIBUTING.md and the original template

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aind_session-0.1.2.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

aind_session-0.1.2-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file aind_session-0.1.2.tar.gz.

File metadata

  • Download URL: aind_session-0.1.2.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.18.0 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for aind_session-0.1.2.tar.gz
Algorithm Hash digest
SHA256 19dfd7fbcd7eef4d16dde9c75d88877bc23ad168c4e05273aa5547391ddf40d0
MD5 c0c61b92ee218f5d0e4a61c716be8290
BLAKE2b-256 88772b67273f32672224c2076890b81920491cd6fcc23c162c451aae248e43db

See more details on using hashes here.

File details

Details for the file aind_session-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aind_session-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.18.0 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for aind_session-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fd9e7b07870d2f47c73514712b9c4eb15cf4a041ed35d6b8d142d2d6518b5001
MD5 904e4d936ac038683a5ea450daebad24
BLAKE2b-256 49cd453d2a60368eda8d9c48925b9ce13ae2783bfc639d8dd6733a9c6780ec90

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page