Skip to content

Commit

Permalink
Misc small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
prioux committed Jan 27, 2025
1 parent 9332035 commit 16dc3aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class BackgroundActivity::CheckMissingWorkdir < BackgroundActivity
# Returns the object.
# Will not do it if an object already exists that was updated less
# than 24 hours ago. In that case, returns nil.
def self.setup!
def self.setup!(remote_resource_id = CBRAIN::SelfRemoteResourceId)
# Don't schedule a check if we've had one in the past 24 hours
return nil if self.where(:remote_resource_id => CBRAIN::SelfRemoteResourceId)
return nil if self.where(:remote_resource_id => remote_resource_id)
.where('updated_at > ?', 24.hours.ago)
.exists?

# Create the scheduled object
self.new(
:user_id => User.admin.id,
:remote_resource_id => CBRAIN::SelfRemoteResourceId,
:remote_resource_id => remote_resource_id,
:status => 'Scheduled',
:start_at => Time.now + 300.seconds,
)
Expand All @@ -48,7 +48,7 @@ def self.setup!
end

def process(task_id)
task = CbrainTask.where(:bourreau_id => CBRAIN::SelfRemoteResourceId).find(task_id)
task = CbrainTask.where(:bourreau_id => self.remote_resource_id).find(task_id)
full = task.full_cluster_workdir
return [ true, nil ] if Dir.exists?(full.to_s)
task.cluster_workdir = nil
Expand Down
3 changes: 2 additions & 1 deletion BrainPortal/app/models/boutiques_cluster_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def cluster_commands #:nodoc:
# Write down the file with the boutiques descriptor itself
File.open(boutiques_json_basename, "w") do |fh|
cleaned_desc = descriptor.dup
cleaned_desc.delete("groups") if cleaned_desc.groups.size == 0 # bosh is picky
cleaned_desc.delete("groups") if cleaned_desc.groups.blank? # bosh is picky
cleaned_desc.delete("error-codes") if cleaned_desc["error-codes"].blank? # and stupid
fh.write JSON.pretty_generate(cleaned_desc)
fh.write "\n"
end
Expand Down
3 changes: 3 additions & 0 deletions BrainPortal/app/models/resource_usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class ResourceUsage < ApplicationRecord

before_save :record_names_and_types

scope :increased, -> { where( "resource_usage.value > 0" ) }
scope :decreased, -> { where( "resource_usage.value < 0" ) }

# If any of the "_id" attributes are provided,
# then we also automatically fill in the duplicated
# information that we keep about the associated object.
Expand Down

0 comments on commit 16dc3aa

Please sign in to comment.