Skip to content

Commit

Permalink
Move all modules into root namespace. (#868)
Browse files Browse the repository at this point in the history
* Move all modules into root namespace.

* Update changelog.

* Use a single global exclude for pre-commit.

* Move internal modules into new _internal subpackage.

* Move internal modules back to top level.

* Clean up exclusions.

Co-authored-by: Carl Simon Adorf <carl.simon.adorf@gmail.com>
Co-authored-by: Vyas Ramasubramani <vyasr@nvidia.com>
Co-authored-by: Vyas Ramasubramani <vyas.ramasubramani@gmail.com>
  • Loading branch information
4 people committed Dec 6, 2022
1 parent 766c0b7 commit 3de5f48
Show file tree
Hide file tree
Showing 48 changed files with 247 additions and 317 deletions.
9 changes: 1 addition & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
ci:
autoupdate_schedule: quarterly

exclude: |
(?x)^(
^signac/common/configobj/|
^signac/common/deprecation/
)
exclude: ^signac/_vendor/.*

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -48,9 +44,6 @@ repos:
(?x)^(
^doc/|
^tests/|
^signac/common/configobj/|
^signac/common/deprecation/|
^signac/db/
)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.981'
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Changed
- The prefix argument to ``$ signac view`` is now optional and can be provided with ``-p/--prefix`` (#653, #774).
- Tests are run with ``xfail_strict = True`` (#850).
- Detection of an invalid config will raise an error rather than a debug log (#855).
- The package namespace has been flattened so that most functionality is directly available in the ``signac`` namespace (#756, #868).

Removed
+++++++
Expand Down
10 changes: 5 additions & 5 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The JobsCursor class
====================
.. _python-api-jobscursor:

.. currentmodule:: signac.contrib.project
.. currentmodule:: signac.project

.. rubric:: Attributes

Expand All @@ -72,7 +72,7 @@ The Job class

.. _python-api-job:

.. currentmodule:: signac.contrib.job
.. currentmodule:: signac.job

.. rubric:: Attributes

Expand Down Expand Up @@ -110,7 +110,7 @@ The Job class
The JSONDict
============

This class implements the interface for the job's :attr:`~signac.contrib.job.Job.statepoint` and :attr:`~signac.contrib.job.Job.document` attributes, but can also be used on its own.
This class implements the interface for the job's :attr:`~signac.job.Job.statepoint` and :attr:`~signac.job.Job.document` attributes, but can also be used on its own.

.. autoclass:: JSONDict
:members:
Expand All @@ -120,7 +120,7 @@ This class implements the interface for the job's :attr:`~signac.contrib.job.Job
The H5Store
===========

This class implements the interface to the job's :attr:`~signac.contrib.job.Job.data` attribute, but can also be used on its own.
This class implements the interface to the job's :attr:`~signac.job.Job.data` attribute, but can also be used on its own.

.. autoclass:: H5Store
:members:
Expand All @@ -130,7 +130,7 @@ This class implements the interface to the job's :attr:`~signac.contrib.job.Job.
The H5StoreManager
==================

This class implements the interface to the job's :attr:`~signac.contrib.job.Job.stores` attribute, but can also be used on its own.
This class implements the interface to the job's :attr:`~signac.job.Job.stores` attribute, but can also be used on its own.

.. autoclass:: H5StoreManager
:members:
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.black]
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
force-exclude = '''
(
/(
\.eggs
Expand All @@ -11,11 +11,11 @@ exclude = '''
| \.venv
| build
| dist
| signac/common/configobj
| _vendor
)/
)
'''

[tool.isort]
profile = 'black'
skip_glob = 'signac/common/configobj/*'
skip_glob = 'signac/_vendor/*'
7 changes: 3 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ python-tag = py3

[flake8]
max-line-length = 100
exclude = configobj
exclude = _vendor
select = E,F,W
ignore = E123,E126,E203,E226,E241,E704,W503,W504

[pydocstyle]
match = ^((?!\.sync-zenodo-metadata|setup).)*\.py$
match-dir = ^((?!\.|tests|configobj).)*$
match-dir = ^((?!\.|tests|_vendor).)*$
ignore-decorators = "deprecated"
add-ignore = D105, D107, D203, D204, D213

Expand All @@ -31,8 +31,7 @@ concurrency = thread,multiprocessing
parallel = True
source = signac
omit =
*/signac/common/configobj/*.py
*/signac/common/deprecation/*.py
*/signac/_vendor/*

[tool:pytest]
xfail_strict = True
Expand Down
7 changes: 3 additions & 4 deletions signac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
collectively accessible.
"""

from . import contrib, errors, sync
from . import errors, sync
from ._synced_collections.backends.collection_json import (
BufferedJSONAttrDict as JSONDict,
)
from .contrib import Project, TemporaryProject, get_job, get_project, init_project
from .core.h5store import H5Store, H5StoreManager
from .diff import diff_jobs
from .h5store import H5Store, H5StoreManager
from .project import Project, TemporaryProject, get_job, get_project, init_project
from .version import __version__

# Alias some properties related to buffering into the signac namespace.
Expand All @@ -27,7 +27,6 @@

__all__ = [
"__version__",
"contrib",
"errors",
"sync",
"Project",
Expand Down
18 changes: 8 additions & 10 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@
else:
READLINE = True

from . import get_project, init_project
from .common import config
from .common.configobj import Section, flatten_errors
from .contrib.filterparse import parse_filter_arg
from .contrib.import_export import _SchemaPathEvaluationError, export_jobs
from .contrib.utility import _add_verbosity_argument, _print_err, _query_yes_no
from .core.utility import _safe_relpath
from . import config, get_project, init_project
from ._utility import _add_verbosity_argument, _print_err, _query_yes_no, _safe_relpath
from ._vendor.configobj import Section, flatten_errors
from .diff import diff_jobs
from .errors import (
DestinationExistsError,
Expand All @@ -44,6 +40,8 @@
SchemaSyncConflict,
SyncConflict,
)
from .filterparse import parse_filter_arg
from .import_export import _SchemaPathEvaluationError, export_jobs
from .sync import DocSync, FileSync
from .version import __version__

Expand Down Expand Up @@ -486,7 +484,7 @@ def _sig(st):


def _main_import_interactive(project, origin, args):
from .contrib.import_export import _prepare_import_into_project
from .import_export import _prepare_import_into_project

if args.move:
raise ValueError(
Expand Down Expand Up @@ -529,7 +527,7 @@ def _main_import_interactive(project, origin, args):


def _main_import_non_interactive(project, origin, args):
from .contrib.import_export import _prepare_import_into_project
from .import_export import _prepare_import_into_project

try:
paths = {}
Expand Down Expand Up @@ -631,7 +629,7 @@ def main_update_cache(args):

def main_migrate(args):
"""Migrate the project's schema to the current schema version."""
from .contrib.migration import _get_config_schema_version, apply_migrations
from .migration import _get_config_schema_version, apply_migrations
from .version import SCHEMA_VERSION

root = args.root_directory if args.root_directory else os.getcwd()
Expand Down
2 changes: 1 addition & 1 deletion signac/core/dict_manager.py → signac/_dict_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
import uuid

from .utility import _safe_relpath
from ._utility import _safe_relpath


class _DictManager:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from math import isclose
from numbers import Number

from ..errors import InvalidKeyError
from .utility import _nested_dicts_to_dotted_keys, _to_hashable
from ._utility import _nested_dicts_to_dotted_keys, _to_hashable
from .errors import InvalidKeyError

logger = logging.getLogger(__name__)

Expand Down
21 changes: 16 additions & 5 deletions signac/contrib/utility.py → signac/_utility.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
# Copyright (c) 2017 The Regents of the University of Michigan
# All rights reserved.
# This software is licensed under the BSD 3-Clause License.
"""Utilities for signac."""
"""Utility functions."""

import logging
import os
import os.path
import sys
from collections.abc import Mapping
from datetime import timedelta
from time import time

logger = logging.getLogger(__name__)


def _print_err(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)


def _safe_relpath(path):
"""Attempt to make a relative path, or return the original path.
This is useful for logging and representing objects, where an absolute path
may be very long.
"""
try:
return os.path.relpath(path)
except ValueError:
# Windows cannot find relative paths across drives, so show the
# original path instead.
return path


def _query_yes_no(question, default="yes"): # pragma: no cover
"""Ask a yes/no question via input() and return their answer.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions signac/common/__init__.py

This file was deleted.

11 changes: 0 additions & 11 deletions signac/common/errors.py

This file was deleted.

10 changes: 5 additions & 5 deletions signac/common/config.py → signac/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import logging
import os

from .configobj import ConfigObj, ConfigObjError
from .configobj.validate import Validator
from ._vendor.configobj import ConfigObj, ConfigObjError
from ._vendor.configobj.validate import Validator
from .errors import ConfigError

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -36,9 +36,9 @@ def _raise_if_older_schema(root):
IncompatibleSchemaVersion
If the project uses an older schema version that requires migration.
"""
from ..contrib.errors import IncompatibleSchemaVersion
from ..contrib.migration import _get_config_schema_version
from ..version import SCHEMA_VERSION, __version__
from .errors import IncompatibleSchemaVersion
from .migration import _get_config_schema_version
from .version import SCHEMA_VERSION, __version__

schema_version = int(SCHEMA_VERSION)

Expand Down
19 changes: 0 additions & 19 deletions signac/contrib/__init__.py

This file was deleted.

63 changes: 0 additions & 63 deletions signac/contrib/errors.py

This file was deleted.

4 changes: 0 additions & 4 deletions signac/core/__init__.py

This file was deleted.

0 comments on commit 3de5f48

Please sign in to comment.