Skip to content

Commit

Permalink
updated toml file and relaunched ruff linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aalbino2 committed Aug 21, 2024
1 parent 42495bf commit 1ee7a38
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 169 deletions.
10 changes: 0 additions & 10 deletions nomad.yaml

This file was deleted.

104 changes: 66 additions & 38 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,30 @@ requires = [
build-backend = "setuptools.build_meta"

[project]
classifiers = [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
]
name = "nomad-material-processing"
dynamic = ["version"]
description = "A plugin for NOMAD containing base sections for material processing."
readme = "README.md"
authors = [
{ name = "Sarthak Kapoor", email = '[email protected]' },
{ name = "Hampus Näsström", email = '[email protected]' },
{ name = "Andrea Albino", email = '[email protected]' },
{ name = "Sebastian Brückner", email = '[email protected]' },
]
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: Apache Software License",
]
license = { file = "LICENSE" }
dependencies = [
"nomad-lab>=1.3.3.dev86",
"nomad-lab>=1.3.4",
]
[project.optional-dependencies]
dev = [
"pytest",
"ruff",
"structlog>=22.3.0",
]

[project.license]
file = "LICENSE"

[project.urls]
"Homepage" = "https://github.com/FAIRmat-NFDI/nomad-material-processing"
Expand All @@ -42,38 +38,69 @@ file = "LICENSE"
[tool.uv]
index-url = "https://gitlab.mpcdf.mpg.de/api/v4/projects/2187/packages/pypi/simple"


[project.optional-dependencies]
dev = [
"pytest",
"ruff",
"structlog",
]

[tool.ruff]
include = ["src/*.py", "tests/*.py"]

exclude = ["dependencies"]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

# Same as Black.
line-length = 88
indent-width = 4

[tool.ruff.lint]
select = [
"E", # pycodestyle
"W", # pycodestyle
"PL", # pylint
# pycodestyle
"E",
# Pyflakes
"F",
# pyupgrade
"UP",
# isort
"I",
# pylint
"PL",
]

ignore = [
"E501", # Line too long ({width} > {limit} characters)
"E701", # Multiple statements on one line (colon)
"E731", # Do not assign a lambda expression, use a def
"E402", # Module level import not at top of file
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0915", # Too many statements
"PLR2004", # Magic value used instead of constant
"PLW0603", # Using the global statement
"PLW2901", # redefined-loop-name
"PLR1714", # consider-using-in
"PLR5501", # else-if-used
"F403", # 'from module import *' used; unable to detect undefined names
]

fixable = ["ALL"]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# this is entirely optional, you can remove this if you wish to
[tool.ruff.format]
# use single quotes for strings.
quote-style = "single"
Expand All @@ -87,10 +114,11 @@ skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.setuptools]
package-dir = { "" = "src" }

[tool.setuptools.packages.find]
where = [
"src",
]
where = ["src"]

[project.entry-points.'nomad.plugin']

Expand Down
24 changes: 12 additions & 12 deletions src/nomad_material_processing/combinatorial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json

#
# Copyright The NOMAD Authors.
Expand All @@ -20,17 +19,8 @@
from typing import (
TYPE_CHECKING,
)

import plotly.graph_objects as go
from nomad.datamodel.metainfo.plot import (
PlotlyFigure,
PlotSection,
)
from nomad.metainfo import (
Package,
Quantity,
SubSection,
Section,
)
from nomad.datamodel.data import (
ArchiveSection,
EntryData,
Expand All @@ -44,6 +34,16 @@
CompositeSystem,
CompositeSystemReference,
)
from nomad.datamodel.metainfo.plot import (
PlotlyFigure,
PlotSection,
)
from nomad.metainfo import (
Package,
Quantity,
Section,
SubSection,
)

