Skip to content

Commit cd325fa

Browse files
author
Guillaume V.
committed
Update [Config File] : Add user input and infos regarding config file overwriting
1 parent 2684090 commit cd325fa

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

examples/freesurfer/freesurfer_longitudinal_processing/freesurfer_longitudinal.ipynb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@
106106
{
107107
"metadata": {},
108108
"cell_type": "markdown",
109-
"source": "**User variables**: should be checked and supplied at each execution. This cell will create a user_config.py file, please modify the values of the file created and not those here",
109+
"source": [
110+
"**User variables**: should be checked and supplied at each execution. This cell will create a user_config.py file. Please modify the variable values by editing the user_config.py file after it is created.\n",
111+
"\n",
112+
"⚠️ We strongly advise you not to modify the values directly in this cell in order to avoid conflicts when updating the notebook."
113+
],
110114
"id": "dd7f54bce66f9e9f"
111115
},
112116
{
@@ -134,7 +138,16 @@
134138
"LICENSE_PATH = Path('~/PATH/LICENSE_NAME.txt').expanduser() # Your pipeline license path, will be copied into VIP input_dirs automatically\n",
135139
"\"\"\"\n",
136140
"\n",
137-
"CONFIG_PATH.write_text(user_config)"
141+
"if CONFIG_PATH.exists():\n",
142+
" answer = input(\"The user_config.py file already exists. Overwrite config ? (y/N): \")\n",
143+
" if answer != \"y\":\n",
144+
" print(\"File not created, as user_config.py already exists.\")\n",
145+
" else:\n",
146+
" CONFIG_PATH.write_text(user_config)\n",
147+
" print(\"User_config.py overwritten with default values.\")\n",
148+
"else:\n",
149+
" CONFIG_PATH.write_text(user_config)\n",
150+
" print(\"User_config.py created with default values.\")\n"
138151
],
139152
"id": "c7f8787950ccc948",
140153
"outputs": [],
@@ -316,7 +329,7 @@
316329
"}\n",
317330
"\n",
318331
"session = VipSession.init(\n",
319-
" api_key=VIP_KEY,\n",
332+
" api_key=cfg.VIP_KEY,\n",
320333
" input_dir=str(cfg.LOCAL_DATASET_PATH),\n",
321334
" output_dir= str(FS_CROSS_OUTPUT_DIR),\n",
322335
" pipeline_id=PIPELINE_ALL_ID,\n",
@@ -343,7 +356,7 @@
343356
"cell_type": "code",
344357
"source": [
345358
"# Connect back to session if needed\n",
346-
"VipSession.init(api_key=VIP_KEY)\n",
359+
"VipSession.init(api_key=cfg.VIP_KEY)\n",
347360
"session = VipSession(output_dir=str(FS_CROSS_OUTPUT_DIR))\n",
348361
"\n",
349362
"# Download outputs to the output_dir\n",
@@ -483,7 +496,7 @@
483496
"}\n",
484497
"\n",
485498
"session = VipSession.init(\n",
486-
" api_key=VIP_KEY,\n",
499+
" api_key=cfg.VIP_KEY,\n",
487500
" input_dir=str(FS_BASE_INPUT_DIR),\n",
488501
" output_dir= str(FS_BASE_OUTPUT_DIR),\n",
489502
" pipeline_id=PIPELINE_BASE_ID,\n",
@@ -510,7 +523,7 @@
510523
"cell_type": "code",
511524
"source": [
512525
"# Connect back to session if needed\n",
513-
"VipSession.init(api_key=VIP_KEY)\n",
526+
"VipSession.init(api_key=cfg.VIP_KEY)\n",
514527
"session = VipSession(output_dir=str(FS_BASE_OUTPUT_DIR))\n",
515528
"\n",
516529
"# Download outputs to the output_dir\n",
@@ -596,7 +609,7 @@
596609
"print(f\"Submitting {len(subjects)} LONG jobs for subjects: {', '.join(subjects)}\")\n",
597610
"\n",
598611
"session = VipSession.init(\n",
599-
" api_key=VIP_KEY,\n",
612+
" api_key=cfg.VIP_KEY,\n",
600613
" input_dir=str(FS_BASE_OUTPUT_DIR.parent), # LONG pipeline uses data from BASE inputs and outputs\n",
601614
" output_dir=str(FS_LONG_OUTPUT_DIR),\n",
602615
" pipeline_id=PIPELINE_LONG_ID,\n",
@@ -623,7 +636,7 @@
623636
"cell_type": "code",
624637
"source": [
625638
"# Connect back to session if needed\n",
626-
"VipSession.init(api_key=VIP_KEY)\n",
639+
"VipSession.init(api_key=cfg.VIP_KEY)\n",
627640
"session = VipSession(output_dir=str(FS_LONG_OUTPUT_DIR))\n",
628641
"\n",
629642
"# Download outputs to the output_dir\n",

0 commit comments

Comments
 (0)