Created
January 9, 2016 18:35
-
-
Save maedoc/6de1fba6ebb5ea965cb2 to your computer and use it in GitHub Desktop.
avoid storing temporary files in home if needed in TVB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseSettingsProfile(object): | |
TVB_USER_HOME = os.environ.get('TVB_USER_HOME', '~') | |
TVB_CONFIG_FILE = os.path.expanduser(os.path.join(TVB_USER_HOME, '.tvb.configuration')) | |
DEFAULT_STORAGE = os.path.expanduser(os.path.join(TVB_USER_HOME, 'TVB' + os.sep)) | |
FIRST_RUN_STORAGE = os.path.expanduser(os.path.join(TVB_USER_HOME, '.tvb-temp')) |
So would the idea here be to add these lines to the BaseSettingsProfile class definition in basic/config/profile_settings.py?
Here's what I came up with. Will do for now as a hack (just replaces from tvb.simulator.lab import *
with from scinet_tvb_lab import *
).
I'll log this on Jira after I've done a few more tests.
"""
scinet_tvb_lab.py
=================
Usage:
from scinet_tvb_lab import *
Alternative to calling
from tvb.simulator.lab import *
The difference is that we specify alternative locations
for some folders that by default are located in /home
(~/), which are used for some minimal logging purposes.
This needs to be modified because scinet compute nodes
do not have write access to /home, only to /scratch.
So that's where we change the locations to.
"""
# Specify the paths we will change in the TvbProfile
orig_base_dir = '/home/r/rmcintos/johngrif'
new_base_dir = '/scratch/r/rmcintos/johngrif'
tochange = ['DEFAULT_STORAGE', 'FIRST_RUN_STORAGE',
'TVB_LOG_FOLDER', 'TVB_CONFIG_FILE',
'TVB_STORAGE', 'TVB_TEMP_FOLDER']
# Initial imports
import os,pdb,numpy,numpy as np
from time import time
from numpy import * # for load & save not available in pylab
from tvb.basic.profile import TvbProfile
# Now import the library profile, modify the paths, a bit more fiddling, and initialize:
# First run set_profile but don't do any initializing
# (not doing this gives some errors to do with logging)
TvbProfile.set_profile('LIBRARY_PROFILE', run_init=False)
# This is where we change the folders from home to scratch
for c in tochange:
tmp = getattr(TvbProfile.current, c)
setattr(TvbProfile.current, c, i
tmp.replace(orig_base_dir, new_base_dir))
# This creates the folders if they're not there already
TvbProfile.current.initialize_profile()
# Now can get on with importing the various tvb modules
from tvb.simulator import (simulator, models, coupling, integrators, monitors, noise)
from tvb.datatypes import connectivity, surfaces, equations, patterns, region_mapping, sensors, cortex, local_connectivity
from tvb.simulator.common import get_logger
LOG = get_logger(__name__)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use like so