-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from sondreso/hook-implemenation
Use ERT plugin system
- Loading branch information
Showing
7 changed files
with
84 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
EXECUTABLE ../sunsch/sunsch.py | ||
ARGLIST <config> | ||
|
||
MIN_ARG 1 | ||
MAX_ARG 1 | ||
ARG_TYPE 0 STRING |
Empty file.
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,28 @@ | ||
import os | ||
from pkg_resources import resource_filename | ||
|
||
from ert_shared.plugins.plugin_manager import hook_implementation | ||
from ert_shared.plugins.plugin_response import plugin_response | ||
|
||
|
||
def _get_jobs_from_directory(directory): | ||
resource_directory = resource_filename("subscript", directory) | ||
|
||
all_files = [ | ||
os.path.join(resource_directory, f) | ||
for f in os.listdir(resource_directory) | ||
if os.path.isfile(os.path.join(resource_directory, f)) | ||
] | ||
return {os.path.basename(path): path for path in all_files} | ||
|
||
|
||
@hook_implementation | ||
@plugin_response(plugin_name="subscript") | ||
def installable_jobs(): | ||
return _get_jobs_from_directory("config_jobs") | ||
|
||
|
||
@hook_implementation | ||
@plugin_response(plugin_name="subscript") | ||
def installable_workflow_jobs(): | ||
return {} |
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,3 +1,4 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Tool for generating Eclipse Schedule files | ||
|
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,31 @@ | ||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
import subscript.hook_implementations.jobs | ||
from ert_shared.plugins.plugin_manager import ErtPluginManager | ||
|
||
|
||
@pytest.mark.skipif(sys.version_info.major < 3, reason="requires python3") | ||
def test_hook_implementations(): | ||
pm = ErtPluginManager(plugins=[subscript.hook_implementations.jobs]) | ||
|
||
expected_jobs = { | ||
"SUNSCH": "subscript/config_jobs/SUNSCH", | ||
} | ||
installable_jobs = pm.get_installable_jobs() | ||
for wf_name, wf_location in expected_jobs.items(): | ||
assert wf_name in installable_jobs | ||
assert installable_jobs[wf_name].endswith(wf_location) | ||
assert os.path.isfile(installable_jobs[wf_name]) | ||
|
||
assert set(installable_jobs.keys()) == set(expected_jobs.keys()) | ||
|
||
expected_workflow_jobs = {} | ||
installable_workflow_jobs = pm.get_installable_workflow_jobs() | ||
for wf_name, wf_location in expected_workflow_jobs.items(): | ||
assert wf_name in installable_workflow_jobs | ||
assert installable_workflow_jobs[wf_name].endswith(wf_location) | ||
|
||
assert set(installable_workflow_jobs.keys()) == set(expected_workflow_jobs.keys()) |