diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index f49313b..2bacdb8 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -4,6 +4,22 @@ on: types: - created workflow_dispatch: + inputs: + lookback: + default: 3 +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read jobs: TagBot: if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' diff --git a/Project.toml b/Project.toml index e514c41..37d865a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AtomsIO" uuid = "1692102d-eeb4-4df9-807b-c9517f998d44" authors = ["Michael F. Herbst and contributors"] -version = "0.2.3" +version = "0.2.5" [deps] AtomsBase = "a963bdd2-2df7-4f54-a1ee-49d51e6be12a" @@ -15,10 +15,10 @@ UnitfulAtomic = "a7773ee8-282e-5fa2-be4e-bd808c38a91a" XCrySDenStructureFormat = "02310045-4665-40c9-a658-98c497d2eca9" [compat] -AtomsBase = "0.3" -AtomsBaseTesting = "0.1" +AtomsBase = "0.4" +AtomsBaseTesting = "0.2" Chemfiles = "0.10.41" -ExtXYZ = "0.1.14" +ExtXYZ = "0.2" PeriodicTable = "1" Reexport = "1" Unitful = "1" diff --git a/lib/AtomsIOPython/Project.toml b/lib/AtomsIOPython/Project.toml index fce270d..1d6d1bd 100644 --- a/lib/AtomsIOPython/Project.toml +++ b/lib/AtomsIOPython/Project.toml @@ -1,7 +1,7 @@ name = "AtomsIOPython" uuid = "9e4c859b-2281-48ef-8059-f50fe53c37b0" authors = ["Michael F. Herbst and contributors"] -version = "0.1.2" +version = "0.1.3" [deps] ASEconvert = "3da9722f-58c2-4165-81be-b4d7253e8fd2" @@ -9,8 +9,8 @@ AtomsIO = "1692102d-eeb4-4df9-807b-c9517f998d44" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] -ASEconvert = "0.1.4" -AtomsBaseTesting = "0.1" +ASEconvert = "0.1.8" +AtomsBaseTesting = "0.2" AtomsIO = "0.2" Reexport = "1" julia = "1.6" diff --git a/lib/AtomsIOPython/src/AtomsIOPython.jl b/lib/AtomsIOPython/src/AtomsIOPython.jl index 2e7e8b7..c649369 100644 --- a/lib/AtomsIOPython/src/AtomsIOPython.jl +++ b/lib/AtomsIOPython/src/AtomsIOPython.jl @@ -2,17 +2,15 @@ module AtomsIOPython using Reexport @reexport using AtomsIO -include("ase.jl") - export AseParser +include("ase.jl") -function __init__() - # Append python-based parsers to the parser list in AtomsIO. +function AtomsIO.atomsio_extra_parsers(::AtomsIO.PythonParsers) + # Register the python-based parsers with AtomsIO + # # Note: For reproducibility reasons changing the order of these parsers is a # *breaking change* (as it alters the behaviour of AtomsIO.load_system). - # Moreover since not all users will want to rely on Python dependencies, it is - # crucial that the python-based parsers are *appended* to this list. - parsers = AbstractParser[AseParser(), ] - append!(AtomsIO.DEFAULT_PARSER_ORDER, parsers) + AbstractParser[AseParser(), ] end + end diff --git a/lib/AtomsIOPython/test/ase.jl b/lib/AtomsIOPython/test/ase.jl index 1b0f5ca..448ab5e 100644 --- a/lib/AtomsIOPython/test/ase.jl +++ b/lib/AtomsIOPython/test/ase.jl @@ -9,7 +9,7 @@ function make_ase_system(args...; drop_atprop=Symbol[], kwargs...) end @testset "ASE parser has been added" begin - @test AseParser() in AtomsIO.DEFAULT_PARSER_ORDER + @test AseParser() in AtomsIO.default_parsers() end @testset "ASE system write/read" begin diff --git a/lib/AtomsIOPython/test/comparison.jl b/lib/AtomsIOPython/test/comparison.jl index 711109d..c6fd7fe 100644 --- a/lib/AtomsIOPython/test/comparison.jl +++ b/lib/AtomsIOPython/test/comparison.jl @@ -20,7 +20,7 @@ using AtomsBaseTesting end @testset "Test structures from simple XYZ files parse the same" begin - drop_atprop = [:covalent_radius, :vdw_radius, :velocity, :charge, :atomic_mass] + drop_atprop = [:covalent_radius, :vdw_radius, :velocity, :charge, :mass] drop_sysprop = [:extra_data] data = make_test_system(; drop_atprop, drop_sysprop, cellmatrix=:lower_triangular) system = periodic_system(data.atoms, data.box; data.sysprop...) diff --git a/src/extxyz.jl b/src/extxyz.jl index 913754e..ce89946 100644 --- a/src/extxyz.jl +++ b/src/extxyz.jl @@ -3,7 +3,7 @@ import ExtXYZ """ Parse or write file using [ExtXYZ](https://github.com/libAtoms/ExtXYZ.jl) -Supported formats: +Supported formats: - [XYZ](https://openbabel.org/wiki/XYZ) and [extxyz](https://github.com/libAtoms/extxyz#extended-xyz-specification-and-parsing-tools) files """ struct ExtxyzParser <: AbstractParser end diff --git a/src/saveload.jl b/src/saveload.jl index e88b76e..6c4d82a 100644 --- a/src/saveload.jl +++ b/src/saveload.jl @@ -1,15 +1,29 @@ -# The list of parsers in the order to try them. -# Python-based parsers are appended once AtomsIOPython is loaded. -# Note: For reproducibility reasons changing the order of these parsers is a -# *breaking change* (as it alters the behaviour of AtomsIO.load_system). -# Moreover since not all users will want to rely on Python dependencies, it is -# crucial that the python packages are only *appended* to this list. -const DEFAULT_PARSER_ORDER = AbstractParser[ - ExtxyzParser(), XcrysdenstructureformatParser(), ChemfilesParser(), -] + +# Mechanics to add additional parsers automatically in a well-defined order +# Add marker structs here for every new "category" of parsers that become +# dynamically available (e.g. the PythonParsers() defined in AtomsIOPython) +struct PythonParsers end +atomsio_extra_parsers(marker) = AbstractParser[] + +function default_parsers() + # The list of parsers in the order to try them. + # Python-based parsers are appended once AtomsIOPython is loaded, + # since this defines an appropriate method for the PythonParsers() marker struct. + # + # Note: For reproducibility reasons changing the order of these parsers is a + # *breaking change* (as it alters the behaviour of AtomsIO.load_system). + # Moreover since not all users will want to rely on Python dependencies, it is + # crucial that the python packages are only *appended* to this list. + + AbstractParser[ + ExtxyzParser(), XcrysdenstructureformatParser(), ChemfilesParser(), + atomsio_extra_parsers(PythonParsers())... # Add python parsers if they are available + ] +end function determine_parser(file; save=false, trajectory=false) - idx_parser = findfirst(DEFAULT_PARSER_ORDER) do parser + parsers = default_parsers() + idx_parser = findfirst(parsers) do parser supports_parsing(parser, file; save, trajectory) end if isnothing(idx_parser) @@ -22,7 +36,7 @@ function determine_parser(file; save=false, trajectory=false) end error(errormsg) end - DEFAULT_PARSER_ORDER[idx_parser] + parsers[idx_parser] end diff --git a/test/chemfiles.jl b/test/chemfiles.jl index 3ba808a..fa317f5 100644 --- a/test/chemfiles.jl +++ b/test/chemfiles.jl @@ -10,15 +10,16 @@ function make_chemfiles_system(D=3; drop_atprop=Symbol[], infinite=false, kwargs extra_sysprop=(; extra_data=42.0), cellmatrix=:upper_triangular, kwargs...) if infinite - system = isolated_system(data.atoms; data.sysprop...) + cell = IsolatedCell(3) else - system = periodic_system(data.atoms, data.box; data.sysprop...) + cell = PeriodicCell(; cell_vectors=data.box, periodicity=(true, true, true)) end + system = AtomsBase.FlexibleSystem(data.atoms, cell; data.sysprop...) merge(data, (; system)) end @testset "Chemfiles system write / read" begin - system = make_chemfiles_system(; drop_atprop=[:atomic_mass]).system + system = make_chemfiles_system(; drop_atprop=[:mass]).system mktempdir() do d outfile = joinpath(d, "output.cml") save_system(ChemfilesParser(), outfile, system) @@ -30,7 +31,7 @@ end @testset "Chemfiles trajectory write/read" begin ignore_atprop = [:covalent_radius, :vdw_radius] - systems = [make_chemfiles_system(; drop_atprop=[:atomic_mass]).system for _ in 1:3] + systems = [make_chemfiles_system(; drop_atprop=[:mass]).system for _ in 1:3] mktempdir() do d outfile = joinpath(d, "output.cml") save_trajectory(ChemfilesParser(), outfile, systems) @@ -41,7 +42,7 @@ end test_approx_eq(systems[end], load_system(ChemfilesParser(), outfile); rtol=1e-6, ignore_atprop) - test_approx_eq(systems[2], load_system(ChemfilesParser(), outfile, 2); + test_approx_eq(systems[2], load_system(ChemfilesParser(), outfile, 2); rtol=1e-6, ignore_atprop) end end diff --git a/test/xsf.jl b/test/xsf.jl index e7a413a..3afa121 100644 --- a/test/xsf.jl +++ b/test/xsf.jl @@ -8,8 +8,7 @@ using UnitfulAtomic function make_xsf_system(D=3; drop_atprop=Symbol[], drop_sysprop=Symbol[], kwargs...) @assert D == 3 # Only 3D systems are supported n_atoms = 5 # Copied from AtomsBaseTesting.make_test_system, used for making forces - xsf_drop_atprop = [:velocity, :charge, :atomic_mass, :vdw_radius, :covalent_radius, - :magnetic_moment] + xsf_drop_atprop = [:velocity, :charge, :mass, :vdw_radius, :covalent_radius, :magnetic_moment] xsf_drop_sysprop = [:extra_data, :charge, :multiplicity] force = [randn(3)u"Eh_au/Å" for _ in 1:n_atoms] make_test_system(D; drop_atprop=append!(drop_atprop, xsf_drop_atprop),