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

isort everything #3421

Merged
merged 3 commits into from
Jun 3, 2024
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
2 changes: 2 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile = black
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ deps: $(DEPS) ## install the dependencies
lint: ## run linter script
parsl/tests/lint-inits.sh

.PHONY: isort
isort: ## run isort on all files
isort --check .

.PHONY: flake8
flake8: ## run flake
flake8 parsl/
Expand Down Expand Up @@ -93,7 +97,7 @@ perf_test:
parsl-perf --time 5 --config parsl/tests/configs/local_threads.py

.PHONY: test ## run all tests with all config types
test: clean_coverage lint flake8 mypy local_thread_test htex_local_test htex_local_alternate_test wqex_local_test vineex_local_test radical_local_test config_local_test perf_test ## run all tests
test: clean_coverage isort lint flake8 mypy local_thread_test htex_local_test htex_local_alternate_test wqex_local_test vineex_local_test radical_local_test config_local_test perf_test ## run all tests

.PHONY: tag
tag: ## create a tag in git. to run, do a 'make VERSION="version string" tag
Expand Down
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
#
import os
import sys

import requests

sys.path.insert(0, os.path.abspath('../'))
import parsl

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down
2 changes: 1 addition & 1 deletion docs/teaching_scripts/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import numpy as np

from parsl import python_app, HighThroughputExecutor, Config
import parsl
from parsl import Config, HighThroughputExecutor, python_app

parsl.load(Config(executors=[HighThroughputExecutor(label='htex_spawn', max_workers_per_node=1, address='127.0.0.1')]))

Expand Down
2 changes: 1 addition & 1 deletion docs/userguide/examples/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from parsl.config import Config
from parsl.channels import LocalChannel
from parsl.config import Config
from parsl.executors import HighThroughputExecutor
from parsl.providers import LocalProvider

Expand Down
1 change: 1 addition & 0 deletions docs/userguide/examples/library.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from parsl import python_app


@python_app
def increment(x):
return x + 1
3 changes: 2 additions & 1 deletion docs/userguide/examples/run_increment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import parsl
from config import htex_config
from library import increment

import parsl

parsl.load(htex_config)

for i in range(5):
Expand Down
19 changes: 9 additions & 10 deletions parsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@

"""
import logging
import multiprocessing as _multiprocessing
import os
import platform

from parsl.version import VERSION
from parsl.app.app import bash_app, join_app, python_app
from parsl.config import Config
from parsl.executors import ThreadPoolExecutor
from parsl.executors import HighThroughputExecutor
from parsl.executors import WorkQueueExecutor
from parsl.log_utils import set_stream_logger
from parsl.log_utils import set_file_logger
from parsl.monitoring import MonitoringHub

from parsl.data_provider.files import File

from parsl.dataflow.dflow import DataFlowKernel, DataFlowKernelLoader
from parsl.executors import (
HighThroughputExecutor,
ThreadPoolExecutor,
WorkQueueExecutor,
)
from parsl.log_utils import set_file_logger, set_stream_logger
from parsl.monitoring import MonitoringHub
from parsl.version import VERSION

import multiprocessing as _multiprocessing
if platform.system() == 'Darwin':
_multiprocessing.set_start_method('fork', force=True)

Expand Down
10 changes: 6 additions & 4 deletions parsl/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@

import logging
import platform
import requests
import socket

import requests

try:
import fcntl
except ImportError:
fcntl = None # type: ignore[assignment]
import struct
import typeguard
import psutil
from typing import Callable, List, Set

from typing import Set, List, Callable
import psutil
import typeguard

logger = logging.getLogger(__name__)

Expand Down
9 changes: 3 additions & 6 deletions parsl/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
The App class encapsulates a generic leaf task that can be executed asynchronously.
"""
import logging
import typeguard
from abc import ABCMeta, abstractmethod
from inspect import signature
from typing import List, Optional, Sequence, Union
from typing import Any, Callable, Dict, List, Optional, Sequence, Union

import typeguard
from typing_extensions import Literal

