generated from nipype/pydra-tasks-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Info class to package via explicit inclusion
- Loading branch information
Showing
4 changed files
with
67 additions
and
0 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
11 changes: 11 additions & 0 deletions
11
nipype-auto-conv/specs/classes/nipype.interfaces.ants.base.Info.yaml
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,11 @@ | ||
# name of the converted workflow constructor function | ||
name: Info | ||
# name of the nipype workflow constructor | ||
nipype_name: Info | ||
# name of the nipype module the function is found within, e.g. mriqc.workflows.anatomical.base | ||
nipype_module: nipype.interfaces.ants.base | ||
# the names of the nested interfaces that are defined in other modules and need to be imported | ||
external_nested_interfaces: null | ||
# a list of tuples where the first element is a regular expression to find in the code and the second | ||
# element is the replacement string | ||
find_replace: null |
20 changes: 20 additions & 0 deletions
20
nipype-auto-conv/specs/classes/nipype.interfaces.base.core.PackageInfo.yaml
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,20 @@ | ||
# name of the converted workflow constructor function | ||
name: PackageInfo | ||
# name of the nipype workflow constructor | ||
nipype_name: PackageInfo | ||
# name of the nipype module the function is found within, e.g. mriqc.workflows.anatomical.base | ||
nipype_module: nipype.interfaces.base.core | ||
# the names of the nested interfaces that are defined in other modules and need to be imported | ||
external_nested_interfaces: null | ||
# a list of tuples where the first element is a regular expression to find in the code and the second | ||
# element is the replacement string | ||
find_replace: | ||
- ["import logging", "import logging\\nimport subprocess as sp"] | ||
- [ | ||
"\\n(\\s+)clout = CommandLine\\(\\s*command=([^,]+).+?\\).run\\(\\)", | ||
"\\n\\1raw_info = sp.check_output(\\2, shell=True).decode('utf-8')", | ||
] | ||
- ["raw_info = clout\\.runtime\\.stdout", ""] | ||
imports: | ||
- module: subprocess | ||
alias: sp |
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,35 @@ | ||
import logging | ||
import os | ||
from packaging.version import Version, parse | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Info(PackageInfo): | ||
version_cmd = ( | ||
os.path.join(os.getenv("ANTSPATH", ""), "antsRegistration") + " --version" | ||
) | ||
|
||
@staticmethod | ||
def parse_version(raw_info): | ||
for line in raw_info.splitlines(): | ||
if line.startswith("ANTs Version: "): | ||
v_string = line.split()[2] | ||
break | ||
else: | ||
return None | ||
|
||
# -githash may or may not be appended | ||
v_string = v_string.split("-")[0] | ||
|
||
version = parse(v_string) | ||
|
||
# Known mislabeled versions | ||
if version.is_postrelease: | ||
if version.base_version == "2.1.0" and version.post >= 789: | ||
return "2.2.0" | ||
|
||
# Unless we know of a specific reason to re-version, we will | ||
# treat the base version (before pre/post/dev) as authoritative | ||
return version.base_version |