coderunner 0.15.13 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdaa33a0e55c8b08f7a428e1437ff88bbfb2098d
4
- data.tar.gz: 93fb05648880a150f5bbc3bce9713c64dd97d803
3
+ metadata.gz: 36a2ab737409ab9ede37d1a6f47e46a04010e9da
4
+ data.tar.gz: 71e146afb88edc85f38f22383143a2b8f7733de3
5
5
  SHA512:
6
- metadata.gz: 67d87ac7d6d8793c7dc3ab8deaa3dcb4de405f4cc0388fd625c93c66681e7bf0775664504f1a6f217078cbb6f1cc21603bd457ee6044fab4a5e6063042da7f7d
7
- data.tar.gz: 981c6767312f1ed06f6d555a5ef5c74da9cf77a15b6346363593d8d9b51d306e69b712c49ccea4832d548e3d9be8f96c0d5d03823d4e4150a1b56d6f23660626
6
+ metadata.gz: cee9710214d38427cf1b31e4c7625285a0ca91f0a2fca81f94045fe36f999d88a2829b27ab910971ebfb0d627d1c77ee73905a47dc95ae158169416f1da1b9ce
7
+ data.tar.gz: df4bf451b827b51a5c76f0520cd7cb8c8999e992abcaa44d56c25b6bb2025cb7a023695bb485bb72b1a2e634a76307454d2e29453cbec9ab7df0b5b1e22af3a2
data/Gemfile CHANGED
@@ -9,6 +9,8 @@ source "http://rubygems.org"
9
9
  gem "gsl_extras", ">= 0.3.0"
10
10
  #gem "ruby-netcdf", ">= 0.6.6"
11
11
  gem "hostmanager", "> 0.1.0"
12
+ gem "command-line-flunky", "> 0.1.0"
13
+ gem "git", ">= 1.2.9"
12
14
 
13
15
  # Add dependencies to develop your gem here.
14
16
  # Include everything needed to run rake, tests, features, etc.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.13
1
+ 0.16.0
data/coderunner.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: coderunner 0.15.13 ruby lib
5
+ # stub: coderunner 0.16.0 ruby lib
6
6
  # stub: ext/extconf.rb
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "coderunner"
10
- s.version = "0.15.13"
10
+ s.version = "0.16.0"
11
11
 
12
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Edmund Highcock"]
15
- s.date = "2015-04-09"
15
+ s.date = "2015-05-13"
16
16
  s.description = "CodeRunner is a framework for the automated running and analysis of simulations. It automatically generates any necessary input files, organises the output data and analyses it. Because it is a modular system, it can easily be customised to work with any system and any simulation code. One of its greatest strengths is that it is independent of any one simulation code; thus it can easily plot and compare the data from different codes."
17
17
  s.email = "edmundhighcock@sourceforge.net"
18
18
  s.executables = ["coderunner"]
@@ -50,6 +50,8 @@ Gem::Specification.new do |s|
50
50
  "lib/coderunner/long_regexen.rb",
51
51
  "lib/coderunner/merged_code_runner.rb",
52
52
  "lib/coderunner/remote_code_runner.rb",
53
+ "lib/coderunner/repository.rb",
54
+ "lib/coderunner/repository_manager.rb",
53
55
  "lib/coderunner/run.rb",
54
56
  "lib/coderunner/system_modules/archer.rb",
55
57
  "lib/coderunner/system_modules/blue_joule.rb",
@@ -89,13 +91,14 @@ Gem::Specification.new do |s|
89
91
  "test/fortran_namelist.in",
90
92
  "test/helper.rb",
91
93
  "test/old_test.rb",
92
- "test/test_coderunner.rb"
94
+ "test/test_coderunner.rb",
95
+ "test/test_coderunnerrepo.rb"
93
96
  ]
94
97
  s.homepage = "http://coderunner.sourceforge.net"
95
98
  s.licenses = ["GPLv3"]
96
99
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.1")
97
100
  s.rubyforge_project = "coderunner"
98
- s.rubygems_version = "2.2.2"
101
+ s.rubygems_version = "2.4.6"
99
102
  s.summary = "A framework for the automated running and analysis of simulations."
100
103
 
101
104
  if s.respond_to? :specification_version then
@@ -108,6 +111,8 @@ Gem::Specification.new do |s|
108
111
  s.add_runtime_dependency(%q<rb-gsl>, [">= 1.12.0"])
109
112
  s.add_runtime_dependency(%q<gsl_extras>, [">= 0.3.0"])
110
113
  s.add_runtime_dependency(%q<hostmanager>, ["> 0.1.0"])
114
+ s.add_runtime_dependency(%q<command-line-flunky>, ["> 0.1.0"])
115
+ s.add_runtime_dependency(%q<git>, [">= 1.2.9"])
111
116
  s.add_development_dependency(%q<shoulda>, [">= 0"])
112
117
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
113
118
  s.add_development_dependency(%q<bundler>, ["> 1.0.0"])
@@ -119,6 +124,8 @@ Gem::Specification.new do |s|
119
124
  s.add_dependency(%q<rb-gsl>, [">= 1.12.0"])
120
125
  s.add_dependency(%q<gsl_extras>, [">= 0.3.0"])
121
126
  s.add_dependency(%q<hostmanager>, ["> 0.1.0"])
