-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reworked config modules activation in an execution context
- Loading branch information
Showing
22 changed files
with
526 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from .configuration import ModuleConfiguration | ||
from soma.controller import Directory, undefined, field | ||
|
||
|
||
class MRTrixConfiguration(ModuleConfiguration): | ||
"""MRTrix configuration module""" | ||
|
||
version: str | ||
directory: Directory = field(optional=True) | ||
name = "mrtrix" | ||
|
||
def is_valid_config(self, requirements): | ||
required_version = requirements.get("version") | ||
if required_version and getattr(self, "version", undefined) != required_version: | ||
return False | ||
return True | ||
|
||
@staticmethod | ||
def init_execution_context(execution_context): | ||
""" | ||
Configure execution (env variables) from a configured execution context | ||
""" | ||
from capsul.in_context import mrtrix | ||
|
||
mrtrix.set_env_from_config(execution_context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
The ``in_context`` module provides functions to call some external software from Capsul processes (SPM, FSL, etc.). The main functions perform calls to the software in a similar way as ``subprocess`` functions (:class:`~subprocess.Popen`, :func:`~subprocess.call`, :func:`~subprocess.check_call` and :func:`subprocess.check_output`). These functions are only valid when the software environment *context* is activated. | ||
Activating the context is normally done using the ``with`` statement on a :class:`~capsul.engine.CapsulEngine` object:: | ||
The ``in_context`` module provides functions to call some external software from Capsul processes (SPM, FSL, etc.). The main functions perform calls to the software in a similar way as ``subprocess`` functions (:class:`~subprocess.Popen`, :func:`~subprocess.call`, :func:`~subprocess.check_call` and :func:`subprocess.check_output`). | ||
The notable difference is that they use an :class:`~capsul.execution_context.ExecutionContext` object instance to get configuration from. | ||
These functions are only run from within the :meth:`~capsul.process.Process.execute` method of a Process, which gets the context as a paremeter:: | ||
from capsul.engine import capsul_engine | ||
from capsul.api import Process | ||
from capsul.in_context.fsl import fsl_check_call | ||
ce = capsul_engine() | ||
ce = Capsul() | ||
# .. configure it ... | ||
Class MyProcess(Process): | ||
with ce: | ||
fsl_check_call(['bet', '-h']) | ||
# [declare fields etc] ... | ||
def execute(self, execution_context): | ||
fsl_check_call(['bet', '-h'], execution_context=execution_context) | ||
""" |
Oops, something went wrong.