Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/rename template of config file #280

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lifemonitor/api/models/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,16 @@ def write_zip(self, target_path: str):
raise IllegalStateException(detail="Missing RO Crate metadata")
return self.metadata.write_zip(target_path)

def write(self, target_path: str):
def write(self, target_path: str, overwrite: bool = False):
for f in self.files:
base_path = os.path.join(target_path, f.dir)
file_path = os.path.join(base_path, f.name)
logger.debug("Writing file: %r", file_path)
os.makedirs(base_path, exist_ok=True)
with open(file_path, "w") as out:
out.write(f.get_content())
file_exists = os.path.isfile(file_path)
if not file_exists or overwrite:
logger.debug("%s file: %r", "Overwriting" if file_exists else "Writing", file_path)
with open(file_path, "w") as out:
out.write(f.get_content())


class IssueCheckResult:
Expand Down
2 changes: 1 addition & 1 deletion lifemonitor/api/models/repositories/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class WorkflowRepositoryConfig(RepositoryFile):

__BASE_FILENAME__ = "lifemonitor"
DEFAULT_FILENAME = f".{__BASE_FILENAME__}.yaml"
TEMPLATE_FILENAME = f"{__BASE_FILENAME__}.yaml.j2"
TEMPLATE_FILENAME = f"{DEFAULT_FILENAME}.j2"

def __init__(self, repo_path: str) -> None:
config_file = self._search_for_config_file(repo_path)
Expand Down
4 changes: 2 additions & 2 deletions lifemonitor/api/models/repositories/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def generate_metadata(self) -> WorkflowRepositoryMetadata:
self._metadata.write(self._local_path)
return self._metadata

def write(self, target_path: str):
super().write(target_path)
def write(self, target_path: str, overwrite: bool = False):
super().write(target_path, overwrite=overwrite)
# rename files according to best practices
if self.name == "galaxy":
os.rename(os.path.join(target_path, 'workflow.ga'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ issues:
# include: [{{issues|join(', ', attribute="identifier")}}]
# csv of issues to ignore (none ignored by default)
# exclude: [{{issues|join(', ', attribute="identifier")}}]


# Github Integration Settings
push:
Expand Down