Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions apps/dashboard/app/models/concerns/job_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def jobs(directory)
class JobLoggerHelper
class << self
def log_file(directory)
Pathname.new("#{directory}/.ondemand/job_log.yml").tap do |path|
FileUtils.touch(path.to_s) unless path.exist?
end
Pathname.new("#{directory}/.ondemand/job_log.yml")
end

def write_log(directory, jobs)
Expand Down
4 changes: 4 additions & 0 deletions apps/dashboard/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ def update_attrs(attributes)
def make_dir
project_dataroot.mkpath unless project_dataroot.exist?
configuration_directory.mkpath unless configuration_directory.exist?
workflow_directory = Workflow.workflow_dir(project_dataroot)
workflow_directory.mkpath unless workflow_directory.exist?
logfile_path = JobLogger::JobLoggerHelper.log_file(project_dataroot)
FileUtils.touch(logfile_path.to_s) unless logfile_path.exist?
true
rescue StandardError => e
errors.add(:save, "Failed to make directory: #{e.message}")
Expand Down
4 changes: 1 addition & 3 deletions apps/dashboard/app/models/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ class Workflow

class << self
def workflow_dir(project_dir)
dir = Pathname.new("#{project_dir}/.ondemand/workflows")
FileUtils.mkdir_p(dir) unless dir.exist?
dir
Pathname.new("#{project_dir}/.ondemand/workflows")
end

def find(id, project_dir)
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/test/models/projects_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class ProjectsTest < ActiveSupport::TestCase
assert Dir.glob(cache_json_path).present? &&
Dir.glob("#{project.directory}/.ondemand/launchers/*/cache.json").empty?
assert Dir.glob(job_log_path).present? &&
Dir.glob("#{project.directory}/.ondemand/*").exclude?("#{project.directory}/.ondemand/job_log.yml")
File.read("#{project.directory}/.ondemand/job_log.yml").empty?
end
end

Expand Down
5 changes: 4 additions & 1 deletion apps/dashboard/test/models/workflow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class WorkflowsTest < ActiveSupport::TestCase

invalid_directory = tmp
workflow = Workflow.new({ name: 'test', project_dir: invalid_directory.to_s})

# this step is done by the project
Workflow.workflow_dir(invalid_directory).mkpath
assert workflow.save
assert_equal 0, workflow.errors.size
end
Expand Down Expand Up @@ -128,6 +129,8 @@ class WorkflowsTest < ActiveSupport::TestCase
def create_workflow(id: nil, name: 'test-workflow', description: 'description', project_dir: nil, launcher_ids: [], source_ids: [], target_ids: [])
attrs = { name: name, id: id, description: description, project_dir: project_dir, launcher_ids: launcher_ids, source_ids: source_ids, target_ids: target_ids}
workflow = Workflow.new(attrs)
# this directory is usually created by the project
Workflow.workflow_dir(project_dir).mkpath
assert workflow.save

workflow
Expand Down