Skip to content

Commit

Permalink
[DATALAD RUNCMD] isort all files for consistency
Browse files Browse the repository at this point in the history
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "bash -c 'git ls-files '\"'\"'**/*.py'\"'\"' | xargs isort'",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
  • Loading branch information
yarikoptic committed Jan 17, 2024
1 parent 9993693 commit 67dfdc1
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 69 deletions.
9 changes: 6 additions & 3 deletions _datalad_buildsupport/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

import datetime
import os

from os.path import (
dirname,
join as opj,
)
from setuptools import Command, DistutilsOptionError

from setuptools import (
Command,
DistutilsOptionError,
)
from setuptools.config import read_configuration

import versioneer
Expand Down Expand Up @@ -210,8 +213,8 @@ def run(self):
if not os.path.exists(opath):
os.makedirs(opath)

from datalad.interface.common_cfg import definitions as cfgdefs
from datalad.dochelpers import _indent
from datalad.interface.common_cfg import definitions as cfgdefs

categories = {
'global': {},
Expand Down
6 changes: 4 additions & 2 deletions datalad_container/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__docformat__ = 'restructuredtext'

# Imported to set singularity/apptainer version commands at init
import datalad_container.extractors._load_singularity_versions # noqa
import datalad_container.extractors._load_singularity_versions # noqa

# defines a datalad command suite
# this symbold must be identified as a setuptools entrypoint
Expand Down Expand Up @@ -47,9 +47,10 @@
]
)

from datalad.support.extensions import register_config
from os.path import join as opj

from datalad.support.constraints import EnsureStr
from datalad.support.extensions import register_config

register_config(
'datalad.containers.location',
Expand All @@ -62,4 +63,5 @@
)

from . import _version

__version__ = _version.get_versions()['version']
11 changes: 9 additions & 2 deletions datalad_container/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
"""Git implementation of _version.py."""

import errno
import functools
import os
import re
import subprocess
import sys
from typing import Any, Callable, Dict, List, Optional, Tuple
import functools
from typing import (
Any,
Callable,
Dict,
List,
Optional,
Tuple,
)


def get_keywords() -> Dict[str, str]:
Expand Down
7 changes: 2 additions & 5 deletions datalad_container/adapters/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@

import hashlib
import json
import logging
import os
import os.path as op
import subprocess as sp
import sys
import tarfile
import tempfile

import logging

from datalad.utils import (
on_windows,
)
from datalad.utils import on_windows

lgr = logging.getLogger("datalad.containers.adapters.docker")

Expand Down
5 changes: 4 additions & 1 deletion datalad_container/adapters/tests/test_docker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import json
import os.path as op
from shutil import unpack_archive, which
import sys
from shutil import (
unpack_archive,
which,
)

