eegdash 0.4.0.dev150__py3-none-any.whl → 0.4.0.dev162__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of eegdash might be problematic. Click here for more details.

eegdash/mongodb.py CHANGED
@@ -4,50 +4,63 @@
4
4
 
5
5
  """MongoDB connection and operations management.
6
6
 
7
- This module provides thread-safe MongoDB connection management and high-level database
8
- operations for the EEGDash metadata database. It includes methods for finding, adding,
9
- and updating EEG data records with proper connection pooling and error handling.
7
+ This module provides a thread-safe singleton manager for MongoDB connections,
8
+ ensuring that connections to the database are handled efficiently and consistently
9
+ across the application.
10
10
  """
11
11
 
12
12
  import threading
13
13
 
14
14
  from pymongo import MongoClient
15
-
16
- # MongoDB Operations
17
- # These methods provide a high-level interface to interact with the MongoDB
18
- # collection, allowing users to find, add, and update EEG data records.
19
- # - find:
20
- # - exist:
21
- # - add_request:
22
- # - add:
23
- # - update_request:
24
- # - remove_field:
25
- # - remove_field_from_db:
26
- # - close: Close the MongoDB connection.
27
- # - __del__: Destructor to close the MongoDB connection.
15
+ from pymongo.collection import Collection
16
+ from pymongo.database import Database
28
17
 
29
18
 
30
19
  class MongoConnectionManager:
31
- """Singleton class to manage MongoDB client connections."""
20
+ """A thread-safe singleton to manage MongoDB client connections.
21
+
22
+ This class ensures that only one connection instance is created for each
23
+ unique combination of a connection string and staging flag. It provides
24
+ class methods to get a client and to close all active connections.
25
+
26
+ Attributes
27
+ ----------
28
+ _instances : dict
29
+ A dictionary to store singleton instances, mapping a
30
+ (connection_string, is_staging) tuple to a (client, db, collection)
31
+ tuple.
32
+ _lock : threading.Lock
33
+ A lock to ensure thread-safe instantiation of clients.
34
+
35
+ """
32
36
 
33
- _instances = {}
37
+ _instances: dict[tuple[str, bool], tuple[MongoClient, Database, Collection]] = {}
34
38
  _lock = threading.Lock()
35
39
 
36
40
  @classmethod
37
- def get_client(cls, connection_string: str, is_staging: bool = False):
38
- """Get or create a MongoDB client for the given connection string and staging flag.
41
+ def get_client(
42
+ cls, connection_string: str, is_staging: bool = False
43
+ ) -> tuple[MongoClient, Database, Collection]:
44
+ """Get or create a MongoDB client for the given connection parameters.
45
+
46
+ This method returns a cached client if one already exists for the given
47
+ connection string and staging flag. Otherwise, it creates a new client,
48
+ connects to the appropriate database ("eegdash" or "eegdashstaging"),
49
+ and returns the client, database, and "records" collection.
39
50
 
40
51
  Parameters
41
52
  ----------
42
53
  connection_string : str
43
- The MongoDB connection string
44
- is_staging : bool
45
- Whether to use staging database
54
+ The MongoDB connection string.
55
+ is_staging : bool, default False
56
+ If True, connect to the staging database ("eegdashstaging").
57
+ Otherwise, connect to the production database ("eegdash").
46
58
 
47
59
  Returns
48
60
  -------
49
- tuple
50
- A tuple of (client, database, collection)
61
+ tuple[MongoClient, Database, Collection]
62
+ A tuple containing the connected MongoClient instance, the Database
63
+ object, and the Collection object for the "records" collection.
51
64
 
52
65
  """
53
66
  # Create a unique key based on connection string and staging flag
@@ -66,8 +79,12 @@ class MongoConnectionManager:
66
79
  return cls._instances[key]
67
80
 
68
81
  @classmethod
69
- def close_all(cls):
70
- """Close all MongoDB client connections."""
82
+ def close_all(cls) -> None:
83
+ """Close all managed MongoDB client connections.
84
+
85
+ This method iterates through all cached client instances and closes
86
+ their connections. It also clears the instance cache.
87
+ """
71
88
  with cls._lock:
72
89
  for client, _, _ in cls._instances.values():
73
90
  try:
eegdash/paths.py CHANGED
@@ -18,12 +18,21 @@ from mne.utils import get_config as mne_get_config
18
18
 
19
19
 
20
20
  def get_default_cache_dir() -> Path:
21
- """Resolve a consistent default cache directory for EEGDash.
21
+ """Resolve the default cache directory for EEGDash data.
22
+
23
+ The function determines the cache directory based on the following
24
+ priority order:
25
+ 1. The path specified by the ``EEGDASH_CACHE_DIR`` environment variable.
26
+ 2. The path specified by the ``MNE_DATA`` configuration in the MNE-Python
27
+ config file.
28
+ 3. A hidden directory named ``.eegdash_cache`` in the current working
29
+ directory.
30
+
31
+ Returns
32
+ -------
33
+ pathlib.Path
34
+ The resolved, absolute path to the default cache directory.
22
35
 
23
- Priority order:
24
- 1) Environment variable ``EEGDASH_CACHE_DIR`` if set.
25
- 2) MNE config ``MNE_DATA`` if set (aligns with tests and ecosystem caches).
26
- 3) ``.eegdash_cache`` under the current working directory.
27
36
  """
