Skip to content

Commit

Permalink
experiment class can be handled from arbitrary directory
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreMary committed Feb 6, 2025
1 parent 77aa292 commit cd871ee
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 118 deletions.
14 changes: 10 additions & 4 deletions src/davai_env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@
import io
import subprocess

__version__ = "1.2.0"
__version__ = "1.2.1"

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

#: usecases implemented
usecases = ('NRV', 'ELP')
#: vortex application
vapp = 'davai'


def guess_host():
"""
Expand Down
15 changes: 12 additions & 3 deletions src/davai_env/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import argparse

from ..experiment import ThisXP
from ..experiment import XP

__all__ = ['main']


def main():
args = get_args()
this_xp = ThisXP()
this_xp = XP(args.experiment)
this_xp.build(
skip_fetching_sources=args.skip_fetching_sources,
drymode=args.drymode,
Expand All @@ -22,7 +22,16 @@ def main():


def get_args():
parser = argparse.ArgumentParser(description='Fetch sources (interactively) and build executables (batch/scheduler). To be executed from the XP directory !')
parser = argparse.ArgumentParser(description=" ".join([
'Fetch sources (interactively) and build executables (batch/scheduler).'
'To be executed from the XP directory !']))
parser.add_argument('experiment',
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
"a piece of path to grab the experiment.",
"Defaults to current working directory.",
]),
nargs='?',
default='.')
parser.add_argument('-s', '--skip_fetching_sources',
action='store_true',
help="Skip fetching the sources (assuming they have been fetched / and pack preexists for gmkpack).")
Expand Down
11 changes: 9 additions & 2 deletions src/davai_env/cli/ciboulai_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@

import argparse

from ..experiment import ThisXP
from ..experiment import XP

__all__ = ['main']

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

4 changes: 2 additions & 2 deletions src/davai_env/cli/cwd_is_xp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import argparse

from ..experiment import ThisXP
from ..experiment import XP

__all__ = ['main']

Expand All @@ -16,7 +16,7 @@ def main():
action='store_true',
help="Silent mode")
args = parser.parse_args()
this_xp = ThisXP()
this_xp = XP()
if not args.silent:
print(this_xp.xpid)

13 changes: 10 additions & 3 deletions src/davai_env/cli/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import argparse

from ..experiment import ThisXP
from ..experiment import XP

__all__ = ['main']

Expand All @@ -12,7 +12,7 @@ def main():

args = get_args()

this_xp = ThisXP()
this_xp = XP(args.experiment)
if args.list_jobs:
this_xp.print_jobs()
else:
Expand All @@ -23,7 +23,14 @@ def main():

def get_args():
parser = argparse.ArgumentParser(description='Launch tests. To be ran from the XP directory only !')
parser.add_argument('only_job',
parser.add_argument('experiment',
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
"a piece of path to grab the experiment.",
"Defaults to current working directory.",
]),
nargs='?',
default='.')
parser.add_argument('-j', '--only_job',
nargs='?',
default=None,
help="Restrict the launch to the given job only (which may contain several tests)")
Expand Down
11 changes: 9 additions & 2 deletions src/davai_env/cli/run_xp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import argparse

from ..experiment import ThisXP
from ..experiment import XP

__all__ = ['main']


def main():
args = parser.parse_args()
this_xp = ThisXP()
this_xp = XP(args.experiment)
this_xp.ciboulai_init()
# build
this_xp.build(
Expand All @@ -29,6 +29,13 @@ def main():

def get_args():
parser = argparse.ArgumentParser(description='Run experiment: ciboulai_init, build, run_tests. To be executed from the XP directory !')
parser.add_argument('experiment',
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
"a piece of path to grab the experiment.",
"Defaults to current working directory.",
]),
nargs='?',
default='.')
# build arguments
parser.add_argument('-s', '--skip_fetching_sources',
action='store_true',
Expand Down
11 changes: 9 additions & 2 deletions src/davai_env/cli/tests_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@

import argparse

from ..experiment import ThisXP
from ..experiment import XP

__all__ = ['main']


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

11 changes: 9 additions & 2 deletions src/davai_env/cli/xp_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import argparse

from ..experiment import ThisXP
from ..experiment import XP


def main():
args = get_args()
this_xp = ThisXP()
this_xp = XP(args.experiment)
this_xp.status(args.task)


Expand All @@ -21,6 +21,13 @@ def get_args():
'Works with tasks summaries in cache,',
'hence files may be missing if used too long after',
'the experiment has been run.']))
parser.add_argument('experiment',
help=" ".join(["An xpid (e.g. 'dv-0054-belenos@mary') or",
"a piece of path to grab the experiment.",
"Defaults to current working directory.",
]),
nargs='?',
default='.')
parser.add_argument('-t', '--task',
default=None,
help="Specify a task name to get the filepath to its detailed summary.")
Expand Down
2 changes: 1 addition & 1 deletion src/davai_env/conf/base.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ IAL_bundle_repository = https://github.com/ACCORD-NWP/IAL-bundle

[paths]
IAL_repository = ~/repositories/IAL
experiments = ~/davai/experiments
experiments = $SCRATCH/davai/experiments
logs = ~/davai/logs

[hosts]
Expand Down
Loading

0 comments on commit cd871ee

Please sign in to comment.