if TYPE_CHECKING:
from nomad.datamodel.datamodel import (
Expand All @@ -65,8 +65,8 @@ class CombinatorialLibrary(CompositeSystem, EntryData, PlotSection):

def plot(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
from nomad.search import (
search,
MetadataPagination,
search,
)

query = {
Expand Down
2 changes: 2 additions & 0 deletions src/nomad_material_processing/crystal_growth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
from typing import (
TYPE_CHECKING,
)

from nomad.metainfo import (
Package,
Section,
)

from nomad_material_processing.general import (
SampleDeposition,
)
Expand Down
2 changes: 2 additions & 0 deletions src/nomad_material_processing/epitaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
from typing import (
TYPE_CHECKING,
)

from nomad.metainfo import (
Package,
Section,
)

from nomad_material_processing.general import (
SampleDeposition,
)
Expand Down
36 changes: 13 additions & 23 deletions src/nomad_material_processing/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,32 @@
BoundLogger,
)

from nomad.datamodel.metainfo.annotations import ELNAnnotation, ELNComponentEnum

import numpy as np
from nomad.datamodel.data import EntryData, ArchiveSection

from nomad.metainfo import (
SchemaPackage,
Quantity,
SubSection,
Section,
MEnum,
)

from nomad.config import config
from nomad.datamodel.data import ArchiveSection, EntryData
from nomad.datamodel.metainfo.annotations import ELNAnnotation, ELNComponentEnum
from nomad.datamodel.metainfo.basesections import (
ElementalComposition,
CompositeSystem,
SynthesisMethod,
ProcessStep,
CompositeSystemReference,
ElementalComposition,
Process,
ProcessStep,
SynthesisMethod,
SystemComponent,
CompositeSystemReference,
)
from nomad.datamodel.metainfo.annotations import (
ELNAnnotation,
ELNComponentEnum,
)
from nomad.datamodel.metainfo.workflow import (
Link,
)
from nomad.metainfo import (
SectionProxy,
MEnum,
Quantity,
Reference,
SchemaPackage,
Section,
SectionProxy,
SubSection,
)

from nomad.config import config

m_package = SchemaPackage(name='Material Processing')

configuration = config.get_plugin_entry_point('nomad_material_processing:schema')
Expand Down
2 changes: 1 addition & 1 deletion src/nomad_material_processing/solution/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class SolutionSchemaPackageEntryPoint(SchemaPackageEntryPoint):
def load(self):
from nomad_material_processing.solution.schema import m_package
from nomad_material_processing.solution.general import m_package

return m_package

Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
from typing import TYPE_CHECKING, Union
from nomad.units import ureg

import numpy as np
from nomad.datamodel.data import (
ArchiveSection,
EntryData,
)
from nomad.datamodel.metainfo.annotations import (
ELNAnnotation,
SectionProperties,
Filter,
SectionProperties,
)
from nomad.datamodel.metainfo.basesections import (
Component,
CompositeSystem,
CompositeSystemReference,
SystemComponent,
InstrumentReference,
Process,
ProcessStep,
PureSubstanceComponent,
PubChemPureSubstanceSection,
PureSubstanceComponent,
SystemComponent,
)
from nomad.metainfo import (
SchemaPackage,
Datetime,
MEnum,
Quantity,
SchemaPackage,
Section,
SubSection,
)
from nomad.units import ureg

from nomad_material_processing.solution.utils import (
create_archive,
create_unique_filename,
)

if TYPE_CHECKING:
from structlog.stdlib import BoundLogger
from nomad.datamodel import EntryArchive
from structlog.stdlib import BoundLogger

from nomad.config import config

Expand Down Expand Up @@ -599,14 +601,13 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
if not self.volume:
# assume entire volume of the solution is used
self.volume = available_volume
else:
if self.volume > available_volume:
logger.warning(
f'The volume used for the "{self.name}" is greater than the '
'available volume of the solution. Setting it to the available '
'volume.'
)
self.volume = available_volume
elif self.volume > available_volume:
logger.warning(
f'The volume used for the "{self.name}" is greater than the '
'available volume of the solution. Setting it to the available '
'volume.'
)
self.volume = available_volume
if self.system.density:
self.mass = self.system.density * self.volume
super().normalize(archive, logger)
Expand Down
6 changes: 1 addition & 5 deletions src/nomad_material_processing/solution/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from typing import TYPE_CHECKING

import json
import math
import re
from typing import TYPE_CHECKING

import pandas as pd
import yaml

if TYPE_CHECKING:
Expand Down Expand Up @@ -84,7 +81,6 @@ def create_archive(
entry_dict, context, filename, file_type, logger, *, overwrite: bool = False
):
from nomad.datamodel.context import ClientContext
from nomad.datamodel import EntryArchive

file_exists = context.raw_path_exists(filename)
dicts_are_equal = None
Expand Down
Loading

0 comments on commit 1ee7a38

Please sign in to comment.