Skip to content

Commit

Permalink
Fix: Script generation for pyflow resource
Browse files Browse the repository at this point in the history
  • Loading branch information
tbkr committed Jun 11, 2024
1 parent 7ab51b7 commit cfd3d11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
4 changes: 2 additions & 2 deletions pyflow/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,8 @@ def deploy_suite(self, target=FileSystem, **options):

target = target(self, **options)
for t in self.all_tasks:
script, includes = t.generate_script()
target.deploy_task(t.deploy_path, script, includes)
script, includes = t.generate_script()
target.deploy_task(t.deploy_path, script, includes)
for f in self.all_families:
manual = self.generate_stub(f.manual)
if manual:
Expand Down
32 changes: 4 additions & 28 deletions pyflow/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,7 @@ def get_resource(self, filename):

return []

def install_file_stub(self, target):
"""
Installs any data associated with the resource object that is going to be deployed from the **ecFlow** server.
Parameters:
target(Deployment): The target deployment where the resource data should be installed.
"""

"""
n.b. If a resource does not need to save data at deployment time, it should not do so (e.g. WebResource)
"""
# Install path is for the suite, so we don't need to include the suite name
assert self.fullname.count("/") > 1
subpath = self.fullname[self.fullname.find("/", 1) + 1 :]

self._server_filename = os.path.join(
target.files_install_path(), subpath, self.name
)

super().install_file_stub(target)

self.save_data(target, self._server_filename)

def build_script(self):
def generate_script(self):
"""
Returns the installer script for the data resource.
Expand All @@ -128,7 +105,7 @@ def build_script(self):
for h in self._hosts:
lines += h.copy_file_to(self._server_filename, self.location()).split("\n")

return lines
return lines, []

def location(self):
"""
Expand Down Expand Up @@ -206,9 +183,8 @@ class FileResource(Resource):
"""

def __init__(self, name, hosts, source_file):
self._source = source_file

super().__init__(name, hosts)
self._server_filename = source_file

def md5(self):
"""
Expand All @@ -230,7 +206,7 @@ def data(self):
The resource data.
"""

with open(self._source, "rb") as f:
with open(self._server_filename, "rb") as f:
return f.read()

def save_data(self, target, filename):
Expand Down

0 comments on commit cfd3d11

Please sign in to comment.