Skip to content

Commit

Permalink
Merge pull request #1512 from pyiron/ruff_sorting
Browse files Browse the repository at this point in the history
Add import sorting to ruff
  • Loading branch information
jan-janssen authored Jul 4, 2024
2 parents f37551c + 2494e29 commit 4a6b8ee
Show file tree
Hide file tree
Showing 67 changed files with 287 additions and 237 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: ruff
name: ruff lint
args: ["--fix"]
args: ["--select", "I", "--fix"]
files: ^pyiron_base/
- id: ruff-format
name: ruff format
53 changes: 25 additions & 28 deletions pyiron_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,49 @@
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

from pyiron_base.state import state

# API of the pyiron_base module - in alphabetical order
from pyiron_base.interfaces.factory import PyironFactory
from pyiron_base.storage.flattenedstorage import FlattenedStorage
from pyiron_base.storage.hdfio import FileHDFio, ProjectHDFio
from pyiron_base.storage.datacontainer import DataContainer
from pyiron_base.storage.has_stored_traits import HasStoredTraits
from pyiron_base.storage.inputlist import InputList
from pyiron_base.storage.parameters import GenericParameters
from pyiron_base.jobs.job.extension.executable import Executable
from pyiron_base.project.external import Notebook, load, dump
from pyiron_base.interfaces.has_groups import HasGroups
from pyiron_base.interfaces.has_hdf import HasHDF
from pyiron_base.interfaces.object import HasDatabase, HasStorage, PyironObject
from pyiron_base.jobs.datamining import PyironTable, TableJob
from pyiron_base.jobs.dynamic import warn_dynamic_job_classes
from pyiron_base.jobs.flex.factory import create_job_factory
from pyiron_base.jobs.job.extension.server.queuestatus import validate_que_request
from pyiron_base.jobs.job.generic import GenericJob
from pyiron_base.jobs.job.interactive import InteractiveBase
from pyiron_base.jobs.job.extension.executable import Executable
from pyiron_base.jobs.job.extension.jobstatus import (
JobStatus,
job_status_successful_lst,
job_status_finished_lst,
job_status_lst,
job_status_successful_lst,
)
from pyiron_base.jobs.job.jobtype import JOB_CLASS_DICT, JobType, JobTypeChoice
from pyiron_base.jobs.job.template import TemplateJob, PythonTemplateJob
from pyiron_base.jobs.job.extension.server.queuestatus import validate_que_request
from pyiron_base.jobs.job.factory import JobFactoryCore
from pyiron_base.jobs.job.generic import GenericJob
from pyiron_base.jobs.job.interactive import InteractiveBase
from pyiron_base.jobs.job.jobtype import JOB_CLASS_DICT, JobType, JobTypeChoice
from pyiron_base.jobs.job.template import PythonTemplateJob, TemplateJob
from pyiron_base.jobs.job.toolkit import BaseTools, Toolkit
from pyiron_base.jobs.master.flexible import FlexibleMaster
from pyiron_base.jobs.master.generic import GenericMaster, get_function_from_string
from pyiron_base.jobs.master.interactivewrapper import InteractiveWrapper
from pyiron_base.jobs.master.list import ListMaster
from pyiron_base.jobs.master.parallel import ParallelMaster, JobGenerator
from pyiron_base.project.generic import Project, Creator
from pyiron_base.utils.parser import Logstatus, extract_data_from_file
from pyiron_base.state.settings import Settings
from pyiron_base.jobs.master.parallel import JobGenerator, ParallelMaster
from pyiron_base.project.external import Notebook, dump, load
from pyiron_base.project.generic import Creator, Project
from pyiron_base.state import state
from pyiron_base.state.install import install_dialog
from pyiron_base.jobs.datamining import PyironTable, TableJob
from pyiron_base.interfaces.object import HasDatabase, HasStorage, PyironObject
from pyiron_base.interfaces.has_groups import HasGroups
from pyiron_base.interfaces.has_hdf import HasHDF

from pyiron_base.jobs.job.toolkit import Toolkit, BaseTools
from pyiron_base.state.settings import Settings
from pyiron_base.storage.datacontainer import DataContainer
from pyiron_base.storage.flattenedstorage import FlattenedStorage
from pyiron_base.storage.has_stored_traits import HasStoredTraits
from pyiron_base.storage.hdfio import FileHDFio, ProjectHDFio
from pyiron_base.storage.inputlist import InputList
from pyiron_base.storage.parameters import GenericParameters
from pyiron_base.utils.jedi import fix_ipython_autocomplete
from pyiron_base.utils.parser import Logstatus, extract_data_from_file

