|
39 | 39 | from renku.core.commands.providers import ProviderFactory |
40 | 40 | from renku.core.compat import contextlib |
41 | 41 | from renku.core.errors import DatasetNotFound, InvalidAccessToken, \ |
42 | | - MigrationRequired, ParameterError |
| 42 | + MigrationRequired, ParameterError, UsageError |
43 | 43 | from renku.core.management.datasets import DATASET_METADATA_PATHS |
44 | 44 | from renku.core.management.git import COMMIT_DIFF_STRATEGY |
45 | 45 | from renku.core.models.creators import Creator |
@@ -166,6 +166,14 @@ def add_to_dataset( |
166 | 166 | urlscontext=contextlib.nullcontext |
167 | 167 | ): |
168 | 168 | """Add data to a dataset.""" |
| 169 | + if sources or destination: |
| 170 | + if len(urls) == 0: |
| 171 | + raise UsageError('No URL is specified') |
| 172 | + elif len(urls) > 1: |
| 173 | + raise UsageError( |
| 174 | + 'Cannot add multiple URLs with --source or --destination' |
| 175 | + ) |
| 176 | + |
169 | 177 | # check for identifier before creating the dataset |
170 | 178 | identifier = extract_doi( |
171 | 179 | with_metadata.identifier |
@@ -207,8 +215,10 @@ def add_to_dataset( |
207 | 215 | '"renku dataset add {0}" command with "--create" option for ' |
208 | 216 | 'automatic dataset creation.'.format(name) |
209 | 217 | ) |
210 | | - except (FileNotFoundError, git.exc.NoSuchPathError): |
211 | | - raise ParameterError('Could not process \n{0}'.format('\n'.join(urls))) |
| 218 | + except (FileNotFoundError, git.exc.NoSuchPathError) as e: |
| 219 | + raise ParameterError( |
| 220 | + 'Could not find paths/URLs: \n{0}'.format('\n'.join(urls)) |
| 221 | + ) from e |
212 | 222 |
|
213 | 223 |
|
214 | 224 | @pass_local_client(clean=False, commit=False) |
@@ -507,14 +517,20 @@ def import_dataset( |
507 | 517 | ) |
508 | 518 |
|
509 | 519 |
|
510 | | -@pass_local_client(clean=True, commit=True, commit_only=DATASET_METADATA_PATHS) |
| 520 | +@pass_local_client( |
| 521 | + clean=True, |
| 522 | + commit=True, |
| 523 | + commit_only=DATASET_METADATA_PATHS, |
| 524 | + commit_empty=False |
| 525 | +) |
511 | 526 | def update_datasets( |
512 | 527 | client, |
513 | 528 | names, |
514 | 529 | creators, |
515 | 530 | include, |
516 | 531 | exclude, |
517 | 532 | ref, |
| 533 | + delete, |
518 | 534 | progress_context=contextlib.nullcontext |
519 | 535 | ): |
520 | 536 | """Update files from a remote Git repo.""" |
@@ -556,7 +572,15 @@ def update_datasets( |
556 | 572 | with progress_context( |
557 | 573 | possible_updates, item_show_func=lambda x: x.path if x else None |
558 | 574 | ) as progressbar: |
559 | | - client.update_dataset_files(progressbar, ref) |
| 575 | + deleted_files = client.update_dataset_files( |
| 576 | + files=progressbar, ref=ref, delete=delete |
| 577 | + ) |
| 578 | + |
| 579 | + if deleted_files and not delete: |
| 580 | + click.echo( |
| 581 | + 'Some files are deleted from remote. To also delete them locally ' |
| 582 | + 'run update command with `--delete` flag.' |
| 583 | + ) |
560 | 584 |
|
561 | 585 |
|
562 | 586 | def _include_exclude(file_path, include=None, exclude=None): |
|
0 commit comments