Other directories in Files Explorer App

#1

Hi everyone,

we have a request to show other file systems in the Files Explorer app. I am trying to follow https://osc.github.io/ood-documentation/master/customization.html#add-shortcuts-to-files-menu to add menu items for a few scratches but not having success.

I am starting with the following simple /etc/ood/config/apps/dashboard/initializers/ood.rb:
OodFilesApp.candidate_favorite_paths.tap do |paths|
paths << Pathname.new("/scratch/serial/kingspeak/#{User.new.name}")
end

So, want to add a new item called /scratch/serial/kingspeak/user_name, but it does not look like it’s recognized since there’s no new item in the Files menu.

Can someone please add some information on the (presumed) Ruby User object so I get a better idea of what it contains, and, also, how to troubleshoot issues like this - e.g. where would the logs be (if any), etc.

Thanks,
MC

#2

The link in the Files menu will not appear unless the directory actually exists. Can you confirm that /scratch/serial/kingspeak/your_username actually exists and you have rx to it?

#3

Here’s what we use for scratch space

UA ood.rb initializer.

#4

Hi Eric,

yes, the directory does exist - though I had a typo in the definition. Thanks for the reminder to check it. Now it works, great. It’s also good that the menu item does not show if the directory does not exist.

I have a follow up question.

Some of our users also have “group” space, which has somewhat different name pattern, /uufs/chpc.utah.edu/common/home/PI_group#, where PI is the group name, # is a number, which can range from 0 to group_max=18 currently.

What would be the best way to get all these? I figure we can start with the User.new.groups and create the basic path as “/uufs/chpc.utah.edu/common/home/#{p}_group”, (#{p} is the group name) but given that most groups # number range is small (0-2), I don’t think hard putting the range 0-18 would be very efficient so we’d probably want to instead get output of something like “ls /uufs/chpc.utah.edu/common/home/group_name*” and feed that to the OOD paths list.

What would be your thoughts on that?

To illustrate the situation better, I am pasting an output of ls for a first page of the group dirs we have:
$ ls -1 -d /uufs/chpc.utah.edu/common/home/-group |more
/uufs/chpc.utah.edu/common/home/anderegg-group1
/uufs/chpc.utah.edu/common/home/anderegg-group2
/uufs/chpc.utah.edu/common/home/armentrout-group1
/uufs/chpc.utah.edu/common/home/avey-group3
/uufs/chpc.utah.edu/common/home/balagurunathan-group1
/uufs/chpc.utah.edu/common/home/bmi-group1
/uufs/chpc.utah.edu/common/home/bolton-group1
/uufs/chpc.utah.edu/common/home/bowen-group2
/uufs/chpc.utah.edu/common/home/calaf-group1
/uufs/chpc.utah.edu/common/home/camp-group1
/uufs/chpc.utah.edu/common/home/camp-group2
/uufs/chpc.utah.edu/common/home/cao-group1
/uufs/chpc.utah.edu/common/home/cheatham-group1
/uufs/chpc.utah.edu/common/home/cheatham-group2
/uufs/chpc.utah.edu/common/home/cheatham-group4
/uufs/chpc.utah.edu/common/home/cheatham-group5
/uufs/chpc.utah.edu/common/home/cheatham-group6
/uufs/chpc.utah.edu/common/home/cheatham-group7
/uufs/chpc.utah.edu/common/home/chpc-group1
/uufs/chpc.utah.edu/common/home/civil-group1
/uufs/chpc.utah.edu/common/home/cliu-group4
/uufs/chpc.utah.edu/common/home/codding-group1
/uufs/chpc.utah.edu/common/home/conway-group1
/uufs/chpc.utah.edu/common/home/conway-group2
/uufs/chpc.utah.edu/common/home/coonh-group1
/uufs/chpc.utah.edu/common/home/coopers-group1
/uufs/chpc.utah.edu/common/home/cryoem-group1

Thanks,
MC

#5

Hey Martin:
We add the research group parent directory (/rsgrps here) to the menu, and let the users navigate from there, file/directory settings permitting. This was drive by the fact that a given user can be part of multiple research groups (e.g. /rsgrps/bill and /rsgrps/fred),
and mind reading would be required to know which one was right for “today”.

Ric

#6

Hi Ric,

do you have a settings file or a piece of code for this? My Ruby knowledge is close to zero so an example speaks thousand words.

Thanks,
MC

#7

Here’s our setup for 2 directories beyond /home: /extra/UserID and /rsgrps

$ cat /etc/ood/config/apps/dashboard/initializers/ood.rb
# UA ood.rb initializer.
#
OodFilesApp.candidate_favorite_paths.tap do |paths|
  # add /extra directory
  paths << Pathname.new("/extra/#{User.new.name}")
  # add /rsgrps directory
  paths << Pathname.new("/rsgrps/")
end
#8

My guess is Ric’s example applied to your situation would be:

OodFilesApp.candidate_favorite_paths.tap do |paths|
paths << Pathname.new("/scratch/serial/kingspeak/#{User.new.name}")
paths << Pathname.new("/uufs/chpc.utah.edu/common/home")
end

And then you navigate to the group directory you want.

Otherwise you could try this:

OodFilesApp.candidate_favorite_paths.tap do |paths|

  # add scratch
  paths << Pathname.new("/scratch/serial/kingspeak/#{User.new.name}")

  # add project directories
  project = camp
  paths.concat Pathname.glob("/uufs/chpc.utah.edu/common/home/#{project}-group*")

end

of course you would replace project = camp with something like project = OodSupport::User.new.group.name or if you had multiple groups you would do

  User.new.groups.each do |group|
    paths.concat Pathname.glob("/uufs/chpc.utah.edu/common/home/#{group.name}-group*")
  end

Note both of those rely on the getgrgid to turn a group id into a name String, so whatever provides the group database on the web node would need to be up to date: (/etc/group) - at least converting the id to the name, not necessarily the membership list of a group though.

Also, this approach means that if the project directory does not exist at application start up, the link will not appear in the user’s dashboard once the directory is created unless their per user web server is restarted.

#9

Thanks guys,

I figured as much as hard coding the parent path :wink:

But, Eric’s last suggestion is perfect, it works great.

It looks like Ruby is quite powerful as long as you know it, like C++. For those of us who don’t, and don’t want to waste Eric’s time - how about sticking a few more examples like this in the OOD User’s Guide?

Or, link to implementations on other sites. E.g. I am working on a document to share with our Rocky Mountain group where I am putting the local trickery, https://github.com/CHPC-UofU/OnDemand-info.

Thanks,
MC

#10

I added an issue to update the documentation as suggested: https://github.com/OSC/ood-documentation/issues/158

Thank you for sharing the notes on Open Ondemand at CHPC!