import pytest
from datalad.cmd import (
Expand Down
27 changes: 17 additions & 10 deletions datalad_container/containers_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,31 @@
import logging
import os
import os.path as op
import re
from pathlib import (
Path,
PurePosixPath,
)
import re
from shutil import copyfile

from datalad.cmd import WitlessRunner
from datalad.interface.base import Interface
from datalad.interface.base import build_doc
from datalad.support.param import Parameter
from datalad.distribution.dataset import datasetmethod, EnsureDataset
from datalad.distribution.dataset import require_dataset
from datalad.interface.base import eval_results
from datalad.support.constraints import EnsureStr
from datalad.support.constraints import EnsureNone
from datalad.support.exceptions import InsufficientArgumentsError
from datalad.distribution.dataset import (
EnsureDataset,
datasetmethod,
require_dataset,
)
from datalad.interface.base import (
Interface,
build_doc,
eval_results,
)
from datalad.interface.results import get_status_dict
from datalad.support.constraints import (
EnsureNone,
EnsureStr,
)
from datalad.support.exceptions import InsufficientArgumentsError
from datalad.support.param import Parameter

from .utils import get_container_configuration

Expand Down
24 changes: 15 additions & 9 deletions datalad_container/containers_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@
import logging
import os.path as op

from datalad.interface.base import Interface
from datalad.interface.base import build_doc
import datalad.support.ansi_colors as ac
from datalad.coreapi import subdatasets
from datalad.distribution.dataset import (
Dataset,
EnsureDataset,
datasetmethod,
require_dataset,
)
from datalad.interface.base import (
Interface,
build_doc,
eval_results,
)
from datalad.interface.common_opts import recursion_flag
from datalad.support.param import Parameter
from datalad.distribution.dataset import datasetmethod, EnsureDataset, Dataset
from datalad.distribution.dataset import require_dataset
from datalad.interface.results import get_status_dict
from datalad.interface.utils import default_result_renderer
from datalad.interface.base import eval_results
from datalad.support.constraints import EnsureNone
import datalad.support.ansi_colors as ac
from datalad.interface.results import get_status_dict
from datalad.coreapi import subdatasets
from datalad.support.param import Parameter
from datalad.ui import ui

from datalad_container.utils import get_container_configuration
Expand Down
23 changes: 15 additions & 8 deletions datalad_container/containers_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
import logging
import os.path as op

from datalad.interface.base import Interface
from datalad.interface.base import build_doc
from datalad.support.param import Parameter
from datalad.distribution.dataset import datasetmethod, EnsureDataset
from datalad.distribution.dataset import require_dataset
from datalad.interface.base import eval_results
from datalad.support.constraints import EnsureNone
from datalad.support.constraints import EnsureStr
from datalad.distribution.dataset import (
EnsureDataset,
datasetmethod,
require_dataset,
)
from datalad.interface.base import (
Interface,
build_doc,
eval_results,
)
from datalad.interface.results import get_status_dict
from datalad.support.constraints import (
EnsureNone,
EnsureStr,
)
from datalad.support.param import Parameter
from datalad.utils import rmtree

from datalad_container.utils import get_container_configuration
Expand Down
25 changes: 15 additions & 10 deletions datalad_container/containers_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@
import os.path as op
import sys

from datalad.interface.base import Interface
from datalad.interface.base import build_doc
from datalad.support.param import Parameter
from datalad.distribution.dataset import datasetmethod
from datalad.distribution.dataset import require_dataset
from datalad.interface.base import eval_results
from datalad.utils import ensure_iter

from datalad.interface.results import get_status_dict
from datalad.core.local.run import (
Run,
get_command_pwds,
normalize_command,
run_command,
)
from datalad.distribution.dataset import (
datasetmethod,
require_dataset,
)
from datalad.interface.base import (
Interface,
build_doc,
eval_results,
)
from datalad.interface.results import get_status_dict
from datalad.support.param import Parameter
from datalad.utils import ensure_iter

from datalad_container.find_container import find_container_

lgr = logging.getLogger("datalad.containers.containers_run")
Expand Down Expand Up @@ -76,7 +80,8 @@ class ContainersRun(Interface):
def __call__(cmd, container_name=None, dataset=None,
inputs=None, outputs=None, message=None, expand=None,
explicit=False, sidecar=None):
from unittest.mock import patch # delayed, since takes long (~600ms for yoh)
from unittest.mock import \
patch # delayed, since takes long (~600ms for yoh)
pwd, _ = get_command_pwds(dataset)
ds = require_dataset(dataset, check_installed=True,
purpose='run a containerized command execution')
Expand Down
12 changes: 9 additions & 3 deletions datalad_container/extractors/metalad_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@
import time
from uuid import UUID

from datalad.support.external_versions import external_versions, UnknownVersion
from datalad_metalad.extractors.base import DataOutputCategory, ExtractorResult, FileMetadataExtractor
from datalad.support.external_versions import (
UnknownVersion,
external_versions,
)
from datalad_metalad import get_file_id
from datalad_metalad.extractors.base import (
DataOutputCategory,
ExtractorResult,
FileMetadataExtractor,
)

from datalad_container.utils import get_container_command


CURRENT_VERSION = "0.0.1"

lgr = logging.getLogger('datalad.metadata.extractors.metalad_container')
Expand Down
1 change: 1 addition & 0 deletions datalad_container/find_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _get_container_by_name(_, name, containers):

def _get_container_by_path(ds, name, containers):
from datalad.distribution.dataset import resolve_path

# Note: since datalad0.12.0rc6 resolve_path returns a Path object here,
# which then fails to equal c['path'] below as this is taken from
# config as a string
Expand Down
4 changes: 2 additions & 2 deletions datalad_container/tests/fixtures/singularity_image.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pytest
from pathlib import Path

import pytest
from datalad.api import Dataset
from datalad.tests.utils_pytest import with_tempfile

from datalad_container.utils import get_container_command
from datalad_container.tests.utils import add_pyscript_image
from datalad_container.utils import get_container_command

TEST_IMG_URL = 'shub://datalad/datalad-container:testhelper'

Expand Down
4 changes: 2 additions & 2 deletions datalad_container/tests/test_run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import os.path as op

import pytest
from datalad.api import (
Dataset,
clone,
Expand All @@ -9,11 +10,11 @@
containers_run,
create,
)
from datalad.local.rerun import get_run_info
from datalad.cmd import (
StdOutCapture,
WitlessRunner,
)
from datalad.local.rerun import get_run_info
from datalad.support.exceptions import IncompleteResultsError
from datalad.support.network import get_local_file_url
from datalad.tests.utils_pytest import (
Expand All @@ -36,7 +37,6 @@
on_windows,
)

import pytest
from datalad_container.tests.utils import add_pyscript_image

testimg_url = 'shub://datalad/datalad-container:testhelper'
Expand Down
4 changes: 2 additions & 2 deletions datalad_container/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import sys

from datalad.api import containers_add
from datalad.utils import chpwd
from datalad.tests.utils_pytest import SkipTest
from datalad.interface.common_cfg import dirs as appdirs
from datalad.tests.utils_pytest import SkipTest
from datalad.utils import chpwd


def add_pyscript_image(ds, container_name, file_name):
Expand Down
1 change: 0 additions & 1 deletion datalad_container/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

# the pathlib equivalent is only available in PY3.12
from os.path import lexists

from pathlib import (
PurePath,
PurePosixPath,
Expand Down
7 changes: 3 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os

import datetime
import os
import sys
from os import pardir
from os.path import (
abspath,
dirname,
exists,
join as opj,
)
from os import pardir

import datalad_container

Expand Down
7 changes: 4 additions & 3 deletions docs/utils/pygments_ansi_color.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-
"""Pygments lexer for text containing ANSI color codes."""
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import (
absolute_import,
unicode_literals,
)

import itertools
import re

import pygments.lexer
import pygments.token


Color = pygments.token.Token.Color

_ansi_code_to_color = {
Expand Down
Loading

0 comments on commit 67dfdc1

Please sign in to comment.