Coder Social home page Coder Social logo

Comments (1)

prioux avatar prioux commented on August 26, 2024

Sample code for usage of the class, from the programmer's perspective. Can be used in the console.

  • Creating it
# Properties of the file, to adjust
dp_id = 23; name = "virtcivet"; user_id = 1; group_id = 1;
co_ids = [23,45] # ID of some CivetOutputs

# Create it
uf = CivetVirtualCollection.new(:name => name, :dp_id => dp_id, :user_id => user_id, :group_id => group_id) # hope I got them all
uf.save!

# Set content
uf.cache_prepare
path = uf.cache_full_path
File.mkdir(path.to_s)
uf.set_civet_outputs(CivetOutput.find(co_id), current_user) # need current_user for validation
uf.sync_to_provider
  • Use an existing CivetVirtualStudy, from any Remote Resource
# Prep; adjust in console
cs_id = 234; # id of the study

# Find it
cs = CivetVirtualStudy.find(cs_id)
cs.sync_to_cache
cos = cs.get_civetoutputs(current_user) # returns array of CivetOutput objects

# Do something with content of each CivetOutput
path = cs.cache_full_path
Dir.chdir(path.to_s) do 
  cos.map(&:name).each do |co_name|
    system("ls -ld #{co_name.bash_escape};du -D -h #{co_name.bash_escape}")
  end
end

The current_user is needed in some methods to be passed to validation code of CbrainFileList methods.

from cbrain-plugins-neuro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.