Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIU-420: Protoype config.INI and Slurm script templates #297

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

myxie
Copy link
Collaborator

@myxie myxie commented Nov 13, 2024

JIRA Ticket

LIU-420

Type

  • Feature (addition)
  • Documentation

Problem/Issue

The current configuration options for the create_dlg_job.py script are not flexible, as it is necessary to create a brand new class for any new facility or non-standard approach for using the script (e.g. a different /venv/directory or DLG installation`. This is true for the SLURM script too; currently any additional SBATCH directives must be added as a CLI option to the script, which will get unwieldy quickly.

It would be good to remove the existing approach, and instead rely on configuration files that the user can edit.

Solution

This PR delivers an MVP of behaviour supporting a configuration file for the facility environment variables, and a SLURM script template that allows for user-defined options and directives.

The following use of the new additions successfully deploys to setonix using a setonix.ini file and a setonix.slurm template:

python create_dlg_job.py -a 1 -n 1 -s 1 -u -f setonix 
-L ~/github/EAGLE_test_repo/eagle_test_graphs/daliuge_tests/dropmake/logical_graphs/ArrayLoop.graph 
-v 5 --remote --submit 
# NEW FLAGS
--config_file configs/setonix.ini --slurm_template configs/setonix.slurm

Things to note are:

  • The config.ini and template.slurm files override the CLI and the config.ini, respectively, in the event that there are overlapping parameters.
  • It is possible to use either option, or both
  • None of the code that supports the existing configuration and command line arguments has been removed.

Ideally, this PR delivers the minimal-viable functionality that will allow us to start prioritising the features we want to support and trigger conversations moving forward about the final implementation we are working towards.

Checklist

  • Unittests added
  • Documentation added

Summary by Sourcery

Prototype the use of configuration INI files and SLURM script templates in the SlurmClient to enhance job submission flexibility and configuration management.

New Features:

  • Introduce support for using configuration INI files and SLURM script templates in the SlurmClient, allowing for more flexible job submission configurations.

Enhancements:

  • Refactor SlurmClient to separate configuration handling from CLI and INI files, improving code modularity and maintainability.

Tests:

  • Add unit tests for SlurmClient to verify functionality with CLI, configuration files, and SLURM templates, ensuring robustness and correctness of the new features.

Summary by Sourcery

Prototype the use of configuration INI files and SLURM script templates in the SlurmClient to enhance job submission flexibility and configuration management.

New Features:

  • Introduce support for using configuration INI files and SLURM script templates in the SlurmClient, allowing for more flexible job submission configurations.

Enhancements:

  • Refactor SlurmClient to separate configuration handling from CLI and INI files, improving code modularity and maintainability.

Documentation:

  • Add documentation for the new configuration INI files and SLURM script templates, explaining their usage and benefits.

Tests:

  • Add unit tests for SlurmClient to verify functionality with CLI, configuration files, and SLURM templates, ensuring robustness and correctness of the new features.

(Incomplete)
- Basic use of SLURM 'template' script
- Skeleton use of .ini file for environment variables
- Added unittests to help prototyping
- Tests pass for config and slurm template
- Tested on Setonix
Copy link
Contributor

sourcery-ai bot commented Nov 13, 2024

Reviewer's Guide by Sourcery

This PR introduces a flexible configuration system for SLURM job submissions by implementing support for INI configuration files and SLURM script templates. The changes maintain backward compatibility while allowing users to customize deployment settings and SLURM directives through external files rather than hardcoded configurations or CLI arguments.

Sequence diagram for job submission with new configuration

sequenceDiagram
    actor User
    participant SlurmClient
    participant ConfigParser
    participant RemoteServer
    User->>SlurmClient: Initialize with config_file and slurm_template
    SlurmClient->>ConfigParser: process_config(config_file)
    ConfigParser-->>SlurmClient: Return configuration
    SlurmClient->>RemoteServer: Create session directory
    SlurmClient->>SlurmClient: apply_slurm_template()
    SlurmClient->>RemoteServer: Submit job
    RemoteServer-->>SlurmClient: Job ID
    SlurmClient-->>User: Return Job ID
Loading

Class diagram for SlurmClient modifications

classDiagram
    class SlurmClient {
        -String host
        -String _acc
        -String dlg_root
        -String modules
        -String venv
        -String exec_prefix
        -String username
        -String _slurm_template
        -int _num_nodes
        -int _job_dur
        -String _suffix
        -boolean _remote
        +create_session_suffix(suffix)
        +get_session_dirname()
        +apply_slurm_template(template_str, session_id, dlg_root)
        +create_job_desc(physical_graph_file)
        +mk_session_dir(dlg_root)
        +submit_job()
    }
    note for SlurmClient "New attributes: config, slurm_template, suffix. New methods: create_session_suffix, apply_slurm_template."
Loading

File-Level Changes

Change Details Files
Implemented support for INI configuration files to manage deployment settings
  • Added ConfigParser to process facility-specific INI files
  • Created default and facility-specific INI templates
  • Modified SlurmClient to accept and prioritize INI configurations over default settings
  • Added new CLI option --config_file to specify custom INI files
daliuge-engine/dlg/deploy/slurm_client.py
daliuge-engine/dlg/deploy/create_dlg_job.py
daliuge-engine/dlg/deploy/configs/default.ini
daliuge-engine/dlg/deploy/configs/setonix.ini
Added support for customizable SLURM script templates
  • Implemented template processing using string.Template
  • Separated SLURM script generation from hardcoded template
  • Added new CLI option --slurm_template for custom templates
  • Created template files for different facilities
daliuge-engine/dlg/deploy/slurm_client.py
daliuge-engine/dlg/deploy/configs/__init__.py
daliuge-engine/dlg/deploy/configs/default.slurm
daliuge-engine/dlg/deploy/configs/setonix.slurm
Added comprehensive test suite for new configuration features
  • Created tests for CLI-based configuration
  • Added tests for INI file configuration
  • Implemented tests for SLURM template processing
  • Added test fixtures and comparison files
daliuge-engine/test/deploy/test_slurm_client.py
daliuge-engine/test/deploy/slurm_script.sh
daliuge-engine/test/deploy/slurm_script_from_template.sh
daliuge-engine/test/deploy/setonix.ini
daliuge-engine/test/deploy/example_template.slurm

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@myxie myxie marked this pull request as ready for review November 15, 2024 08:56
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @myxie - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Please add documentation with examples of the config.INI format and SLURM template structure to help users adopt these new features.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

daliuge-engine/dlg/deploy/slurm_client.py Show resolved Hide resolved
daliuge-engine/dlg/deploy/slurm_client.py Show resolved Hide resolved
daliuge-engine/test/deploy/test_slurm_client.py Outdated Show resolved Hide resolved
daliuge-engine/dlg/deploy/slurm_client.py Show resolved Hide resolved
daliuge-engine/dlg/deploy/slurm_client.py Show resolved Hide resolved
daliuge-engine/dlg/deploy/create_dlg_job.py Show resolved Hide resolved
daliuge-engine/dlg/deploy/slurm_client.py Outdated Show resolved Hide resolved
- Previous approach ended up using local graph as input to the script; this isn't how client.submit_job() works; it uses the remote path the phyiscal graph is expected
@coveralls
Copy link

Coverage Status

coverage: 78.676% (-1.1%) from 79.752%
when pulling 0de27c1 on LIU-420
into c09b85e on master.

@myxie
Copy link
Collaborator Author

myxie commented Nov 25, 2024

@awicenec and @alxndrwllmsn, it would be great to get your eyes on this if you have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants