Skip to content

Commit

Permalink
Add: new feature skip data upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mosoriob committed Aug 14, 2019
1 parent b48a198 commit 99522d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/wcm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def configure(profile="default"):
@cli.command(help="Deploy the pacakge to the wcm.")
@click.option("--debug/--no-debug", "-d/-nd", default=False)
@click.option("--dry-run", "-n", is_flag=True)
@click.option("--ignore-data/--no-ignore-data", "-i/-ni", default=False, )
@click.option(
"--profile",
"-p",
Expand All @@ -139,10 +140,10 @@ def configure(profile="default"):
type=click.Path(file_okay=False, dir_okay=True, writable=True, exists=True),
default=".",
)
def publish(component, profile="default", debug=False, dry_run=False):
def publish(component, profile="default", debug=False, dry_run=False, ignore_data=False):
logging.info("Publishing component")
_component.deploy_component(
component, profile=profile, debug=debug, dry_run=dry_run
component, profile=profile, debug=debug, dry_run=dry_run, ignore_data=ignore_data
)

click.secho(f"Success", fg="green")
Expand Down
14 changes: 9 additions & 5 deletions src/wcm/_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ def check_data_types(spec):
raise ValueError(f"data-type {dtype} not defined")


def create_data_types(spec, component_dir, cli):
def create_data_types(spec, component_dir, cli, ignore_data):
for dtype, _file in spec.get("data", {}).items():
cli.data.new_data_type(dtype, None)
if ignore_data:
continue

if _file:
# Properties
format = _file.get("format", None)
Expand Down Expand Up @@ -84,7 +87,7 @@ def check_if_component_exists(spec, profile):
exit(0)


def deploy_component(component_dir, profile=None, creds={}, debug=False, dry_run=False):
def deploy_component(component_dir, profile=None, creds={}, debug=False, dry_run=False, ignore_data=False):
component_dir = Path(component_dir)
if not component_dir.exists():
raise ValueError("Component directory does not exist.")
Expand Down Expand Up @@ -117,13 +120,14 @@ def deploy_component(component_dir, profile=None, creds={}, debug=False, dry_run
else:
_id = name + "-" + version

wings_component = spec["wings"]
if ignore_data:
log.info("Upload data and metadata skipped")

wings_component = spec["wings"]
log.debug("Check component's data-types")
check_data_types(wings_component)

log.debug("Create component's data-types")
create_data_types(wings_component, component_dir, cli)
create_data_types(wings_component, component_dir, cli, ignore_data)

log.debug("Create component's type")
cli.component.new_component_type(wings_component["componentType"], None)
Expand Down

0 comments on commit 99522d7

Please sign in to comment.