28
37
  # 1) Explicit env var wins
29
38
  env_dir = os.environ.get("EEGDASH_CACHE_DIR")
eegdash/utils.py CHANGED
@@ -11,7 +11,22 @@ including MongoDB client initialization and configuration helpers.
11
11
  from mne.utils import get_config, set_config, use_log_level
12
12
 
13
13
 
14
- def _init_mongo_client():
14
+ def _init_mongo_client() -> None:
15
+ """Initialize the default MongoDB connection URI in the MNE config.
16
+
17
+ This function checks if the ``EEGDASH_DB_URI`` is already set in the
18
+ MNE-Python configuration. If it is not set, this function sets it to the
19
+ default public EEGDash MongoDB Atlas cluster URI.
20
+
21
+ The operation is performed with MNE's logging level temporarily set to
22
+ "ERROR" to suppress verbose output.
23
+
24
+ Notes
25
+ -----
26
+ This is an internal helper function and is not intended for direct use
27
+ by end-users.
28
+
29
+ """
15
30
  with use_log_level("ERROR"):
16
31
  if get_config("EEGDASH_DB_URI") is None:
17
32
  set_config(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eegdash
3
- Version: 0.4.0.dev150
3
+ Version: 0.4.0.dev162
4
4
  Summary: EEG data for machine learning
5
5
  Author-email: Young Truong <dt.young112@gmail.com>, Arnaud Delorme <adelorme@gmail.com>, Aviv Dotan <avivd220@gmail.com>, Oren Shriki <oren70@gmail.com>, Bruno Aristimunha <b.aristimunha@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -0,0 +1,37 @@
1
+ eegdash/__init__.py,sha256=04SaQxsJAI5vCXSpaNxtNEuq-CPKUlMSaX3mdz5Xzng,704
2
+ eegdash/api.py,sha256=az7uUYrEvJfBtzvkzYKzXqEztDSCMsCmgIywpdzYqc8,38381
3
+ eegdash/bids_eeg_metadata.py,sha256=kEmFUe07tivkuIoC5T-YwfO4QQYJBxuc769ZBV1UCKo,16682
4
+ eegdash/const.py,sha256=9WMetN7YMQJbkN2PhzItxtVRZ4VBXLP82vFu9pY6xok,9066
5
+ eegdash/data_utils.py,sha256=nCiGi1LGClTOUUnEPfykcCtza1o4BDW9kb0JBymwbs4,26206
6
+ eegdash/downloader.py,sha256=Z-9EEJildqJxIihwdtXc_h9kzCkuF9LWIwQEfyG9Huw,6030
7
+ eegdash/logging.py,sha256=OQ4jMtwv1h-gzjxmr3PCpcsKi5-3Nhd3r9PJ4UN7oQI,1467
8
+ eegdash/mongodb.py,sha256=9FJDeEebOD5RzNYfAf1lhr0R-pECAlnug6Sjhd9_oUw,3469
9
+ eegdash/paths.py,sha256=dKaDlF87q47KwP-5arAFwx83i5IwGgmEfPfNauEtkds,1499
10
+ eegdash/utils.py,sha256=u_fQ8DiA1b7dVLzwzZBhm8H-LUk6dga54WyqbbqYEJ4,1282
11
+ eegdash/dataset/__init__.py,sha256=HKDfV2DHBv63BqYLBWDMvU8jbFNRC7DqQbxL7RG1DKQ,863
12
+ eegdash/dataset/dataset.py,sha256=DnR6LoirPNV45MECq42MNtIPyhL7DTFuwPWavVWZmmA,8137
13
+ eegdash/dataset/dataset_summary.csv,sha256=797SpPVVkT17y1uYY4GUqAyWSB2H9Ibqnubw7XSTjwA,23613
14
+ eegdash/dataset/registry.py,sha256=5TOCWalA0RV7omRoYS0OzdcSaOTvXvqos74_Vj2jv0M,9127
15
+ eegdash/features/__init__.py,sha256=BXNhjvL4_SSFAY1lcP9nyGpkbJNtoOMH4AHlF6OyABo,4078
16
+ eegdash/features/datasets.py,sha256=5BQZMNwsUsugW05_qGSdKbCFVgI4KP8PGukLx5y8p2A,24569
17
+ eegdash/features/decorators.py,sha256=xK6-HcusPRnKcUCot3DEzkoRjlazd9OLVvq6R8JO0Nw,3826
18
+ eegdash/features/extractors.py,sha256=Fl9vIHBfajk33x7RMweDCrcb7ZlyivVx-ddV8owKeTc,11730
19
+ eegdash/features/inspect.py,sha256=VhK621yv39qHw-cNMhZTeZjpXeWtuIJ-2j3gcrayobE,3875
20
+ eegdash/features/serialization.py,sha256=ZyLgqVul4H0bLfffiVvb_p9_gtMGDFKetcC5AWjHD0I,3852
21
+ eegdash/features/utils.py,sha256=lK-epGlkRm9_psqsbgiWzan_gFC8BuizCRu44PSTvco,6092
22
+ eegdash/features/feature_bank/__init__.py,sha256=YsMXLC1FEtHL3IEw9pYw1fc5IY0x_hr2qWQowI5gZj8,2991
23
+ eegdash/features/feature_bank/complexity.py,sha256=iy9uaLInsYdxKZlXHTWlgEpP9fVI-v9TqLGfnS15-Eg,3258
24
+ eegdash/features/feature_bank/connectivity.py,sha256=bQ6KlxWm5GNpCS9ypLqBUr2L171Yq7wpBQT2tRQKTZ4,2159
25
+ eegdash/features/feature_bank/csp.py,sha256=jKPrmqBj7FliybNbg035cVZddvVSkhk9OazcscDpipU,3303
26
+ eegdash/features/feature_bank/dimensionality.py,sha256=j_Ds71Y1AbV2uLFQj8EuXQ4kzofLBlQtPV5snMkF7i4,3965
27
+ eegdash/features/feature_bank/signal.py,sha256=3Tb8z9gX7iZipxQJ9DSyy30JfdmW58kgvimSyZX74p8,3404
28
+ eegdash/features/feature_bank/spectral.py,sha256=bNB7skusePs1gX7NOU6yRlw_Gr4UOCkO_ylkCgybzug,3319
29
+ eegdash/features/feature_bank/utils.py,sha256=DGh-Q7-XFIittP7iBBxvsJaZrlVvuY5mw-G7q6C-PCI,1237
30
+ eegdash/hbn/__init__.py,sha256=hsI5pmIuYDzr--aE5UiToO-P9XL5fVRKahZzdsAodro,794
31
+ eegdash/hbn/preprocessing.py,sha256=xp0HBz8WGhLI5c2Zkk4QiVUzGoIZep8YypnHNZsUJ4o,3800
32
+ eegdash/hbn/windows.py,sha256=Z_fhG3kaHd5MAPg60FwFnxMJay8EzacXytUaCsOENGc,14408
33
+ eegdash-0.4.0.dev162.dist-info/licenses/LICENSE,sha256=asisR-xupy_NrQBFXnx6yqXeZcYWLvbAaiETl25iXT0,931
34
+ eegdash-0.4.0.dev162.dist-info/METADATA,sha256=inHG7-WQLXe7uptJa2dG2u6ODc9iOTz6-zpikjbJCjU,6804
35
+ eegdash-0.4.0.dev162.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
+ eegdash-0.4.0.dev162.dist-info/top_level.txt,sha256=zavO69HQ6MyZM0aQMR2zUS6TAFc7bnN5GEpDpOpFZzU,8
37
+ eegdash-0.4.0.dev162.dist-info/RECORD,,
@@ -1,37 +0,0 @@
1
- eegdash/__init__.py,sha256=E0583aFzz3UAElK7BMSDvWmuTNyiEkhJXjqlNsxg7n0,704
2
- eegdash/api.py,sha256=vcme_BXxc0KpyLwQfrzV7lojM0s16P7KPq-62Gu9ee4,37241
3
- eegdash/bids_eeg_metadata.py,sha256=0fA5FDM4OlSS83JziRI7-hPvh-KRvwKBpT1dMeB4znk,14307
4
- eegdash/const.py,sha256=-cwrtncqJHZ19lGf2MK-IgKy7hTMfb6H-CeL50Oonyg,7883
5
- eegdash/data_utils.py,sha256=5g88vIuU_KTixWF2BV6wtQTs8ba23OPIMkrsEklmiE8,26548
6
- eegdash/downloader.py,sha256=ukkol-2Y-8FGgociwJR-3TqBfvbUuCuMt2L6E_6baDY,3638
7
- eegdash/logging.py,sha256=Jux2A3YM9m2ksETErEfUG7wnB7jpJw6v1JH9tQuYVJc,974
8
- eegdash/mongodb.py,sha256=oXjiNLf0-46r_0RbxG8Y8wQZl8MIcfGQt4_qieU2MqU,2469
9
- eegdash/paths.py,sha256=4-ae23KeXMP5yaKAJCNW7pQGV19c00ll0EGElV2rZn8,1255
10
- eegdash/utils.py,sha256=e7LdirPY0dAfMZNWTbgAguqzu-dq0zo-mtXB9nIzf_c,758
11
- eegdash/dataset/__init__.py,sha256=HKDfV2DHBv63BqYLBWDMvU8jbFNRC7DqQbxL7RG1DKQ,863
12
- eegdash/dataset/dataset.py,sha256=e_rliu4E-uPtz_miUSzGukUahCHHhyXB2Gu3pm3cyHo,7062
13
- eegdash/dataset/dataset_summary.csv,sha256=a5Y21LmBPKLVRt5uKNXO7lSRDjsDmJLzv6-3HryF5JU,23614
14
- eegdash/dataset/registry.py,sha256=KmPDfazhdsIyUouo3qdqDaHiTKHCZcEvXQJeHphZijY,7057
15
- eegdash/features/__init__.py,sha256=BXNhjvL4_SSFAY1lcP9nyGpkbJNtoOMH4AHlF6OyABo,4078
16
- eegdash/features/datasets.py,sha256=eV4d86EU4fu1yoIMdPQnot6YZDRGG4qE9h77lk7iVhU,18317
17
- eegdash/features/decorators.py,sha256=v0qaJz_dcX703p1fvFYbAIXmwK3d8naYGlq7fRVKn_w,1313
18
- eegdash/features/extractors.py,sha256=H7h6tP3dKoRcjDJpWWAo0ppmokCq5QlhqMcehYwYV9s,6845
19
- eegdash/features/inspect.py,sha256=PmbWhx5H_WqpnorUpWONUSkUtaIHkZblRa_Xyk7Szyc,1569
20
- eegdash/features/serialization.py,sha256=LmDrQEb-NLNgak_LabdDnr_J_v0QyLPzm_E8IiIHgMQ,2960
21
- eegdash/features/utils.py,sha256=eM6DdyOpdVfNh7dSPykJ0WaTDtaGvkCQWAmW0G8v60Y,3784
22
- eegdash/features/feature_bank/__init__.py,sha256=YsMXLC1FEtHL3IEw9pYw1fc5IY0x_hr2qWQowI5gZj8,2991
23
- eegdash/features/feature_bank/complexity.py,sha256=iy9uaLInsYdxKZlXHTWlgEpP9fVI-v9TqLGfnS15-Eg,3258
24
- eegdash/features/feature_bank/connectivity.py,sha256=bQ6KlxWm5GNpCS9ypLqBUr2L171Yq7wpBQT2tRQKTZ4,2159
25
- eegdash/features/feature_bank/csp.py,sha256=jKPrmqBj7FliybNbg035cVZddvVSkhk9OazcscDpipU,3303
26
- eegdash/features/feature_bank/dimensionality.py,sha256=j_Ds71Y1AbV2uLFQj8EuXQ4kzofLBlQtPV5snMkF7i4,3965
27
- eegdash/features/feature_bank/signal.py,sha256=3Tb8z9gX7iZipxQJ9DSyy30JfdmW58kgvimSyZX74p8,3404
28
- eegdash/features/feature_bank/spectral.py,sha256=bNB7skusePs1gX7NOU6yRlw_Gr4UOCkO_ylkCgybzug,3319
29
- eegdash/features/feature_bank/utils.py,sha256=DGh-Q7-XFIittP7iBBxvsJaZrlVvuY5mw-G7q6C-PCI,1237
30
- eegdash/hbn/__init__.py,sha256=hsI5pmIuYDzr--aE5UiToO-P9XL5fVRKahZzdsAodro,794
31
- eegdash/hbn/preprocessing.py,sha256=cfsLXnGuUaVJ3NhueDgmdc0w7jflmIi69occuB4bs7M,2609
32
- eegdash/hbn/windows.py,sha256=23KyVl0pQn4o40wM3Rsu8nl5tN-REAusU7wcv9L4a5U,10351
33
- eegdash-0.4.0.dev150.dist-info/licenses/LICENSE,sha256=asisR-xupy_NrQBFXnx6yqXeZcYWLvbAaiETl25iXT0,931
34
- eegdash-0.4.0.dev150.dist-info/METADATA,sha256=YbiJANCGZcLMSn2pjX73kOm0QO_pFzYTVifwtVhAZ_A,6804
35
- eegdash-0.4.0.dev150.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
36
- eegdash-0.4.0.dev150.dist-info/top_level.txt,sha256=zavO69HQ6MyZM0aQMR2zUS6TAFc7bnN5GEpDpOpFZzU,8
37
- eegdash-0.4.0.dev150.dist-info/RECORD,,