from parsl.dataflow.dflow import DataFlowKernel

from typing import Any, Callable, Dict

from parsl.dataflow.futures import AppFuture


logger = logging.getLogger(__name__)


Expand Down
8 changes: 4 additions & 4 deletions parsl/app/bash.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from functools import update_wrapper
from functools import partial
from inspect import signature, Parameter
import logging
from functools import partial, update_wrapper
from inspect import Parameter, signature

from parsl.app.errors import wrap_error
from parsl.app.app import AppBase
from parsl.app.errors import wrap_error
from parsl.data_provider.files import File
from parsl.dataflow.dflow import DataFlowKernelLoader

Expand All @@ -17,6 +16,7 @@ def remote_side_bash_executor(func, *args, **kwargs):
"""
import os
import subprocess

import parsl.app.errors as pe
from parsl.utils import get_std_fname_mode

Expand Down
8 changes: 5 additions & 3 deletions parsl/app/errors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Exceptions raised by Apps."""
import logging
from functools import wraps
from typing import Callable, List, Optional, TypeVar, Union
from typing_extensions import ParamSpec
from types import TracebackType
import logging
from typing import Callable, List, Optional, TypeVar, Union

from tblib import Traceback
from typing_extensions import ParamSpec

from parsl.data_provider.files import File
from parsl.errors import ParslError
Expand Down Expand Up @@ -134,6 +135,7 @@ def wrap_error(func: Callable[P, R]) -> Callable[P, Union[R, RemoteExceptionWrap
@wraps(func)
def wrapper(*args: P.args, **kwargs: P.kwargs) -> Union[R, RemoteExceptionWrapper]:
import sys

from parsl.app.errors import RemoteExceptionWrapper
try:
return func(*args, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions parsl/app/futures.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""This module implements DataFutures.
"""
import logging
import typeguard
from concurrent.futures import Future
from typing import Optional

from parsl.data_provider.files import File
import typeguard

from typing import Optional
from parsl.data_provider.files import File

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion parsl/app/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import threading

import tblib.pickling_support

tblib.pickling_support.install()

from functools import wraps
Expand All @@ -11,14 +12,14 @@
from parsl.dataflow.dflow import DataFlowKernelLoader
from parsl.utils import AutoCancelTimer


logger = logging.getLogger(__name__)


def timeout(f, seconds: float):
@wraps(f)
def wrapper(*args, **kwargs):
import ctypes

import parsl.app.errors

def inject_exception(thread):
Expand Down
3 changes: 2 additions & 1 deletion parsl/benchmark/perf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
import concurrent.futures
import importlib
import time
import concurrent.futures

import parsl

min_iterations = 2
Expand Down
4 changes: 2 additions & 2 deletions parsl/channels/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from parsl.channels.base import Channel
from parsl.channels.ssh.ssh import SSHChannel
from parsl.channels.local.local import LocalChannel
from parsl.channels.ssh_il.ssh_il import SSHInteractiveLoginChannel
from parsl.channels.oauth_ssh.oauth_ssh import OAuthSSHChannel
from parsl.channels.ssh.ssh import SSHChannel
from parsl.channels.ssh_il.ssh_il import SSHInteractiveLoginChannel

__all__ = ['Channel', 'SSHChannel', 'LocalChannel', 'SSHInteractiveLoginChannel', 'OAuthSSHChannel']
1 change: 0 additions & 1 deletion parsl/channels/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from abc import ABCMeta, abstractmethod, abstractproperty

from typing import Dict, Tuple


Expand Down
3 changes: 2 additions & 1 deletion parsl/channels/errors.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
''' Exceptions raise by Apps.
'''
from parsl.errors import ParslError
from typing import Optional

from parsl.errors import ParslError


class ChannelError(ParslError):
""" Base class for all exceptions
Expand Down
7 changes: 4 additions & 3 deletions parsl/channels/oauth_ssh/oauth_ssh.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import logging
import paramiko
import socket

from parsl.errors import OptionalModuleMissing
import paramiko

from parsl.channels.ssh.ssh import SSHChannel
from parsl.errors import OptionalModuleMissing

try:
from oauth_ssh.ssh_service import SSHService
from oauth_ssh.oauth_ssh_token import find_access_token
from oauth_ssh.ssh_service import SSHService
_oauth_ssh_enabled = True
except (ImportError, NameError):
_oauth_ssh_enabled = False
Expand Down
10 changes: 9 additions & 1 deletion parsl/channels/ssh/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
import os

import paramiko

from parsl.channels.base import Channel
from parsl.channels.errors import BadHostKeyException, AuthException, SSHException, BadScriptPath, BadPermsScriptPath, FileCopyException
from parsl.channels.errors import (
AuthException,
BadHostKeyException,
BadPermsScriptPath,
BadScriptPath,
FileCopyException,
SSHException,
)
from parsl.utils import RepresentationMixin

logger = logging.getLogger(__name__)
Expand Down
1 change: 1 addition & 0 deletions parsl/channels/ssh_il/ssh_il.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging

import paramiko

from parsl.channels.ssh.ssh import SSHChannel

logger = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions parsl/concurrent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Interfaces modeled after Python's `concurrent library <https://docs.python.org/3/library/concurrent.html>`_"""
from typing import Callable, Dict, Optional, Iterator, Iterable
import time
from concurrent.futures import Executor
from typing import Callable, Dict, Iterable, Iterator, Optional
from warnings import warn
import time

from parsl import Config, DataFlowKernel
from parsl.app.python import PythonApp
Expand Down
10 changes: 5 additions & 5 deletions parsl/config.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import logging
import typeguard

from typing import Callable, Iterable, Optional, Sequence, Union

import typeguard
from typing_extensions import Literal

from parsl.utils import RepresentationMixin
from parsl.dataflow.dependency_resolvers import DependencyResolver
from parsl.dataflow.taskrecord import TaskRecord
from parsl.errors import ConfigurationError
from parsl.executors.base import ParslExecutor
from parsl.executors.threads import ThreadPoolExecutor
from parsl.errors import ConfigurationError
from parsl.dataflow.taskrecord import TaskRecord
from parsl.monitoring import MonitoringHub
from parsl.usage_tracking.api import UsageInformation
from parsl.utils import RepresentationMixin

logger = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions parsl/configs/ASPIRE1.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from parsl.providers import PBSProProvider
from parsl.launchers import MpiRunLauncher
from parsl.addresses import address_by_interface
from parsl.config import Config
from parsl.executors import HighThroughputExecutor
from parsl.addresses import address_by_interface
from parsl.launchers import MpiRunLauncher
from parsl.monitoring.monitoring import MonitoringHub
from parsl.providers import PBSProProvider

config = Config(
executors=[
Expand Down
13 changes: 6 additions & 7 deletions parsl/configs/Azure.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
"""Config for Azure"""
from parsl.config import Config
import getpass

from parsl.providers import AzureProvider
from parsl.executors import HighThroughputExecutor
from parsl.data_provider.http import HTTPInTaskStaging
from parsl.addresses import address_by_query
from parsl.config import Config
from parsl.data_provider.ftp import FTPInTaskStaging
from parsl.data_provider.http import HTTPInTaskStaging
from parsl.data_provider.rsync import RSyncStaging
from parsl.addresses import address_by_query

import getpass
from parsl.executors import HighThroughputExecutor
from parsl.providers import AzureProvider

vm_reference = {
# All fields below are required
Expand Down
7 changes: 4 additions & 3 deletions parsl/configs/ad_hoc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from parsl.providers import AdHocProvider
from typing import Any, Dict

from parsl.channels import SSHChannel
from parsl.executors import HighThroughputExecutor
from parsl.config import Config
from typing import Any, Dict
from parsl.executors import HighThroughputExecutor
from parsl.providers import AdHocProvider

user_opts: Dict[str, Dict[str, Any]]
user_opts = {'adhoc':
Expand Down
Loading
Loading