Skip to content

Commit

Permalink
Remove future annotations dependency for compatibility with earlier P…
Browse files Browse the repository at this point in the history
…ython versions
  • Loading branch information
heikomuller committed Oct 5, 2020
1 parent 960c440 commit 7c285c7
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
* Simple command-line interface for persistent archive manager


### 0.1.3 - 2020-09-21
### 0.1.3 - 2020-10-05

* Add archive manager that maintains descriptors in a relational database (\#8)
7 changes: 6 additions & 1 deletion histore/archive/manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def create(
primary_key: Optional[Union[List[str], str]] = None,
encoder: Optional[str] = None, decoder: Optional[str] = None
) -> ArchiveDescriptor:
"""Create a new archive object.
"""Create a new archive object. Raises a ValueError if an archive with
the given name exists.
Parameters
----------
Expand All @@ -72,6 +73,10 @@ def create(
Returns
-------
histore.archive.manager.descriptor.ArchiveDescriptor
Raises
------
ValueError
"""
raise NotImplementedError()

Expand Down
4 changes: 2 additions & 2 deletions histore/archive/manager/db/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def __init__(
if create:
# Create a fresh database instance.
db.init()
# Delete the base directory if it exists.
# Clear all files in the base directory if it exists.
if os.path.isdir(self.basedir):
shutil.rmtree(self.basedir)
util.cleardir(self.basedir)
# Create the base directory (if it does not exist).
util.createdir(basedir)

Expand Down
4 changes: 1 addition & 3 deletions histore/archive/manager/db/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@


class Archive(Base):
"""A workflow group associates a set of users with a workflow template. It
allows to define a group-specific set of parameters for the template.
"""
"""ORM for maintaining archive descriptors in a relational database."""
# -- Schema ---------------------------------------------------------------
__tablename__ = 'archive'

Expand Down
4 changes: 1 addition & 3 deletions histore/archive/manager/descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
by an archive manager.
"""

from __future__ import annotations

import jsonschema

from datetime import datetime
Expand Down Expand Up @@ -71,7 +69,7 @@ def create(
description: Optional[str] = None,
primary_key: Optional[Union[List[str], str]] = None,
encoder: Optional[str] = None, decoder: Optional[str] = None
) -> ArchiveDescriptor:
):
"""Create a new archive descriptor object.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions histore/archive/manager/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def __init__(
self.basedir = basedir
# Initialize path to file that maintains archive descriptors.
if create:
# Delete the base directory if it exists.
# Clear all files in the base directory if it exists.
if os.path.isdir(self.basedir):
shutil.rmtree(self.basedir)
util.cleardir(self.basedir)
util.createdir(self.basedir)
# Initialize the internal cache of archive descriptors
self.descriptorfile = os.path.join(basedir, 'archives.json')
Expand Down
3 changes: 1 addition & 2 deletions histore/archive/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

"""Classes to maintain information about dataset snapshots in an archive."""

from __future__ import annotations
from datetime import datetime
from typing import List, Optional

Expand Down Expand Up @@ -124,7 +123,7 @@ def __len__(self):
def append(
self, version: int, valid_time: Optional[datetime] = None,
description: Optional[str] = None
) -> SnapshotListing:
):
"""Add a new version to the given listing. This will return a modified
version listing with the new snapshot as the last element.
Expand Down
17 changes: 17 additions & 0 deletions histore/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import errno
import gzip
import os
import shutil
import uuid


Expand Down Expand Up @@ -103,6 +104,22 @@ def import_obj(import_path):

# -- I/O ----------------------------------------------------------------------

def cleardir(directory):
"""Remove all files in the given directory.
Parameters
----------
directory: string
Path to directory that is being created.
"""
for filename in os.listdir(directory):
file = os.path.join(directory, filename)
if os.path.isfile(file) or os.path.islink(file):
os.unlink(file)
elif os.path.isdir(file):
shutil.rmtree(file)


def createdir(directory, abs=False):
"""Safely create the given directory path if it does not exist.
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
future
pandas>=1.0.0
jsonschema>=3.2.0
python-dateutil
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


install_requires = [
'future',
'pandas>=1.0.0',
'jsonschema>=3.2.0',
'python-dateutil',
Expand Down

0 comments on commit 7c285c7

Please sign in to comment.