Closed wwieder closed 1 year ago
@teaganking or @samsrabin can you help with this basic question?
Does it work if you write out the full path to your home directory instead of using ~
?
If not, and sorry if this is insulting but it's always good to check: Is ~/scratch/NEON_cases/archive/CPER.transient/lnd/hist
actually a directory on your system?
oh you're right, it doesn't like the ~ and the softlink that's in home to my scratch directory.
is there another convenient way to do this in a way that's agnostic to running in the cloud or on cheyenne. I've been using a softlink in home to go to scratch ~/scratch
. This let's other parts of the tutorial work on either machine (once users add a similar to softlink to /glade/scratch/$USER/
. Is there a similar python work around?
Not sure if this will work, but try putting the path with ~/scratch
through os.path.realpath()
.
Failing that, you could instruct users to (bash) export SCRATCH="/path/to/scratch/dir"
before starting Python. Then in the Python script they could do os.environ["SCRATCH"]
to get its value.
yep, os.path.realpath()
gets rid the the ~, but glob still does't like the soft link that it points to, I'll keep trying. Thanks for your suggestions.
Okay, it looks like this should work:
os.path.realpath(os.path.expanduser("~/scratch"))
For example, on Cheyenne:
>>> os.path.realpath(os.path.expanduser("~samrabin/inputdata"))
'/glade/p/cesmdata/cseg/inputdata'
>>> glob.glob(os.path.realpath(os.path.expanduser("~samrabin/inputdata/*txt")))
['/glade/p/cesmdata/cseg/inputdata/list_prism_restart.txt', '/glade/p/cesmdata/cseg/inputdata/files_201.txt', '/glade/p/cesmdata/cseg/inputdata/list_prism.txt', '/glade/p/cesmdata/cseg/inputdata/files.txt', '/glade/p/cesmdata/cseg/inputdata/files_200.txt', '/glade/p/cesmdata/cseg/inputdata/lake_list.txt']
Thanks @samsrabin that did the trick!
I started working on a quick plot tutorial
Specifically I'm setting up a path the the folder where files are located
Here all looks correct, pointing to
~/scratch/NEON_cases/archive/CPER.transient/lnd/hist
When I try to glob this data folder, I only get an empty list in return
[ ]
Suggestions here would be most helpful.