Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import all foreign key references.
### Infrastructure

- Auto-load within-Spyglass tables for graph operations #1368
- Add explicit `kachery-cloud` dependency #1430
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add explicit `kachery-cloud` dependency #1430
- Add explicit `kachery-cloud` dependency #1430
- Default ton globally saved config #1430


### Pipelines

Expand All @@ -37,6 +38,7 @@ import all foreign key references.
- Common
- Add tables for storing optogenetic experiment information #1312
- Remove wildcard matching in `Nwbfile().get_abs_path` #1382
- Ensure `AnalysisNwbfile.get_abs_path` always returns same type #1429
- Decoding
- Ensure results directory is created if it doesn't exist #1362
- Position
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ dependencies:
- pip:
- ghostipy # for common_filter
- mountainsort4
- kachery-cloud
- .
1 change: 1 addition & 0 deletions environment_dlc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ dependencies:
- pip:
- ghostipy # for common_filter
- mountainsort4
- kachery-cloud
- .[dlc]
1 change: 1 addition & 0 deletions environment_moseq_cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ dependencies:
- pip:
- ghostipy # for common_filter
- mountainsort4
- kachery-cloud
- .[moseq-cpu]
1 change: 1 addition & 0 deletions environment_moseq_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ dependencies:
- pip:
- ghostipy # for common_filter
- mountainsort4
- kachery-cloud
- .[moseq-gpu]
46 changes: 32 additions & 14 deletions notebooks/00_Setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -502,30 +502,48 @@
"metadata": {},
Copy link
Collaborator

@edeno edeno Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line #17.            "database.host": "lmf-db.cin.ucsf.edu",

Do we want this to be specific to our database?


Reply via ReviewNB

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry. this should be the database_host value defined above

"outputs": [],
"source": [
"import os\n",
"import datajoint as dj\n",
"from spyglass.settings import SpyglassConfig\n",
"\n",
"# change to the root directory of the project\n",
"if os.path.basename(os.getcwd()) == \"notebooks\":\n",
" os.chdir(\"..\")\n",
"username = \"your username\" # replace with username made for you in the spyglass database\n",
"initial_password = (\n",
" \"your initial password\" # replace with the initial password given to you\n",
")\n",
"new_password = (\n",
" \"your new password\" # replace with the new password you want to set\n",
")\n",
"spyglass_base_dir = \"/path/like/stelmo/nwb/\" # replace with a path on your system where spyglass can store NWB files\n",
"database_host = \"address like: 'localhost' or 'lmf-db.cin.ucsf.edu'\"\n",
"\n",
"# connect to the database\n",
"dj.conn()\n",
"\n",
"# change your password\n",
"dj.admin.set_password()\n",
"dj.config.update(\n",
" {\n",
" \"database.host\": database_host,\n",
" \"database.user\": username,\n",
" \"database.password\": initial_password,\n",
" \"database.port\": 3306,\n",
" }\n",
")\n",
"\n",
"dj.conn() # connect to the database\n",
"\n",
"# change your password from the initial password\n",
"dj.admin.set_password(new_password, update_config=True)\n",
"\n",
"# save the configuration\n",
"SpyglassConfig().save_dj_config(\n",
" save_method=\"local\", # global or local\n",
" base_dir=\"/path/like/stelmo/nwb/\",\n",
" database_user=\"your username\",\n",
" database_password=\"your password\", # remove this line for shared machines\n",
" database_host=\"localhost or lmf-db.cin.ucsf.edu\", # only list one\n",
" save_method=\"global\", # global or local\n",
" base_dir=spyglass_base_dir,\n",
" database_user=username,\n",
" database_password=new_password,\n",
" database_host=database_host, # only list one\n",
" database_port=3306,\n",
" set_password=False,\n",
")"
")\n",
"\n",
"# ensure the configuration is saved for future use\n",
"dj.config.save_global()\n",
"dj.config.save_local()"
]
},
{
Expand Down
46 changes: 32 additions & 14 deletions notebooks/py_scripts/00_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.17.0
# jupytext_version: 1.17.2
# kernelspec:
# display_name: spyglass
# language: python
Expand Down Expand Up @@ -426,30 +426,48 @@
#

# +
import os
import datajoint as dj
from spyglass.settings import SpyglassConfig

# change to the root directory of the project
if os.path.basename(os.getcwd()) == "notebooks":
os.chdir("..")
username = "your username" # replace with username made for you in the spyglass database
initial_password = (
"your initial password" # replace with the initial password given to you
)
new_password = (
"your new password" # replace with the new password you want to set
)
spyglass_base_dir = "/path/like/stelmo/nwb/" # replace with a path on your system where spyglass can store NWB files
database_host = "address like: 'localhost' or 'lmf-db.cin.ucsf.edu'"


# connect to the database
dj.conn()
dj.config.update(
{
"database.host": database_host,
"database.user": username,
"database.password": initial_password,
"database.port": 3306,
}
)

dj.conn() # connect to the database

# change your password
dj.admin.set_password()
# change your password from the initial password
dj.admin.set_password(new_password, update_config=True)

# save the configuration
SpyglassConfig().save_dj_config(
save_method="local", # global or local
base_dir="/path/like/stelmo/nwb/",
database_user="your username",
database_password="your password", # remove this line for shared machines
database_host="localhost or lmf-db.cin.ucsf.edu", # only list one
save_method="global", # global or local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this line, let it use the default, global

base_dir=spyglass_base_dir,
database_user=username,
database_password=new_password,
database_host=database_host, # only list one
database_port=3306,
set_password=False,
)

# ensure the configuration is saved for future use
dj.config.save_global()
dj.config.save_local()
Comment on lines +469 to +470
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because save_dj_config should do this already, yeah? I might change this too a check-exists.

Suggested change
dj.config.save_global()
dj.config.save_local()
your_config = Path.home() / '.datajoint_config.json'
print(f"Config exists: {your_config.exists()}"

# -

# <details><summary>Legacy config</summary>
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies = [
# "ghostipy", # removed from list bc M1 users need to install pyfftw first
"hdmf>=3.4.6",
"ipympl",
"kachery-cloud",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be in yaml and toml files? As an imported package, my thought would be to only list here in toml and let the yaml's - . handle installing for the conda env

"matplotlib",
"ndx_franklab_novela>=0.1.0",
"ndx-pose",
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/common/common_nwbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def get_abs_path(
& f"filepath LIKE '%{analysis_nwb_file_name}'"
)
if len(query) == 1: # Else try the standard way
return Path(analysis_dir) / query.fetch1("filepath")
return str(Path(analysis_dir) / query.fetch1("filepath"))
logger.warning(
f"Found {len(query)} files for: {analysis_nwb_file_name}"
)
Expand Down