127
+ s.add_dependency(%q<command-line-flunky>, ["> 0.1.0"])
128
+ s.add_dependency(%q<git>, [">= 1.2.9"])
122
129
  s.add_dependency(%q<shoulda>, [">= 0"])
123
130
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
124
131
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
@@ -131,6 +138,8 @@ Gem::Specification.new do |s|
131
138
  s.add_dependency(%q<rb-gsl>, [">= 1.12.0"])
132
139
  s.add_dependency(%q<gsl_extras>, [">= 0.3.0"])
133
140
  s.add_dependency(%q<hostmanager>, ["> 0.1.0"])
141
+ s.add_dependency(%q<command-line-flunky>, ["> 0.1.0"])
142
+ s.add_dependency(%q<git>, [">= 1.2.9"])
134
143
  s.add_dependency(%q<shoulda>, [">= 0"])
135
144
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
136
145
  s.add_dependency(%q<bundler>, ["> 1.0.0"])
data/lib/coderunner.rb CHANGED
@@ -70,7 +70,7 @@ require "getoptlong"
70
70
  require "thread"
71
71
  require "fileutils"
72
72
  require "drb"
73
- require "test/unit/assertions"
73
+ #require "test/unit/assertions"
74
74
  require 'parallelpipes'
75
75
  require 'find'
76
76
 
@@ -112,6 +112,8 @@ load CodeRunner::SCRIPT_FOLDER + "/fortran_namelist.rb"
112
112
  eprint '.' unless $has_put_startup_message_for_code_runner
113
113
  load CodeRunner::SCRIPT_FOLDER + "/fortran_namelist_c.rb"
114
114
  eprint '.' unless $has_put_startup_message_for_code_runner
115
+ load CodeRunner::SCRIPT_FOLDER + "/repository.rb"
116
+ eprint '.' unless $has_put_startup_message_for_code_runner
115
117
 
116
118
  CodeRunner::CODE_RUNNER_VERSION = Version.new(Gem.loaded_specs['coderunner'].version.to_s) rescue "test"
117
119
 
@@ -171,6 +171,15 @@ class CodeRunner
171
171
  key = LONG_TO_SHORT.key(key) if LONG_TO_SHORT.key(key)
172
172
  set(key, value) if value
173
173
  end
174
+ if is_in_repo?
175
+ repo = Repository.open_in_subfolder(@root_folder)
176
+ Dir.chdir(@root_folder) do
177
+ repo.add('.code_runner_script_defaults.rb')
178
+ repo.autocommit("Updated script defaults in #{repo.relative_path}")
179
+ #repo.add('.code-runner-irb-save-history')
180
+ end
181
+ end
182
+
174
183
  # ep options
175
184
 
176
185
  log 'modlet in initialize', @modlet
@@ -1193,7 +1202,13 @@ Conditions contain a single = sign: #{conditions}
1193
1202
  runs.each do |run|
1194
1203
  # ep run.id, run_list.keys
1195
1204
  Dir.chdir(run.directory){traverse_directories}
1205
+
1196
1206
  end
1207
+ if is_in_repo? @root_folder
1208
+ runs.each do |run|
1209
+ Dir.chdir(run.directory){run.add_to_repo}
1210
+ end
1211
+ end
1197
1212
  @write_status_dots = wsd
1198
1213
  save_large_cache
1199
1214
  File.delete("submitting")
@@ -17,6 +17,14 @@ class CodeRunner
17
17
  def setup_interactive
18
18
  @runner = CodeRunner.fetch_runner(CodeRunner::DEFAULT_COMMAND_OPTIONS.dup) unless CodeRunner::DEFAULT_COMMAND_OPTIONS[:q]
19
19
  @r = @runner
20
+ if FileTest.exist?(@r.root_folder + '/.code-runner-irb-save-history')
21
+ if @r.is_in_repo?
22
+ repo = Repository.open_in_subfolder(@r.root_folder)
23
+ repo.add(@r.root_folder + '/.code-runner-irb-save-history')
24
+ repo.autocommit("--Updated save history in #{repo.relative_path(@r.root_folder)}")
25
+ end
26
+ end
27
+
20
28
  end
21
29
  def pwd
22
30
  puts Dir.pwd
