Skip to content
Snippets Groups Projects
Commit c62047d3 authored by Anusha Ranganathan's avatar Anusha Ranganathan
Browse files

Gather hidden files and fix rake task

parent 344d0cb2
No related branches found
No related tags found
1 merge request!359Gather hidden files and fix rake task
require 'json' require 'json'
require 'csv' require 'csv'
require 'find'
class VerifyCRCDatasetImport class VerifyCRCDatasetImport
extend ComplexHelper extend ComplexHelper
...@@ -66,11 +67,11 @@ class VerifyCRCDatasetImport ...@@ -66,11 +67,11 @@ class VerifyCRCDatasetImport
msg = "Error: Import entry #{entry_id} not found" msg = "Error: Import entry #{entry_id} not found"
return false, msg, paths_compared, nil return false, msg, paths_compared, nil
end end
paths_compared[source_identifier: entry.identifier] paths_compared[:source_identifier] = entry.identifier
# Check import id # Check import id
if import_id != entry.importerexporter_id if import_id != entry.importerexporter_id
msg = "Error: Importer id #{import_id} does not match id associated with entry #{entry_id}" msg = "Error: Importer id #{import_id} does not match id associated with entry #{entry.importerexporter_id}"
return false, msg, paths_compared, nil return false, msg, paths_compared, nil
end end
...@@ -124,11 +125,16 @@ class VerifyCRCDatasetImport ...@@ -124,11 +125,16 @@ class VerifyCRCDatasetImport
# Get files to compare # Get files to compare
# -- Get list of files from import directory # -- Get list of files from import directory including hidden files
input_list = Dir.glob(File.join(import_path, '**', '*')). input_list = []
reject {|fn| File.directory?(fn) }. ::Find.find(import_path) do |fp|
reject{|fn| self.restricted_file_names?(fn.split('/')[-1])}. unless FileTest.directory?(fp)
map{ |fn| fn.sub(import_path, '')}.sort unless self.restricted_file_names?(fp.split('/')[-1])
input_list << fp.sub(import_path, '')
end
end
end
input_list.sort
# ---- downcase folder name # ---- downcase folder name
sanitised_input_list = {} sanitised_input_list = {}
input_list.each do |fp| input_list.each do |fp|
......
...@@ -2,17 +2,18 @@ require 'json' ...@@ -2,17 +2,18 @@ require 'json'
namespace :rdms do namespace :rdms do
namespace :crc_1280_import do namespace :crc_1280_import do
desc 'Verify CRC1280 import or verify CRC1280 import of an experiment. This will compare the files in the file path with the objects in the S3 bucket"]' desc 'Verify all experiments in CRC1280 import. This will compare the files in the file path with the objects in the S3 bucket'
task :"verify_import", [:import_id] => :environment do |task, args| task :verify_import, [:import_id] => :environment do |task, args|
puts "Verifying import #{args.import_id}" puts "Verifying import #{args.import_id.to_i}"
import_status, report_paths = VerifyCRCDatasetImport.verify_import(args.import_id) import_status, report_paths = VerifyCRCDatasetImport.verify_import(args.import_id.to_i)
puts "import status : #{import_status}" puts "import status : #{import_status}"
puts "Detailed reports are available at:" puts "Detailed reports are available at:"
puts JSON.pretty_generate(report_paths) puts JSON.pretty_generate(report_paths)
end end
task :"verify_experiment", [:import_id, :entry_id] => :environment do |task, args| desc 'Verify experiment in CRC1280 import. This will compare the files in the file path with the objects in the S3 bucket'
puts "Verifying import #{args.import_id}" task :verify_experiment, [:import_id, :entry_id] => :environment do |task, args|
experiment_status, report_path = VerifyCRCDatasetImport.verify_experiment_and_report(args.import_id, args.entry_id) puts "Verifying experiment #{args.entry_id.to_i} in import #{args.import_id.to_i}"
experiment_status, report_path = VerifyCRCDatasetImport.verify_experiment_and_report(args.import_id.to_i, args.entry_id.to_i)
puts "Experiment import status : #{experiment_status}" puts "Experiment import status : #{experiment_status}"
puts "Detailed reports is available at: #{report_path}" puts "Detailed reports is available at: #{report_path}"
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment