Skip to content

Commit cd871ee

Browse files
committed
experiment class can be handled from arbitrary directory
1 parent 77aa292 commit cd871ee

File tree

10 files changed

+169
-118
lines changed

10 files changed

+169
-118
lines changed

src/davai_env/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@
1010
import io
1111
import subprocess
1212

13-
__version__ = "1.2.0"
13+
__version__ = "1.2.1"
1414

1515
# fixed parameters
1616
DAVAI_RC_DIR = os.path.join(os.environ['HOME'], '.davairc')
1717
DAVAI_XP_COUNTER = os.path.join(DAVAI_RC_DIR, '.last_xp')
1818
DAVAI_XPID_SYNTAX = 'dv-{xpid_num:04}-{host}@{user}'
19-
DAVAI_XPID_RE = re.compile('^' + DAVAI_XPID_SYNTAX.replace('{xpid_num:04}', '\d+').
20-
replace('-{host}', '(-\w+)?').
21-
replace('{user}', '\w+') + '$')
19+
DAVAI_XPID_RE = re.compile(r'^dv-(?P<num>\d{4})-(?P<host>\w+)@(?P<user>\w+)$')
20+
#DAVAI_XPID_RE = re.compile('^' + DAVAI_XPID_SYNTAX.replace('{xpid_num:04}', '\d+').
21+
# replace('-{host}', '(-\w+)?').
22+
# replace('{user}', '\w+') + '$')
2223
CONFIG_USER_FILE = os.path.join(DAVAI_RC_DIR, 'user_config.ini')
2324

25+
#: usecases implemented
26+
usecases = ('NRV', 'ELP')
27+
#: vortex application
28+
vapp = 'davai'
29+
2430

2531
def guess_host():
2632
"""

src/davai_env/cli/build.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import argparse
55

6-
from ..experiment import ThisXP
6+
from ..experiment import XP
77

88
__all__ = ['main']
99

1010

1111
def main():
1212
args = get_args()
13-
this_xp = ThisXP()
13+
this_xp = XP(args.experiment)
1414
this_xp.build(
1515
skip_fetching_sources=args.skip_fetching_sources,
1616
drymode=args.drymode,
@@ -22,7 +22,16 @@ def main():
2222

2323

2424
def get_args():
25-
parser = argparse.ArgumentParser(description='Fetch sources (interactively) and build executables (batch/scheduler). To be executed from the XP directory !')
25+
parser = argparse.ArgumentParser(description=" ".join([
26+
'Fetch sources (interactively) and build executables (batch/scheduler).'
27+
'To be executed from the XP directory !']))
28+
parser.add_argument('experiment',
29+
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
30+
"a piece of path to grab the experiment.",
31+
"Defaults to current working directory.",
32+
]),
33+
nargs='?',
34+
default='.')
2635
parser.add_argument('-s', '--skip_fetching_sources',
2736
action='store_true',
2837
help="Skip fetching the sources (assuming they have been fetched / and pack preexists for gmkpack).")

src/davai_env/cli/ciboulai_init.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33

44
import argparse
55

6-
from ..experiment import ThisXP
6+
from ..experiment import XP
77

88
__all__ = ['main']
99

1010
def main():
1111
parser = argparse.ArgumentParser(description="(Re-)Initialize experiment in Ciboulai dashboard server. " +
1212
"To be executed from the XP directory !")
13+
parser.add_argument('experiment',
14+
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
15+
"a piece of path to grab the experiment.",
16+
"Defaults to current working directory.",
17+
]),
18+
nargs='?',
19+
default='.')
1320
args = parser.parse_args()
14-
this_xp = ThisXP()
21+
this_xp = XP(args.experiment)
1522
this_xp.ciboulai_init()
1623

src/davai_env/cli/cwd_is_xp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import argparse
55

6-
from ..experiment import ThisXP
6+
from ..experiment import XP
77

88
__all__ = ['main']
99

@@ -16,7 +16,7 @@ def main():
1616
action='store_true',
1717
help="Silent mode")
1818
args = parser.parse_args()
19-
this_xp = ThisXP()
19+
this_xp = XP()
2020
if not args.silent:
2121
print(this_xp.xpid)
2222

src/davai_env/cli/run_tests.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import argparse
55

6-
from ..experiment import ThisXP
6+
from ..experiment import XP
77

88
__all__ = ['main']
99

@@ -12,7 +12,7 @@ def main():
1212

1313
args = get_args()
1414

15-
this_xp = ThisXP()
15+
this_xp = XP(args.experiment)
1616
if args.list_jobs:
1717
this_xp.print_jobs()
1818
else:
@@ -23,7 +23,14 @@ def main():
2323

2424
def get_args():
2525
parser = argparse.ArgumentParser(description='Launch tests. To be ran from the XP directory only !')
26-
parser.add_argument('only_job',
26+
parser.add_argument('experiment',
27+
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
28+
"a piece of path to grab the experiment.",
29+
"Defaults to current working directory.",
30+
]),
31+
nargs='?',
32+
default='.')
33+
parser.add_argument('-j', '--only_job',
2734
nargs='?',
2835
default=None,
2936
help="Restrict the launch to the given job only (which may contain several tests)")

src/davai_env/cli/run_xp.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
import argparse
55

6-
from ..experiment import ThisXP
6+
from ..experiment import XP
77

88
__all__ = ['main']
99

1010

1111
def main():
1212
args = parser.parse_args()
13-
this_xp = ThisXP()
13+
this_xp = XP(args.experiment)
1414
this_xp.ciboulai_init()
1515
# build
1616
this_xp.build(
@@ -29,6 +29,13 @@ def main():
2929

3030
def get_args():
3131
parser = argparse.ArgumentParser(description='Run experiment: ciboulai_init, build, run_tests. To be executed from the XP directory !')
32+
parser.add_argument('experiment',
33+
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
34+
"a piece of path to grab the experiment.",
35+
"Defaults to current working directory.",
36+
]),
37+
nargs='?',
38+
default='.')
3239
# build arguments
3340
parser.add_argument('-s', '--skip_fetching_sources',
3441
action='store_true',

src/davai_env/cli/tests_version.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33

44
import argparse
55

6-
from ..experiment import ThisXP
6+
from ..experiment import XP
77

88
__all__ = ['main']
99

1010

1111
def main():
1212
parser = argparse.ArgumentParser(description='Prints the version of tests currently in use in this experiment.')
13+
parser.add_argument('experiment',
14+
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
15+
"a piece of path to grab the experiment.",
16+
"Defaults to current working directory.",
17+
]),
18+
nargs='?',
19+
default='.')
1320
parser.parse_args()
14-
this_xp = ThisXP()
21+
this_xp = XP(args.experiment)
1522
print(this_xp.davai_tests_version)
1623

src/davai_env/cli/xp_status.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
import argparse
88

9-
from ..experiment import ThisXP
9+
from ..experiment import XP
1010

1111

1212
def main():
1313
args = get_args()
14-
this_xp = ThisXP()
14+
this_xp = XP(args.experiment)
1515
this_xp.status(args.task)
1616

1717

@@ -21,6 +21,13 @@ def get_args():
2121
'Works with tasks summaries in cache,',
2222
'hence files may be missing if used too long after',
2323
'the experiment has been run.']))
24+
parser.add_argument('experiment',
25+
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
26+
"a piece of path to grab the experiment.",
27+
"Defaults to current working directory.",
28+
]),
29+
nargs='?',
30+
default='.')
2431
parser.add_argument('-t', '--task',
2532
default=None,
2633
help="Specify a task name to get the filepath to its detailed summary.")

src/davai_env/conf/base.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ IAL_bundle_repository = https://github.com/ACCORD-NWP/IAL-bundle
88

99
[paths]
1010
IAL_repository = ~/repositories/IAL
11-
experiments = ~/davai/experiments
11+
experiments = $SCRATCH/davai/experiments
1212
logs = ~/davai/logs
1313

1414
[hosts]

0 commit comments

Comments
 (0)