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

Drop support for datasets V1 (except for upgrade) #342

Merged
merged 2 commits into from
Jan 13, 2021
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ vendor/Brewfile.lock.json
/platforms/linux/sqlite3

/tests/data/*/
!/tests/data/patches
/tests/data/*.zip
!/tests/data/patches
!/tests/data/upgrade
/tests/data/upgrade/v0/*/
/tests/data/upgrade/v1/*/
/coverage
pytest.xml
.coverage
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ _When adding new entries to the changelog, please include issue/PR numbers where

## 0.8.0 (UNRELEASED)

### End of support for Datasets V1

* Backwards compatibility with Datasets V1 ends at Sno 0.8.0 - all Sno commands except `sno upgrade` will no longer work in a V1 repository. Since Datasets V2 has been the default since Sno 0.5.0, most users will be unaffected. Remaining V1 repositories can be upgraded to V2 using `sno upgrade EXISTING_REPO NEW_REPO`, and the ability to upgrade from V1 to V2 continues to be supported indefinitely. [#342](https://github.com/koordinates/sno/pull/342)

### Other changes

* Support for detecting features which have changed slightly during a re-import from a data source without a primary key, and reimporting them with the same primary key as last time so they show as edits as opposed to inserts. [#212](https://github.com/koordinates/sno/issues/212)
* Bugfix - fixed issues roundtripping certain type metadata in the PostGIS working copy: specifically geometry types with 3 or more dimensions (Z/M values) and numeric types with scale.

Expand Down
21 changes: 3 additions & 18 deletions sno/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class BaseDataset(ImportSource):
"""
Common interface for all datasets - so far this is Dataset1, Dataset2 -
and even Dataset0 (but this is only supported for `sno upgrade`)
Common interface for all datasets - mainly Dataset2, but
there is also Dataset0 and Dataset1 used by `sno upgrade`.
"""

# Constants that subclasses should generally define.
Expand All @@ -26,9 +26,7 @@ def __init__(self, tree, path):
The tree can be None if this dataset hasn't yet been written to the repo.
"""
if self.__class__ is BaseDataset:
raise TypeError(
"Cannot construct a BaseDataset - use a subclass (see BaseDataset.for_version)"
)
raise TypeError("Cannot construct a BaseDataset - you may want Dataset2")

self.tree = tree
self.path = path.strip("/")
Expand All @@ -38,19 +36,6 @@ def __init__(self, tree, path):
def __repr__(self):
return f"<{self.__class__.__name__}: {self.path}>"

@classmethod
def for_version(cls, version):
from .dataset1 import Dataset1
from .dataset2 import Dataset2

version = int(version)
if version == 1:
return Dataset1
elif version == 2:
return Dataset2

raise ValueError(f"No Dataset implementation found for version={version}")

def default_dest_path(self):
# ImportSource method - by default, a dataset should import with the same path it already has.
return self.path
Expand Down
4 changes: 4 additions & 0 deletions sno/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def repo(self):

def get_repo(
self,
allow_legacy_versions=False,
allowed_states=SnoRepoState.NORMAL,
bad_state_message=None,
command_extra=None,
Expand All @@ -67,6 +68,9 @@ def get_repo(

raise NotFound(message, exit_code=NO_REPOSITORY, param_hint=param_hint)

if not allow_legacy_versions:
self._repo.ensure_latest_version()

state = self._repo.state
state_is_allowed = (
state in allowed_states
Expand Down
7 changes: 5 additions & 2 deletions sno/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .cli_util import add_help_subcommand
from .output_util import dump_json_output
from .repo import SnoRepoState
from .repo_version import get_repo_version


# Changing these items would generally break the repo;
Expand Down Expand Up @@ -57,10 +58,12 @@ def data_ls(ctx, output_format, refish):
@click.pass_context
def data_version(ctx, output_format):
"""Show the repository structure version"""
repo = ctx.obj.get_repo(allowed_states=SnoRepoState.ALL_STATES)
repo = ctx.obj.get_repo(
allowed_states=SnoRepoState.ALL_STATES, allow_legacy_versions=True
)
version = repo.version
if output_format == "text":
click.echo(f"Sno repository uses Datasets v{version}")
click.echo(f"This Sno repo uses Datasets v{version}")
if version >= 1:
click.echo(
f"(See https://github.com/koordinates/sno/blob/master/docs/DATASETS_v{version}.md)"
Expand Down
Loading