Exemplo n.º 1
0
def add_job(name,
            workflow,
            application,
            description='',
            args='',
            mpi_flags='',
            num_nodes=1,
            ranks_per_node=1,
            cpu_affinity='depth',
            threads_per_rank=1,
            threads_per_core=1,
            environ_vars={},
            data=None,
            save=True,
            **kwargs):
    '''Add a new job to the BalsamJob DB

    Creates a new job and saves it to the database in CREATED state.
    The job is initialized with all blank/default values for its fields; these
    must be configured by the user or provided via ``kwargs``

    Args:
        - ``kwargs`` (*dict*): contains BalsamJob fields (keys) and their values to
          be set on BalsamJob instantiation.

    Returns:
        - ``job`` (*BalsamJob*): the newly-created BalsamJob instance

    Raises:
        - ``ValueError``: if an invalid field name is provided to *kwargs*
    '''
    job = BalsamJob()
    job.name = name
    job.workflow = workflow
    job.application = application
    job.description = description
    job.args = args
    job.mpi_flags = mpi_flags
    job.num_nodes = num_nodes
    job.ranks_per_node = ranks_per_node
    job.threads_per_rank = threads_per_rank
    job.threads_per_core = threads_per_core
    job.cpu_affinity = cpu_affinity
    job.environ_vars = environ_vars
    job.data = data if data else dict()
    job.get_application()

    for k, v in kwargs.items():
        setattr(job, k, v)

    if current_job:
        job.queued_launch = current_job.queued_launch
    if save:
        job.save()
    return job
Exemplo n.º 2
0
def create_jobs(N):
    """If we're on a command line, create N tasks to square a number"""
    for i in range(N):
        job = BalsamJob(
            name=f"square{i}",
            workflow="demo-square",
            application="square",
        )
        job.data["x"] = i
        job.save()
    print(f"Created {N} jobs")
Exemplo n.º 3
0
def run_migrations():
    from django.core.management import call_command
    from balsam.django_config.db_index import refresh_db_index
    setup()
    print(f"DB settings:", settings.DATABASES['default'])
    call_command('makemigrations', interactive=True, verbosity=2)
    call_command('migrate', interactive=True, verbosity=2)
    refresh_db_index()
    try:
        from balsam.core.models import BalsamJob
        j = BalsamJob()
        j.save()
        j.delete()
    except:
        print("BalsamJob table not properly created")
        raise
    else:
        print("BalsamJob table created successfully")
Exemplo n.º 4
0
    RPN,
    TRIALS,
    COMMON_PARAMS,
    BENCHMARK_SCRIPTS,
)
from balsam.core.models import BalsamJob, ApplicationDefinition


RELEASE_PATH = os.environ['RELEASE_PATH']
PYTHON = os.path.join(RELEASE_PATH, 'env', 'bin', 'python')

for script_path in BENCHMARK_SCRIPTS:
    executable = ' '.join((PYTHON, script_path))
    app_name = script_path[script_path.find('osu_') + 4:-3]
    app, created = ApplicationDefinition.objects.get_or_create(
        name=app_name,
        defaults=dict(
            executable=executable,
        )
    )
    for (num_nodes, rpn, trial) in product(NUM_NODES, RPN, TRIALS):
        job = BalsamJob(
            name=f"{num_nodes}nodes.{rpn}rpn.{trial}",
            workflow=f"{app_name}",
            application=app_name,
            num_nodes=num_nodes,
            ranks_per_node=rpn,
            **COMMON_PARAMS,
        )
        job.save()