@@ -0,0 +1,186 @@
1
+ require 'git'
2
+ class CodeRunner
3
+ def is_in_repo?(folder=@root_folder)
4
+ Repository.repo_folder(folder) ? true : false
5
+ end
6
+ class Run
7
+ # Add CodeRunner files within the run folder to git. If
8
+ # the run_class for this run defines the run class property
9
+ # repo_file_match, also add any files which match any of
10
+ def add_to_repo
11
+ Dir.chdir(@directory) do
12
+ repo = Repository.open_in_subfolder
13
+ repo.add("code_runner_info.rb")
14
+ repo.add("code_runner_results.rb")
15
+ Dir.entries.each do |f|
16
+ repo.add(f) if rcp.repo_file_match? and f =~ rcp.repo_file_match
17
+ end
18
+ repo.autocommit("Submitted simulation id #{id} in folder #{repo.relative_path(@runner.root_folder)}")
19
+ end
20
+ end
21
+ end
22
+ # This is a class which implements methods
23
+ # for managing a CodeRunner repository, which is a
24
+ # slightly customised git repository. It contains
25
+ # methods for initializing standard files, and maintains
26
+ # a small amount of metadata about the repository.
27
+ class Repository < Git::Base
28
+ # If the folder is within a coderunner repository
29
+ # return the root folder of the repository; else
30
+ # return nil
31
+ def self.repo_folder(folder = Dir.pwd)
32
+ f2 = File.expand_path(folder)
33
+ while not (Dir.entries(f2).include?('.git') and
34
+ Dir.entries(f2).include?('.code_runner_repo_metadata'))
35
+ f2 = File.expand_path(f2 + '/..')
36
+ (f2=nil; break) if f2 == '/'
37
+ p 'f2 is ', f2
38
+ end
39
+ return f2
40
+ end
41
+ # Open a git object from within a subfolder of a repository
42
+ # Checks to see if the subfolder actually is inside a CodeRunner
43
+ # repository.
44
+ def self.open_in_subfolder(folder = Dir.pwd)
45
+ f2 = repo_folder(folder)
46
+ raise "#{folder} is not a coderunner repository " if not f2
47
+ return open(f2)
48
+ end
49
+ def relative_path(folder=Dir.pwd)
50
+ File.expand_path(folder).sub(File.expand_path(dir.to_s) + '/', '')
51
+ end
52
+ def repo_file(path)
53
+ "#{dir}/#{path}"
54
+ end
55
+ def init_readme
56
+ File.open(repo_file("README.md"), "w"){|f| f.puts readme_text}
57
+ add(repo_file("README.md"))
58
+ autocommit_all('Added README.md')
59
+ end
60
+ def init_metadata
61
+ Hash.phoenix(repo_file('.code_runner_repo_metadata')) do |hash|
62
+ hash[:creation_time] = Time.now.to_i
63
+ hash[:autocommit] = true
64
+ end
65
+ add(repo_file('.code_runner_repo_metadata'))
66
+ autocommit_all('Added metadata')
67
+ end
68
+ def metadata
69
+ Hash.phoenix(repo_file('.code_runner_repo_metadata'))
70
+ end
71
+ def add_folder(folder)
72
+ Dir.chdir(folder) do
73
+ require 'find'
74
+ #files = []
75
+ Find.find('.') { |e| (puts e; add(e)) if
76
+ e =~ /code_runner_info.rb/ or
77
+ e =~ /code_runner_results.rb/ or
78
+ e =~ /.code-runner-irb-save-history/ or
79
+ e =~ /.code_runner_script_defaults.rb/ or
80
+ (Dir.entries(Dir.pwd).include?('.code_runner_script_defaults') and
81
+ (repo_file_match = (
82
+ rcp = CodeRunner.fetch_runner(Y: folder, U: true).run_class.rcp;
83
+ rcp.repo_file_match? ? rcp.repo_file_match : false);
84
+ repo_file_match =~ m
85
+ )
86
+ )
87
+ }
88
+ end
89
+ autocommit_all("Added folder #{relative_path(folder)}")
90
+ end
91
+ def autocommit(*args)
92
+ commit(*args) if metadata[:autocommit]
93
+ end
94
+ def autocommit_all(*args)
95
+ commit_all(*args) if metadata[:autocommit]
96
+ end
97
+ def init_defaults_folder
98
+ FileUtils.makedirs(repo_file("defaults_files"))
99
+ File.open(repo_file("defaults_files/README"), "w"){|f|
100
+ f.puts <<EOF
101
+ This folder is where defaults files for codes should be placed, with
102
+ paths such as defaults_files/<code>crmod/my_defaults.rb. This folder
103
+ will automatically be checked for defaults files when submitting simulations
104
+ within this repository.
105
+ EOF
106
+
107
+ }
108
+ add(repo_file("defaults_files/README"))
109
+ autocommit_all('Added defaults folder')
110
+ end
111
+ def readme_text
112
+ return <<EOF
113
+ #{File.basename(dir.path)} CodeRunner Repository
114
+ ================================================
115
+
116
+ This is a coderunner repository, which consists of
117
+ a managed set of simulation folders and defaults files which are
118
+ synchronised across systems using git.
119
+
120
+ This readme is a stub which was created automatically...
121
+ feel free to modify this and describe this repo.
122
+
123
+ Created on: #{Time.now.to_s}
124
+
125
+ EOF
126
+ end
127
+ def split_url(remote_name)
128
+ remote(remote_name).url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
129
+ namehost = $~[:namehost]
130
+ folder = $~[:folder]
131
+ return [namehost, folder]
132
+ end
133
+ def changed_in_folder(folder)
134
+ status.changed.find_all{|k,f| File.expand_path(dir.to_s + '/' + f.path).include?(File.expand_path(folder))}
135
+ end
136
+ # Bring all files in the given folder from
137
+ # the given remote. (Obviously folder must
138
+ # be a subfolder within the repository).
139
+ def rsyncd(remote_name, folder)
140
+ #f2 = File.expand_path(folder)
141
+ namehost, remote_folder = split_url(remote_name)
142
+ rpath = relative_path(folder)
143
+ if File.expand_path(folder) == File.expand_path(dir.to_s)
144
+ raise "Cannot run rsyncd in the top level of a repository"
145
+ end
146
+ string = "rsync -av #{namehost}:#{remote_folder}/#{rpath}/ #{folder}/"
147
+ #Dir.chdir(folder) do
148
+ #FileUtils.touch('dummyfile')
149
+ #add('dummyfile')
150
+ #autocommit_all('--Added dummyfile')
151
+ #system "echo 'Hello' >> dummyfile"
152
+ ##add('dummyfile')
153
+ #end
154
+ #p status.changed.map{|k,f| [p1=File.expand_path(folder), p2=File.expand_path(dir.to_s + '/' + f.path), p2.include?(p1), p1.include?(p2)]}
155
+ #p changed_in_folder(folder).map{|k,f| f.path}
156
+ if changed_in_folder(folder).size > 0
157
+ raise "You have some uncommitted changes in the folder #{folder}. Please commit these changes before calling rsyncd"
158
+ end
159
+ puts string
160
+ system string
161
+ end
162
+ # Send all files in the given folder to
163
+ # the given remote. (Obviously folder must
164
+ # be a subfolder within the repository).
165
+ def rsyncu(remote_name, folder)
166
+ #f2 = File.expand_path(folder)
167
+ namehost, remote_folder = split_url(remote_name)
168
+ rpath = relative_path(folder)
169
+ if File.expand_path(folder) == File.expand_path(dir.to_s)
170
+ raise "Cannot run rsyncd in the top level of a repository"
171
+ end
172
+ string = "rsync -av #{folder}/ #{namehost}:#{remote_folder}/#{rpath}/"
173
+ #p status.changed.map{|k,f| [p1=File.expand_path(folder), p2=File.expand_path(dir.to_s + '/' + f.path), p2.include?(p1), p1.include?(p2)]}
174
+ #p changed_in_folder(folder).map{|k,f| f.path}
175
+
176
+ cif = `ssh #{namehost} "cd #{remote_folder}/#{rpath} && echo "START" && git status"`
177
+ #p cif
178
+ if cif =~ /START.*modified/m
179
+ raise "You have some uncommitted changes in the remote folder #{rpath}. Please commit these changes before calling rsyncu"
180
+ end
181
+ puts string
182
+ system string
183
+ end
184
+ end
185
+
186
+ end
@@ -0,0 +1,210 @@
1
+
2
+
3
+ # A tool for reading, manipulating and converting files containing
4
+ # tokamak data.
5
+
6
+ require 'getoptlong'
7
+
8
+ module CommandLineFlunky
9
+
10
+ STARTUP_MESSAGE = "\n------CodeRunner Repository Manager------"
11
+
12
+ MANUAL_HEADER = <<EOF
13
+
14
+ -------------CodeRunner Repository Manager Manual---------------
15
+
16
+ Written by Edmund Highcock (2014)
17
+
18
+ NAME
19
+
20
+ coderunnerrepo
21
+
22
+
23
+ SYNOPSIS
24
+
25
+ coderunnerrepo <command> [arguments] [options]
26
+
27
+
28
+ DESCRIPTION
29
+
30
+ Create and manipulate a coderunner repository: a collection of simulation
31
+ folders and defaults files that a synchronised across systems using git.
32
+
33
+ EXAMPLES
34
+
35
+ $ coderunnerrepo init <name>
36
+
37
+ $ coderunnerrepo clone <url>
38
+
39
+ $ coderunnerrepo pull
40
+
41
+ $ coderunnerrepo pull -r <remote>
42
+
43
+ $ coderunnerrepo push
44
+
45
+ $ coderunnerrepo add <folder>
46
+
47
+ $ coderunnerrepo adrm <name> <url>
48
+
49
+
50
+ EOF
51
+
52
+ COMMANDS_WITH_HELP = [
53
+ ['add_remote', 'adrm', 2, 'Add a remote url to the repository.', ['name', 'url'], [:Y]],
54
+ ['add_folder', 'add', 1, 'Add the folder to the repository... this adds the directory tree and all coderunner data files to the repository, e.g. .code_runner_info.rb, script defaults, command histories etc. Note that this command must be issued in the root of the repository, or with the -Y flag giving the root of the repository.', ['folder'], [:Y]],
55
+ ['init_repository', 'init', 1, 'Create a new repository with the given name.', ['name'], []],
56
+ ['pull_repository', 'pull', 2, 'Pull repository from all remotes, or from a comma-separated list of remotes given by the -r option.', ['name', 'url'], [:r, :Y]],
57
+ ['push_and_create_repository', 'pushcr', 2, 'Push to a comma-separated list of remotes given by the -r option; this command assumes that there is no repository on the remote and creates a bundle which is then copied to and cloned on the remote destination to create the repository.', ['name', 'url'], [:r, :Y]],
58
+ ['push_repository', 'push', 2, 'Push repository to all remotes, or to a comma-separated list of remotes given by the -r option.', ['name', 'url'], [:r, :Y]],
59
+ ['remote_synchronize_down', 'rsyncd', 2, 'Bring the contents of the remote folder corresponding to the given folder (which must be a subfolder of a local coderunner repository) to the local system. The folder cannot be the top level of the repository. This command uses rsync to actually copy the files. The --delete option is not specified (i.e. files that do not exist on the remote will not be deleted).', ['remote', 'folder'], []],
60
+ ['set_repo_metadata', 'mdata', 1, "Give a hash of metadata to modify e.g., '{autocommit: false}. Things that can be modified are: autocommit: true/false, automatically commit repo changes made by CodeRunner, default true'.", ['hash'], [:Y]],
61
+
62
+ ]
63
+
64
+
65
+
66
+ COMMAND_LINE_FLAGS_WITH_HELP = [
67
+ #['--boolean', '-b', GetoptLong::NO_ARGUMENT, 'A boolean option'],
68
+ ['--remotes', '-r', GetoptLong::REQUIRED_ARGUMENT, 'A comma separated list of remotes.'],
69
+ ['--other-folder', '-Y', GetoptLong::REQUIRED_ARGUMENT, 'Specify the path of the folder where you want to run this command.'],
70
+
71
+ ]
72
+
73
+ LONG_COMMAND_LINE_OPTIONS = [
74
+ #["--no-short-form", "", GetoptLong::NO_ARGUMENT, %[This boolean option has no short form]],
75
+ ]
76
+
77
+ # specifying flag sets a bool to be true
78
+
79
+ CLF_BOOLS = []
80
+
81
+ CLF_INVERSE_BOOLS = [] # specifying flag sets a bool to be false
82
+
83
+ PROJECT_NAME = 'coderunnerrepo'
84
+
85
+ def self.method_missing(method, *args)
86
+ # p method, args
87
+ CodeRunner::RepositoryManager.send(method, *args)
88
+ end
89
+
90
+ #def self.setup(copts)
91
+ #CommandLineFlunkyTestUtility.setup(copts)
92
+ #end
93
+
94
+ SCRIPT_FILE = __FILE__
95
+ end
96
+
97
+ $has_put_startup_message_for_code_runner = true
98
+ require 'coderunner'
99
+
100
+ class CodeRunner
101
+ # A class for managing a coderunner repository, which consists of
102
+ # a managed set of simulation folders and defaults files which are
103
+ # synchronised across systems using git.
104
+ class RepositoryManager
105
+ class << self
106
+ # This function gets called before every command
107
+ # and allows arbitrary manipulation of the command
108
+ # options (copts) hash
109
+ def setup(copts)
110
+ copts[:Y] ||= Dir.pwd
111
+ copts[:Y] = File.expand_path(copts[:Y])
112
+ end
113
+ def verbosity
114
+ 2
115
+ end
116
+ def init_repository(name, copts)
117
+ repo = Repository.init(name)
118
+ repo.init_metadata
119
+ repo.init_readme
120
+ repo.init_defaults_folder
121
+ end
122
+ def add_remote(name, url, copts)
123
+ Dir.chdir(copts[:Y]){
124
+ repo = Repository.open(Dir.pwd)
125
+ repo.add_remote(name, url)
126
+ }
127
+ end
128
+ def try_system(str)
129
+ raise "Failed command: #{str}" unless system str
130
+ end
131
+ def push_and_create_repository(copts)
132
+ Dir.chdir(copts[:Y]){
133
+ repo = Repository.open(Dir.pwd)
134
+ if copts[:r]
135
+ rems = copts[:r].split(/,/).map{|rname| repo.remote(rname)}
136
+ else
137
+ raise "Must specify remotes using the -r flag when calling push_and_create_repository"
138
+ end
139
+ rems.each do |r|
140
+ r.url =~ (/ssh:\/\/(?<namehost>[^\/]+)(?<folder>.*$)/)
141
+ namehost = $~[:namehost]
142
+ folder = $~[:folder]
143
+ p namehost, folder
144
+ try_system %[git bundle create .tmpbundle --all]
145
+ try_system %[ssh #{namehost} "mkdir -p #{folder}"]
146
+ try_system %[scp .tmpbundle #{namehost}:#{folder}/../.]
147
+ try_system %[rm .tmpbundle]
148
+ #try_system %[ssh #{namehost} "cd #{folder} && git clone .tmpbundle #{repname = File.basename(repo.dir.to_s)} "]
149
+ try_system %[ssh #{namehost} "cd #{folder} && git clone ../.tmpbundle ."]
150
+ #try_system %[ssh #{namehost} "cd #{folder}/#{repname} && git remote rm origin"]
151
+ try_system %[ssh #{namehost} "cd #{folder} && git remote rm origin"]
152
+ #push_repository(copts.dup.absorb(r: r.name))
153
+ repo.remotes.each do |other_remote|
154
+ next if other_remote.name == r.name
155
+ try_system %[ssh #{namehost} "cd #{folder} && git remote add #{other_remote.name} #{other_remote.url}"]
156
+ #try_system %[ssh #{namehost} "cd #{folder} && git remote add #{other_remote.name} #{other_remote.url}"]
157
+ end
158
+ end
159
+ }
160
+ end
161
+ def push_repository(copts)
162
+ Dir.chdir(copts[:Y]){
163
+ repo = Repository.open(Dir.pwd)
164
+ if copts[:r]
165
+ rems = copts[:r].split(/,/).map{|rname| repo.remote(rname)}
166
+ else
167
+ rems = repo.remotes
168
+ end
169
+ rems.each{|r| repo.push(r)}
170
+ }
171
+ end
172
+ def pull_repository(copts)
173
+ Dir.chdir(copts[:Y]){
174
+ repo = Repository.open(Dir.pwd)
175
+ if copts[:r]
176
+ rems = copts[:r].split(/,/).map{|rname| repo.remote(rname)}
177
+ else
178
+ rems = repo.remotes
179
+ end
180
+ rems.each{|r| repo.pull(r)}
181
+ }
182
+ end
183
+ def add_folder(folder, copts)
184
+ repo = Repository.open_in_subfolder(folder)
185
+ repo.add_folder(folder)
186
+ end
187
+ def remote_synchronize_down(remote, folder, copts)
188
+ repo = Repository.open_in_subfolder(folder)
189
+ repo.rsyncd(remote, folder)
190
+ end
191
+ def remote_synchronize_up(remote, folder, copts)
192
+ repo = Repository.open_in_subfolder(folder)
193
+ repo.rsyncu(remote, folder)
194
+ end
195
+
196
+ end
197
+ end
198
+ end
199
+
200
+
201
+ ######################################
202
+ # This must be at the end of the file
203
+ #
204
+ require 'command-line-flunky'
205
+ ###############################
206
+ #
207
+
208
+ if $0==__FILE__
209
+ CommandLineFlunky.run_script
210
+ end
@@ -25,9 +25,11 @@ class CodeRunner
25
25
 
26
26
  @uses_mpi = false
27
27
 
28
+ @repo_file_match = /results.txt/
29
+
28
30
  #@readout_list = @variables + @results
29
31
 
30
- @code_module_folder = folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
32
+ @code_module_folder = File.dirname(File.expand_path(__FILE__)) # i.e. the directory this file is in
31
33
 
32
34
  @namelists_to_print_not_specified = []
33
35
 
data/test/helper.rb CHANGED
@@ -7,7 +7,8 @@ rescue Bundler::BundlerError => e
7
7
  $stderr.puts "Run `bundle install` to install missing gems"
8
8
  exit e.status_code
9
9
  end
10
- require 'test/unit'
10
+ require 'minitest'
11
+ require 'minitest/autorun'
11
12
  require 'shoulda'
12
13
 
13
14
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -17,5 +18,5 @@ require 'cubecalccrmod'
17
18
  require 'cubecalccrmod/sleep'
18
19
 
19
20
 
20
- class Test::Unit::TestCase
21
- end
21
+ #class Test::Unit::TestCase
22
+ #end
@@ -1,11 +1,11 @@
1
-
1
+ if true
2
2
  require 'helper'
3
3
  require 'rbconfig'
4
4
  CodeRunner::RemoteCodeRunner::DISPLAY_REMOTE_INVOCATION = true
5
5
 
6
6
 
7
7
 
8
- module Test::Unit::Assertions
8
+ module MiniTest::Assertions
9
9
  def assert_system(string)
10
10
  assert(system(string), "System Command: '#{string}'")
11
11
  end
@@ -23,7 +23,7 @@ $coderunner_command = "#{$ruby_command} -I lib/ lib/coderunner.rb"
23
23
  #end
24
24
 
25
25
  if true
26
- class TestSubmission < Test::Unit::TestCase
26
+ class TestSubmission < MiniTest::Test
27
27
  def setup
28
28
  string = $cpp_command + ' ../cubecalc.cc -o cubecalc'
29
29
  Dir.chdir('test'){CodeRunner.generate_cubecalc}
@@ -78,7 +78,7 @@ class TestSubmission < Test::Unit::TestCase
78
78
  end
79
79
 
80
80
 
81
- class TestCodeRunner < Test::Unit::TestCase
81
+ class TestCodeRunner < MiniTest::Test
82
82
 
83
83
  # Override this method as we want the tests to be run in the order they are defined
84
84
 
@@ -201,17 +201,17 @@ class TestCodeRunner < Test::Unit::TestCase
201
201
  assert_equal(21, @runner3.max_id)
202
202
  #eputs "\ntesting set_start_id complete"
203
203
  @runner3 = CodeRunner.new(tfolder2).update
204
- assert_nothing_raised{@mrunner = CodeRunner::Merged.new(@runner, @runner3)}
204
+ @mrunner = CodeRunner::Merged.new(@runner, @runner3)
205
205
  @mrunner.print_out(0)
206
206
  #STDIN.gets
207
207
  assert_equal(@runner.run_list.size + 1, @mrunner.run_list.size)
208
208
  @mrunner2 = @runner.merge(@runner3)
209
209
  assert_equal(@mrunner2.run_list.keys, @mrunner.run_list.keys)
210
- assert_nothing_raised{@mrunner.add_runner(@runner)}
210
+ @mrunner.add_runner(@runner)
211
211
  assert_equal(CodeRunner::Run::Merged, @mrunner.run_list[[2, 6]].class)
212
212
  assert_equal(6, @mrunner.run_list[[2, 6]].run.id)
213
213
  assert_system("#$coderunner_command st -Y #{tfolder} -Y #{tfolder2}")
214
- assert_raise(RuntimeError){@mrunner.submit}
214
+ assert_raises(RuntimeError){@mrunner.submit}
215
215
  #STDIN.gets
216
216
  FileUtils.rm_r tfolder2
217
217
  end
@@ -261,6 +261,7 @@ class TestCodeRunner < Test::Unit::TestCase
261
261
  #assert(!FileTest.exist?('results/submitting'))
262
262
  #end
263
263
 
264
+ if ENV['LATEX']
264
265
  def test_latex_graphkit
265
266
  Dir.chdir('test/results') do
266
267
  #@runner.print_out(0)
@@ -282,7 +283,6 @@ class TestCodeRunner < Test::Unit::TestCase
282
283
  end
283
284
  end
284
285
 
285
- if ENV['LATEX']
286
286
 
287
287
  def test_graphkit_multiplot
288
288
  unless ENV['SHORT_TEST']
@@ -375,7 +375,7 @@ EOF
375
375
  end # class TestCodeRunner
376
376
  end # if false/true
377
377
 
378
- #class TestFortranNamelist < Test::Unit::TestCase
378
+ #class TestFortranNamelist < MiniTest::Test
379
379
  ##require 'gs2crmod'
380
380
  #def test_make_defaults
381
381
  #Dir.chdir('test') do
@@ -387,7 +387,7 @@ end # if false/true
387
387
  #
388
388
  #
389
389
  ENV['CR_NON_INTERACTIVE'] = 'true'
390
- class TestFortranNamelistC < Test::Unit::TestCase
390
+ class TestFortranNamelistC < MiniTest::Test
391
391
  def setup
392
392
  end
393
393
  def test_synchronise_variables
@@ -421,3 +421,5 @@ class TestFortranNamelistC < Test::Unit::TestCase
421
421
  FileUtils.rm('test/cubecalc_namelist')
422
422
  end
423
423
  end
424
+
425
+ end
@@ -0,0 +1,95 @@
1
+
2
+ require 'helper'
3
+ require 'rbconfig'
4
+ require 'coderunner/repository_manager'
5
+
6
+ unless $cpp_command = ENV['CPP']
7
+ raise "Please specify the environment variable CPP (the C++ compiler)"
8
+ end
9
+ $coderunner_folder = File.dirname(File.expand_path(__FILE__)) + '/../'
10
+
11
+ module MiniTest::Assertions
12
+ def assert_system(string)
13
+ assert(system(string), "System Command: '#{string}'")
14
+ end
15
+ end
16
+
17
+ $ruby_command = "#{RbConfig::CONFIG['bindir']}/#{RbConfig::CONFIG['ruby_install_name']}"
18
+ $coderunnerrepo_command = "#{$ruby_command} -I #{$coderunner_folder}lib/ #{$coderunner_folder}/lib/coderunner/repository_manager.rb"
19
+
20
+ class Dummy
21
+ include CodeRunner::InteractiveMethods
22
+ end
23
+ class TestCreate < MiniTest::Test
24
+ def tfolder
25
+ 'test/createrepo'
26
+ end
27
+ def dffolder
28
+ 'myrepo/crdummyfiles'
29
+ end
30
+ def setup
31
+ FileUtils.rm_r(tfolder) if FileTest.exist? tfolder
32
+ FileUtils.makedirs(tfolder)
33
+ string = $cpp_command + ' ../cubecalc.cc -o cubecalc'
34
+ Dir.chdir('test'){CodeRunner.generate_cubecalc}
35
+ Dir.chdir(tfolder){assert_system string}
36
+ end
37
+ def test_create
38
+ Dir.chdir(tfolder) {
39
+ assert_system("#$coderunnerrepo_command init myrepo")
40
+ assert_system("#$coderunnerrepo_command adrm local ssh://#{ENV['USER']}@#{`hostname`.chomp}/#{Dir.pwd}/remote -Y myrepo")
41
+ assert_system("#$coderunnerrepo_command adrm dummy ssh://dummyuser@nohost/#{Dir.pwd}/remote -Y myrepo")
42
+ assert_system("#$coderunnerrepo_command pushcr -r local -Y myrepo")
43
+ #assert_equal(false, system("#$coderunnerrepo_command pushcr -r local -Y myrepo"))
44
+ assert_system("cd myrepo; git remote rm dummy")
45
+ assert_system("#$coderunnerrepo_command pull -Y myrepo")
46
+ FileUtils.makedirs(dffolder)
47
+ FileUtils.touch(dffolder + '/code_runner_info.rb')
48
+ FileUtils.touch(dffolder + '/code_runner_results.rb')
49
+ #assert_system("#$coderunnerrepo_command add myrepo/crdummyfiles -Y myrepo")
50
+ CodeRunner::RepositoryManager.add_folder('myrepo/crdummyfiles', {})
51
+ FileUtils.makedirs('myrepo/sims')
52
+ Dir.chdir('myrepo/sims') do
53
+ CodeRunner.submit(C: 'cubecalc', m: 'empty', X: '../../cubecalc')
54
+ FileUtils.touch('.code-runner-irb-save-history')
55
+ Dummy.new.setup_interactive
56
+ end
57
+ CodeRunner::RepositoryManager.remote_synchronize_up('local', 'myrepo/sims', {})
58
+ CodeRunner::RepositoryManager.remote_synchronize_down('local', 'myrepo/sims', {})
59
+ Dir.chdir('remote') do
60
+ FileUtils.makedirs 'sims'
61
+ Dir.chdir('sims') do
62
+ system "echo 'Hello' >> dummyfile"
63
+ #add('dummyfile')
64
+ system "git add dummyfile"
65
+ system "git commit -m 'added dummyfile'"
66
+ #autocommit_all('--Added dummyfile')
67
+ system "echo 'Hello' >> dummyfile"
68
+ end
69
+ #add('dummyfile')
70
+ end
71
+ err = assert_raises(RuntimeError){CodeRunner::RepositoryManager.remote_synchronize_up('local', 'myrepo/sims', {})}
72
+ p err.message
73
+ Dir.chdir('remote') do
74
+ Dir.chdir('sims') do
75
+ system "git add dummyfile"
76
+ system "git commit -m 'modified dummyfile'"
77
+ end
78
+ end
79
+ Dir.chdir('myrepo/sims') do
80
+ system "echo 'Hello' >> dummyfile"
81
+ #add('dummyfile')
82
+ system "git add dummyfile"
83
+ system "git commit -m 'added dummyfile'"
84
+ #autocommit_all('--Added dummyfile')
85
+ system "echo 'Hello' >> dummyfile"
86
+ end
87
+ err = assert_raises(RuntimeError){CodeRunner::RepositoryManager.remote_synchronize_down('local', 'myrepo/sims', {})}
88
+ p err.message
89
+ #CodeRunner::RepositoryManager.remote_synchronize_down('local', 'myrepo/sims', {})
90
+ }
91
+ end
92
+ def teardown
93
+ #FileUtils.rm_r(testfolder)
94
+ end
95
+ end
metadata CHANGED
@@ -1,153 +1,181 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coderunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.13
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edmund Highcock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-09 00:00:00.000000000 Z
11
+ date: 2015-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphkit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: parallelpipes
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubyhacks
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.1.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rb-gsl
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.12.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.12.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gsl_extras
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.3.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: hostmanager
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">"
87
+ - - '>'
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.1.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">"
94
+ - - '>'
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: command-line-flunky
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>'
102
+ - !ruby/object:Gem::Version
103
+ version: 0.1.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>'
109
+ - !ruby/object:Gem::Version
110
+ version: 0.1.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: git
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.2.9
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.2.9
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: shoulda
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
- - - ">="
129
+ - - '>='
102
130
  - !ruby/object:Gem::Version
103
131
  version: '0'
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - ">="
136
+ - - '>='
109
137
  - !ruby/object:Gem::Version
110
138
  version: '0'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: rdoc
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
- - - "~>"
143
+ - - ~>
116
144
  - !ruby/object:Gem::Version
117
145
  version: '3.12'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
- - - "~>"
150
+ - - ~>
123
151
  - !ruby/object:Gem::Version
124
152
  version: '3.12'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: bundler
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
- - - ">"
157
+ - - '>'
130
158
  - !ruby/object:Gem::Version
131
159
  version: 1.0.0
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
- - - ">"
164
+ - - '>'
137
165
  - !ruby/object:Gem::Version
138
166
  version: 1.0.0
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: jeweler
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
- - - ">="
171
+ - - '>='
144
172
  - !ruby/object:Gem::Version
145
173
  version: 2.0.0
146
174
  type: :development
147
175
  prerelease: false
148
176
  version_requirements: !ruby/object:Gem::Requirement
149
177
  requirements:
150
- - - ">="
178
+ - - '>='
151
179
  - !ruby/object:Gem::Version
152
180
  version: 2.0.0
153
181
  description: CodeRunner is a framework for the automated running and analysis of simulations.
@@ -166,7 +194,7 @@ extra_rdoc_files:
166
194
  - README.md
167
195
  - README.rdoc
168
196
  files:
169
- - ".document"
197
+ - .document
170
198
  - Gemfile
171
199
  - LICENSE.txt
172
200
  - README.md
@@ -193,6 +221,8 @@ files:
193
221
  - lib/coderunner/long_regexen.rb
194
222
  - lib/coderunner/merged_code_runner.rb
195
223
  - lib/coderunner/remote_code_runner.rb
224
+ - lib/coderunner/repository.rb
225
+ - lib/coderunner/repository_manager.rb
196
226
  - lib/coderunner/run.rb
197
227
  - lib/coderunner/system_modules/archer.rb
198
228
  - lib/coderunner/system_modules/blue_joule.rb
@@ -233,6 +263,7 @@ files:
233
263
  - test/helper.rb
234
264
  - test/old_test.rb
235
265
  - test/test_coderunner.rb
266
+ - test/test_coderunnerrepo.rb
236
267
  homepage: http://coderunner.sourceforge.net
237
268
  licenses:
238
269
  - GPLv3
@@ -243,17 +274,17 @@ require_paths:
243
274
  - lib
244
275
  required_ruby_version: !ruby/object:Gem::Requirement
245
276
  requirements:
246
- - - ">="
277
+ - - '>='
247
278
  - !ruby/object:Gem::Version
248
279
  version: 1.9.1
249
280
  required_rubygems_version: !ruby/object:Gem::Requirement
250
281
  requirements:
251
- - - ">="
282
+ - - '>='
252
283
  - !ruby/object:Gem::Version
253
284
  version: '0'
254
285
  requirements: []
255
286
  rubyforge_project: coderunner
256
- rubygems_version: 2.2.2
287
+ rubygems_version: 2.4.6
257
288
  signing_key:
258
289
  specification_version: 4
259
290
  summary: A framework for the automated running and analysis of simulations.