-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Javier Carnero
committed
Jun 20, 2018
1 parent
8280a90
commit 0e31db5
Showing
10 changed files
with
321 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
######## | ||
# Copyright (c) 2017-2018 MSO4SC - [email protected] | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
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,22 @@ | ||
from external_repository import ExternalRepository | ||
|
||
|
||
class Ckan(ExternalRepository): | ||
|
||
def __init__(self, publish_item): | ||
super().__init__(publish_item) | ||
|
||
self.entrypoint = publish_item['entrypoint'] | ||
self.api_key = publish_item['api_key'] | ||
self.dataset = publish_item['dataset'] | ||
self.file_path = publish_item['file_path'] | ||
|
||
def _build_publish_call(self, logger): | ||
# detach call?? | ||
operation = "create" | ||
# TODO: if resource file exists, operation="update" | ||
call = "curl -H'Authorization: " + self.api_key + "' " + \ | ||
"'" + self.entrypoint + "/api/action/resource_" + operation + "' " + \ | ||
"--form upload=@ " + self.file_path + \ | ||
"--form package_id=" + self.package_id | ||
return call |
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,47 @@ | ||
from hpc_plugin.ssh import SshClient | ||
|
||
|
||
class ExternalRepository(object): | ||
|
||
def factory(publish_item): | ||
if publish_item['type'] == "CKAN": # TODO: manage key error | ||
from ckan import Ckan | ||
return Ckan(publish_item) | ||
else: | ||
return None | ||
factory = staticmethod(factory) | ||
|
||
def __init__(self, publish_item): | ||
self.er_type = publish_item['type'] # TODO: manage key error | ||
|
||
def publish(self, | ||
ssh_client, | ||
logger, | ||
workdir=None): | ||
""" | ||
Publish the local file in the external repository | ||
@type ssh_client: SshClient | ||
@param ssh_client: ssh client connected to an HPC login node | ||
@rtype string | ||
@return TODO: | ||
""" | ||
if not SshClient.check_ssh_client(ssh_client, logger): | ||
return False | ||
|
||
call = self._build_publish_call(logger) | ||
if call is None: | ||
return False | ||
|
||
return ssh_client.execute_shell_command( | ||
call, | ||
workdir=workdir) | ||
|
||
def _build_publish_call(self, logger): | ||
""" | ||
Creates a script to publish the local file | ||
@rtype string | ||
@return string with the publish call. None if an error arise. | ||
""" | ||
raise NotImplementedError("'_build_publish_call' not implemented.") |
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
100 changes: 100 additions & 0 deletions
100
hpc_plugin/tests/blueprint/blueprint_sbatch_output.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,100 @@ | ||
######## | ||
# Copyright (c) 2017 MSO4SC - [email protected] | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
tosca_definitions_version: cloudify_dsl_1_3 | ||
|
||
imports: | ||
# to speed things up, it is possible downloading this file, | ||
# - http://www.getcloudify.org/spec/cloudify/4.1/types.yaml | ||
- http://raw.githubusercontent.com/mso4sc/cloudify-hpc-plugin/master/resources/types/cfy_types.yaml | ||
# relative import of plugin.yaml that resides in the blueprint directory | ||
- hpc_plugin/test_plugin.yaml | ||
|
||
inputs: | ||
# Monitor | ||
monitor_entrypoint: | ||
description: Monitor entrypoint IP | ||
default: "" | ||
type: string | ||
|
||
# Job prefix name | ||
job_prefix: | ||
description: Job name prefix in HPCs | ||
default: "cfyhpc" | ||
type: string | ||
|
||
partition: | ||
description: Partition in which the jobs will run | ||
default: "public" | ||
type: string | ||
|
||
mso4sc_hpc_primary: | ||
description: Configuration for the primary HPC to be used | ||
default: {} | ||
|
||
mso4sc_datacatalogue: | ||
description: entrypoint of the data catalogue | ||
default: "" | ||
|
||
mso4sc_publish_key: | ||
description: API Key to publish the outputs | ||
default: "" | ||
|
||
publish_dataset_id: | ||
description: ID of the CKAN dataset | ||
default: "" | ||
|
||
publish_outputs_path: | ||
description: Local path to the outputs to be uploaded | ||
default: "" | ||
|
||
node_templates: | ||
first_hpc: | ||
type: hpc.nodes.Compute | ||
properties: | ||
config: { get_input: mso4sc_hpc_primary } | ||
external_monitor_entrypoint: { get_input: monitor_entrypoint } | ||
job_prefix: { get_input: job_prefix } | ||
workdir_prefix: "single_sbatch" | ||
skip_cleanup: True | ||
simulate: True # COMMENT to test against a real HPC | ||
|
||
single_job: | ||
type: hpc.nodes.job | ||
properties: | ||
job_options: | ||
type: 'SBATCH' | ||
command: "touch.script single.test" | ||
deployment: | ||
bootstrap: 'scripts/bootstrap_sbatch_example.sh' | ||
revert: 'scripts/revert_sbatch_example.sh' | ||
inputs: | ||
- 'single' | ||
- { get_input: partition } | ||
publish: | ||
- type: "CKAN" | ||
entrypoint: { get_input: mso4sc_datacatalogue} | ||
api_key: { get_input: mso4sc_publish_key } | ||
dataset: { get_input: publish_dataset_id } | ||
file_path: { get_input: publish_outputs_path } | ||
skip_cleanup: True | ||
relationships: | ||
- type: job_contained_in_hpc | ||
target: first_hpc | ||
|
||
outputs: | ||
single_job_name: | ||
description: single job name in the HPC | ||
value: { get_attribute: [single_job, job_name] } |
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
Oops, something went wrong.