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

Support TOML as a configuration file format alongside CFG/INI. #560

Merged
merged 11 commits into from
Feb 3, 2022

Conversation

osma
Copy link
Member

@osma osma commented Jan 28, 2022

Using Annif efficiently with DVC requires that DVC understands the Annif configuration file; the current INI-style format is not supported by DVC (see #547).

This PR adds support for TOML as a configuration file format alongside the current one (which still works). Unless the path to the configuration file has been set using the ANNIF_PROJECTS environment variable or the -p command line option, the configuration will be read from projects.cfg if it exists, otherwise from projects.toml.

The main difference in the configuration syntax is that TOML requires string values to be quoted, e.g.

language="fi"

instead of

language=fi

The tomli parser is used for parsing project configuration files with a .toml extension. It's a very minimal read-only, pure Python TOML parser; in the future, similar functionality (based on tomli) may be included in the Python standard library - see PEP 680.

Fixes #547

Opening as draft PR to get early feedback from CI tools. Probably some refactoring will be necessary, as well as additional unit tests.

@codecov
Copy link

codecov bot commented Jan 28, 2022

Codecov Report

Merging #560 (4fcee08) into master (eb84777) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #560    +/-   ##
========================================
  Coverage   99.46%   99.47%            
========================================
  Files          82       84     +2     
  Lines        5444     5544   +100     
========================================
+ Hits         5415     5515   +100     
  Misses         29       29            
Impacted Files Coverage Δ
annif/cli.py 99.63% <ø> (ø)
annif/config.py 100.00% <100.00%> (ø)
annif/default_config.py 100.00% <100.00%> (ø)
annif/registry.py 100.00% <100.00%> (ø)
tests/test_config.py 100.00% <100.00%> (ø)
tests/test_project.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb84777...4fcee08. Read the comment docs.

@osma osma force-pushed the issue547-config-toml-format branch from 66dcebd to b816e71 Compare February 1, 2022 15:27
@sonarcloud
Copy link

sonarcloud bot commented Feb 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@osma osma marked this pull request as ready for review February 3, 2022 12:33
@osma osma requested a review from juhoinkinen February 3, 2022 12:34
Copy link
Member

@juhoinkinen juhoinkinen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@osma osma merged commit 01ff9aa into master Feb 3, 2022
@osma osma deleted the issue547-config-toml-format branch February 3, 2022 13:28
@osma osma added this to the 0.57 milestone Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration file format compatible with DVC
2 participants