Skip to content

Commit

Permalink
added notes and deprecations throughout project (#220)
Browse files Browse the repository at this point in the history
* added notes and deprecations in the project module

* fixed code style formatting problems in project.py

* quick fix for the __version__ variable

* fixed code formatting

* added deprecation package to test environment

* marked everything in contrib/filesystems.py for deprecation

* formatted filesystems.py

* added deprecated tags for mpipool module

* marked unused functions for deprecations in contrib/utility.py

* deprecations in core/utility

* removed one of the copied versions of TemporaryDirectory

* fixed some indentations

* fixed error with python 2.7 compatibility

* added deprecations in connection.py

* updated code format in connection.py

* added deprecations in crypt.py

* added deprecations in host.py

* changed deprecation warnings in crypt.py

* changed deprecation warnings in connection.py

* changed deprecation warnings in host.py

* updated deprecation warnings in filesystems.py

* deprecated the indexing module

* fixed typo

* deprecated the mpipool module

* deprecated everything in the db package

* reworded some depreation notices

* undeprecated some stuff i accidentally deprecated

* undeprecated some stuff I accidentally deprecated

* deprecated the database module

* defined __version__ in smaller number of places

* finshed deprecation annotation stuff

* fixed order for multiple decorators

* removed reference to sublime project files in the git ignore

* moved the __version__ variable to be stored in a single file

* fixed code formatting issues

* updated @deprecated headers in indexing

* standardized the way we deprecate class and functions wrt privacy

* Revert changes to benchmark.py

* Change bumpversion configuration to point to new version.py file.

* Add deprecation to package requirements.

* removed previous whitespace changed

* removed other whitespace change

* updated deprecation style

* fixed flake8 issues

* added myself to list of contributors

* fixed typo in contributors

* removed TODO from check() method in Project class

* added that period in project module

* moved implementation of find_job_ids to private method

* updated the unit test that was failing on py27

* changed the message on a deprecation warning

* refactored internal uses of find_job_ids

* Update signac/contrib/project.py

* Update signac/contrib/project.py

* Update signac/core/utility.py

Co-Authored-By: Carl Simon Adorf <csadorf@umich.edu>

* Update signac/version.py

Co-Authored-By: Carl Simon Adorf <csadorf@umich.edu>

* Un-deprecate JobSearchIndex.find_job_ids.
  • Loading branch information
tommy-waltmann authored and bdice committed Sep 6, 2019
1 parent 1298ce1 commit 9fab38a
Show file tree
Hide file tree
Showing 28 changed files with 211 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ message = Bump up to version {new_version}.

[bumpversion:file:setup.py]

[bumpversion:file:signac/__init__.py]
[bumpversion:file:signac/version.py]

[bumpversion:file:doc/conf.py]

Expand Down
5 changes: 5 additions & 0 deletions contributors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ contributors:
family-names: Adams
given-names: Alexander
affiliation: "University of Michigan"
-
family-names: Waltmann
given-names: "Thomas R."
affiliation: "University of Michigan"
orcid: "https://orcid.org/0000-0001-6876-5956"
...
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deprecation>=2
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import os
from setuptools import setup, find_packages


requirements = [
# Deprecation management
'deprecation>=2',
]

description = "Simple file data management database."

try:
Expand Down Expand Up @@ -39,6 +45,8 @@
"Programming Language :: Python :: Implementation :: PyPy",
],

install_requires=requirements,

python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4',