# Internal init
from ._version import get_versions
from pyiron_base.utils.jedi import fix_ipython_autocomplete


Project.register_tools("base", BaseTools)

Expand Down
11 changes: 6 additions & 5 deletions pyiron_base/_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

"""Classes to help developers avoid code duplication when writing tests for pyiron."""

from contextlib import redirect_stdout
import doctest
from io import StringIO
import unittest
import os
from pyiron_base import PythonTemplateJob, state
from pyiron_base.project.generic import Project
import unittest
from abc import ABC
from contextlib import redirect_stdout
from inspect import getfile
from io import StringIO

import numpy as np

from pyiron_base import PythonTemplateJob, state
from pyiron_base.project.generic import Project

__author__ = "Liam Huber"
__copyright__ = (
Expand Down
2 changes: 1 addition & 1 deletion pyiron_base/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"""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


def get_keywords() -> Dict[str, str]:
Expand Down
2 changes: 1 addition & 1 deletion pyiron_base/cli/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import warnings

from pyiron_base.cli import cp, ls, mv, rm, install, reloadfile, wrapper
from pyiron_base.cli import cp, install, ls, mv, reloadfile, rm, wrapper

__author__ = "Marvin Poul"
__copyright__ = (
Expand Down
2 changes: 2 additions & 0 deletions pyiron_base/cli/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import datetime
import re
import sys

import pandas as pd

import pyiron_base.jobs.job.extension.jobstatus
from pyiron_base import Project

Expand Down
4 changes: 3 additions & 1 deletion pyiron_base/cli/reloadfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.
import os
from h5io_browser.base import _open_hdf
import shutil

from h5io_browser.base import _open_hdf

from pyiron_base import Project
from pyiron_base.state import state

Expand Down
1 change: 1 addition & 0 deletions pyiron_base/cli/rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import os

from pyiron_base.project.generic import Project

__author__ = "Marvin Poul"
Expand Down
6 changes: 4 additions & 2 deletions pyiron_base/database/filetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
"""

import datetime
import os
from abc import ABCMeta
from collections.abc import Iterable

import numpy as np
import os
import pandas
from h5io_browser.base import _read_hdf, _write_hdf
from pyfileindex import PyFileIndex

from pyiron_base.database.interface import IsDatabase
from h5io_browser.base import _read_hdf, _write_hdf

__author__ = "Jan Janssen"
__copyright__ = (
Expand Down
21 changes: 12 additions & 9 deletions pyiron_base/database/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@
DatabaseAccess class deals with accessing the database
"""

import numpy as np
import re
import os
import re
from datetime import datetime
from queue import Empty as QueueEmpty
from queue import SimpleQueue
from threading import Lock, Thread

import numpy as np
import pandas
from pyiron_snippets.deprecate import deprecate
from pyiron_snippets.logger import logger
from pyiron_snippets.retry import retry
from sqlalchemy import (
create_engine,
MetaData,
Table,
text,
and_,
create_engine,
or_,
text,
)
from sqlalchemy.exc import DatabaseError, OperationalError
from sqlalchemy.pool import NullPool
from sqlalchemy.sql import select
from sqlalchemy.exc import OperationalError, DatabaseError
from threading import Thread, Lock
from queue import SimpleQueue, Empty as QueueEmpty
from pyiron_snippets.retry import retry
from pyiron_base.database.tables import get_historical_table

from pyiron_base.database.interface import IsDatabase
from pyiron_base.database.sqlcolumnlength import CHEMICALFORMULA_STR_LENGTH
from pyiron_base.database.tables import get_historical_table

__author__ = "Murat Han Celik"
__copyright__ = (
Expand Down
9 changes: 5 additions & 4 deletions pyiron_base/database/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
DatabaseAccess class deals with accessing the database
"""

import fnmatch
import re
import typing
import warnings
from abc import ABC, abstractmethod
from collections.abc import Iterable
import warnings

import numpy as np
import re
import pandas
from pyiron_snippets.deprecate import deprecate
from pyiron_snippets.logger import logger
import typing
import fnmatch

__author__ = "Murat Han Celik"
__copyright__ = (
Expand Down
1 change: 1 addition & 0 deletions pyiron_base/database/jobtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import numpy as np

from pyiron_base.database.filetable import FileTable

__author__ = "Jan Janssen"
Expand Down
4 changes: 3 additions & 1 deletion pyiron_base/database/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
A class for mediating connections to SQL databases.
"""

import os
from urllib.parse import quote_plus

from pyiron_snippets.logger import logger
from pyiron_snippets.singleton import Singleton

from pyiron_base.state.settings import settings as s
import os

__author__ = "Jan Janssen, Liam Huber"
__copyright__ = (
Expand Down
9 changes: 5 additions & 4 deletions pyiron_base/database/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

import pandas as pd
from sqlalchemy import (
create_engine,
select,
distinct,
MetaData,
Table,
create_engine,
distinct,
false,
func,
or_,
false,
select,
)

from pyiron_base.state import state

__author__ = "Muhammad Hassani"
Expand Down
13 changes: 7 additions & 6 deletions pyiron_base/database/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
String,
Table,
)

from pyiron_base.database.sqlcolumnlength import (
PROJECT_PATH_STR_LENGTH,
PROJECT_STR_LENGTH,
JOB_STR_LENGTH,
SUBJOB_STR_LENGTH,
CHEMICALFORMULA_STR_LENGTH,
STATUS_STR_LENGTH,
COMPUTER_STR_LENGTH,
HAMILTON_STR_LENGTH,
HAMVERSION_STR_LENGTH,
JOB_STR_LENGTH,
PROJECT_PATH_STR_LENGTH,
PROJECT_STR_LENGTH,
STATUS_STR_LENGTH,
SUBJOB_STR_LENGTH,
USERNAME_STR_LENGTH,
COMPUTER_STR_LENGTH,
)

__author__ = "Murat Han Celik, Liam Huber"
Expand Down
4 changes: 2 additions & 2 deletions pyiron_base/interfaces/has_hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Distributed under the terms of "New BSD License", see the LICENSE file.
"""Interface for classes to serialize to HDF5."""

from pyiron_base.storage.hdfio import ProjectHDFio

from abc import ABC, abstractmethod

from pyiron_base.storage.hdfio import ProjectHDFio

__author__ = "Marvin Poul"
__copyright__ = (
"Copyright 2021, Max-Planck-Institut für Eisenforschung GmbH - "
Expand Down
4 changes: 2 additions & 2 deletions pyiron_base/interfaces/lockable.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
sibling classes may bring in.
"""

import warnings
from contextlib import nullcontext
from typing import Optional, Literal
from functools import wraps
import warnings
from typing import Literal, Optional

from pyiron_base.interfaces.has_groups import HasGroups

Expand Down
5 changes: 3 additions & 2 deletions pyiron_base/interfaces/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
"""

from abc import ABC
from pyiron_base.storage.datacontainer import DataContainer

from pyiron_base.interfaces.has_hdf import HasHDF
from pyiron_base.storage.hdfio import ProjectHDFio
from pyiron_base.state import state
from pyiron_base.storage.datacontainer import DataContainer
from pyiron_base.storage.hdfio import ProjectHDFio

__author__ = "Liam Huber"
__copyright__ = (
Expand Down
12 changes: 6 additions & 6 deletions pyiron_base/jobs/datamining.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

import codecs
import concurrent.futures
import json
import os
import types
from datetime import datetime
from typing import List, Tuple

import cloudpickle
import json
import numpy as np
import os
import pandas
from pandas.errors import EmptyDataError
from pyiron_snippets.deprecate import deprecate
from tqdm.auto import tqdm
import types
from typing import List, Tuple

from pyiron_base.jobs.job.generic import GenericJob
from pyiron_base.jobs.job.extension import jobstatus
from pyiron_base.jobs.job.generic import GenericJob
from pyiron_base.storage.hdfio import FileHDFio


__author__ = "Uday Gajera, Jan Janssen, Joerg Neugebauer"
__copyright__ = (
"Copyright 2020, Max-Planck-Institut für Eisenforschung GmbH - "
Expand Down
2 changes: 1 addition & 1 deletion pyiron_base/jobs/flex/executablecontainer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import cloudpickle
import numpy as np

from pyiron_base.jobs.job.template import TemplateJob
from pyiron_base.jobs.job.runfunction import CalculateFunctionCaller
from pyiron_base.jobs.job.template import TemplateJob


class ExecutableContainerJob(TemplateJob):
Expand Down
Loading

0 comments on commit 4a6b8ee

Please sign in to comment.