Skip to content

Commit

Permalink
Merge pull request #1295 from mvdbeek/dockstore_fixes
Browse files Browse the repository at this point in the history
Control publish setting in .dockstore.yml, fix first release not appearing on dockstore
  • Loading branch information
jmchilton committed Oct 19, 2022
2 parents d791736 + 1209044 commit c45d89e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion planemo/commands/cmd_dockstore_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

@click.command("dockstore_init")
@options.optional_project_arg()
@options.publish_dockstore_option()
@command_function
def cli(ctx, path=".", **kwds):
"""Initialize a .dockstore.yml configuration file for workflows in directory.
Expand All @@ -27,6 +28,6 @@ def cli(ctx, path=".", **kwds):
"""
# TODO: implement -f semantics
dockstore_path = os.path.join(path, DOCKSTORE_REGISTRY_CONF)
contents = generate_dockstore_yaml(path)
contents = generate_dockstore_yaml(path, kwds["publish"])
with open(dockstore_path, "w") as f:
f.write(contents)
2 changes: 1 addition & 1 deletion planemo/commands/cmd_workflow_test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
def cli(ctx, workflow_identifier, output=None, split_test=False, **kwds):
"""Initialize a Galaxy workflow test description for supplied workflow.
Be sure to your lint your workflow with ``workflow_lint`` before calling this
Be sure to lint your workflow with ``workflow_lint`` before calling this
to ensure inputs and outputs comply with best practices that make workflow
testing easier.
"""
Expand Down
4 changes: 4 additions & 0 deletions planemo/github_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import stat
import tarfile
import tempfile
import time
from distutils.dir_util import copy_tree
from pathlib import Path

Expand All @@ -29,6 +30,7 @@
NO_GITHUB_DEP_ERROR = "Cannot use github functionality - " "PyGithub library not available."
FAILED_TO_DOWNLOAD_GH = "No gh executable available and it could not be installed."
DEFAULT_REMOTE_NAME = "planemo-remote"
SLEEP_BEFORE_RELEASE = int(os.environ.get("PLANEMO_SLEEP_BEFORE_RELEASE", 60))


def get_github_config(ctx, allow_anonymous=False):
Expand Down Expand Up @@ -183,6 +185,8 @@ def create_release(ctx, from_dir, target_dir, owner, repo, version, dry_run, bra
]
cmd.extend(["--notes", notes or changelog_in_repo(target_repository_path)])
if not dry_run:
# For new repositories dockstore needs a bit of time to register the new workflow.
time.sleep(SLEEP_BEFORE_RELEASE)
communicate(cmd, env=gh_env)
else:
ctx.log("Would run command '{}'".format(" ".join(cmd)))
Expand Down
9 changes: 9 additions & 0 deletions planemo/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,15 @@ def run_download_outputs_option():
)


def publish_dockstore_option():
return planemo_option(
"--publish/--no_publish",
is_flag=True,
default=True,
help="Set publish attribute to true in .dockstore.yml file",
)


def no_dependency_resolution():
return planemo_option(
"--no_dependency_resolution",
Expand Down
3 changes: 2 additions & 1 deletion planemo/workflow_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ class WorkflowLintContext(LintContext):
training_topic = None


def generate_dockstore_yaml(directory: str) -> str:
def generate_dockstore_yaml(directory: str, publish: bool = True) -> str:
workflows = []
for workflow_path in find_workflow_descriptions(directory):
test_parameter_path = f"{workflow_path.rsplit('.', 1)[0]}-tests.yml"
workflow_entry: Dict[str, Any] = {
# TODO: support CWL
"subclass": "Galaxy",
"publish": publish,
"name": "main",
"primaryDescriptorPath": f"/{os.path.relpath(workflow_path, directory)}",
}
Expand Down
17 changes: 17 additions & 0 deletions tests/test_cmd_dockstore_init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for the ``dockstore_init`` command."""
import os
from typing import Optional

import yaml

Expand All @@ -8,14 +9,30 @@

class CmdDockstoreInitTestCase(CliTestCase):
def test_plain_init(self):
self.run_dockstore_init()

def test_init_publish_true(self):
self.run_dockstore_init(True)

def test_init_publish_false(self):
self.run_dockstore_init(False)

def run_dockstore_init(self, publish: Optional[bool] = None):
with self._isolate_with_test_data("wf_repos/from_format2/0_basic_native") as f:
init_cmd = ["dockstore_init"]
expect_published = True
if publish:
init_cmd.append("--publish")
elif publish is False:
expect_published = False
init_cmd.append("--no_publish")
self._check_exit_code(init_cmd)
assert os.path.exists(".dockstore.yml")
with open(".dockstore.yml") as fh:
dockstore_config = yaml.safe_load(fh)
assert str(dockstore_config["version"]) == "1.2"
assert "workflows" in dockstore_config
assert len(dockstore_config["workflows"]) == 1
assert dockstore_config["workflows"][0]["publish"] == expect_published
workflow_lint_cmd = ["workflow_lint", "--fail_level", "error", f]
self._check_exit_code(workflow_lint_cmd)

0 comments on commit c45d89e

Please sign in to comment.