extras_require={
Expand Down
3 changes: 1 addition & 2 deletions signac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@
from .core.jsondict import JSONDict
from .core.h5store import H5Store
from .core.h5store import H5StoreManager
from .version import __version__


__version__ = '1.2.0'

__all__ = ['__version__', 'contrib', 'db', 'errors', 'warnings', 'sync',
'cite',
'Project', 'TemporaryProject', 'get_project', 'init_project', 'get_job',
Expand Down
2 changes: 1 addition & 1 deletion signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
READLINE = True

from . import Project, get_project, init_project, index
from . import __version__
from .version import __version__
from .common import config
from .common.configobj import flatten_errors, Section
from .common.crypt import get_crypt_context, parse_pwhash, get_keyring
Expand Down
12 changes: 12 additions & 0 deletions signac/common/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import subprocess
import logging
from os.path import expanduser
from deprecation import deprecated

import pymongo

from .errors import ConfigError
from ..version import __version__


PYMONGO_2 = pymongo.version_tuple[0] == 2
Expand All @@ -19,7 +21,13 @@
AUTH_SSL = 'SSL'
AUTH_SSL_x509 = 'SSL-x509'

"""
THIS MODULE IS DEPRECATED!
"""


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The connection module is deprecated.")
def get_subject_from_certificate(fn_certificate): # pragma no cover
try:
cert_txt = subprocess.check_output(
Expand All @@ -34,11 +42,15 @@ def get_subject_from_certificate(fn_certificate): # pragma no cover
return lines[0][len('subject='):].strip()


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The connection module is deprecated.")
def raise_unsupported_auth_mechanism(mechanism):
msg = "Auth mechanism '{}' not supported."
raise ValueError(msg.format(mechanism))


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The connection module is deprecated.")
class DBClientConnector(object):

def __init__(self, host_config, **kwargs):
Expand Down
10 changes: 10 additions & 0 deletions signac/common/crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import base64

from . import six
from deprecation import deprecated
from ..version import __version__

try:
from passlib.context import CryptContext
Expand All @@ -27,7 +29,13 @@ def get_keyring():
"Return the system user keyring."
return keyring.get_keyring()

"""
THIS MODULE IS DEPRECATED!
"""


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The crypt module is deprecated.")
class SimpleKeyring(object):
"""Simple in-memory keyring for caching."""

Expand Down Expand Up @@ -65,6 +73,8 @@ def setdefault(self, key, value):
return self._decode(self._cache.setdefault(key, self._encode(value)))


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The crypt module is deprecated.")
def parse_pwhash(pwhash):
"Extract hash configuration from hash string."
if get_crypt_context().identify(pwhash) == 'bcrypt':
Expand Down
22 changes: 22 additions & 0 deletions signac/common/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import warnings
import getpass

from deprecation import deprecated
from ..version import __version__
from ..core import json
from .config import load_config
from .errors import ConfigError, AuthenticationError
Expand All @@ -18,7 +20,13 @@
SESSION_PASSWORD_HASH_CACHE = SimpleKeyring()
SESSION_USERNAME_CACHE = dict()

"""
THIS MODULE IS DEPRECATED!
"""


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def get_default_host(config=None):
if config is None:
config = load_config()
Expand All @@ -38,6 +46,8 @@ def _get_host_config(hostname, config):
raise ConfigError("Host '{}' not configured.".format(hostname))


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def get_host_config(hostname=None, config=None):
if config is None:
config = load_config()
Expand All @@ -50,6 +60,8 @@ def _host_id(hostcfg):
return json.dumps(hostcfg, sort_keys=True)


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def make_uri(hostcfg):
ret = hostcfg['url']
if ret.startswith('mongodb://'):
Expand Down Expand Up @@ -116,6 +128,8 @@ def default():
return _get_cached_credentials(hostcfg, default)


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def get_credentials(hostcfg, ask=True):
if ask:
return _get_credentials(hostcfg)
Expand All @@ -135,6 +149,8 @@ def _input(prompt, default=''):
return default


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def check_credentials(hostcfg):
from pymongo.uri_parser import parse_uri
auth_m = hostcfg.get('auth_mechanism', 'none')
Expand All @@ -156,17 +172,23 @@ def check_credentials(hostcfg):
return hostcfg


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def get_connector(hostcfg, **kwargs):
return DBClientConnector(hostcfg, **kwargs)


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def get_client(hostcfg, **kwargs):
connector = get_connector(hostcfg, **kwargs)
connector.connect()
connector.authenticate()
return connector.client


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The host module is deprecated.")
def get_database(name, hostname=None, config=None, **kwargs):
if hostname is None:
hostname = get_default_host(config)
Expand Down
14 changes: 12 additions & 2 deletions signac/contrib/filesystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from ..common import six
from ..db import get_database
from ..version import __version__
from deprecation import deprecated

try:
import pymongo
Expand All @@ -27,12 +29,18 @@
GRIDFS_LARGE_FILE_WARNING_THRSHLD = int(1e9) # 1GB
FILESYSTEM_REGISTRY = dict()

"""
THIS MODULE IS DEPRECATED!
"""


def _register_fs_class(fs):
"Register a file system handler in the module's registry."
FILESYSTEM_REGISTRY[fs.name] = fs


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The filesystems module is deprecated.")
class LocalFS(object):
"""A file system handler for the local file system.
Expand Down Expand Up @@ -193,7 +201,8 @@ def get(self, _id, mode='r'):
raise ValueError(mode)
_register_fs_class(GridFS)


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The filesystems module is deprecated.")
def filesystems_from_config(fs_config):
"""Generate file system handlers from a configuration.
Expand Down Expand Up @@ -236,7 +245,8 @@ def filesystems_from_config(fs_config):
else:
yield fs_class(args)


@deprecated(deprecated_in="1.3", removed_in="2.0", current_version=__version__,
details="The filesystems module is deprecated.")
def filesystems_from_configs(fs_configs):
"""Generate file system handlers.
Expand Down

0 comments on commit 9fab38a

Please sign in to comment.