Skip to content

Commit

Permalink
Merge branch 'master' into cli
Browse files Browse the repository at this point in the history
  • Loading branch information
hechth authored Jul 8, 2024
2 parents 5a2aa02 + 50edef2 commit 1863439
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
17 changes: 17 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"
jobs:
post_create_environment:
- python -m pip install poetry
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with dev

sphinx:
configuration: docs/conf.py

formats:
- pdf

python:
install:
- method: pip
Expand Down
14 changes: 8 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description = "This package adjusts and cleans the metadata file provided by a u
authors = ["Zargham Ahmad <[email protected]>" ]
license = "MIT"
readme = "README.md"
keywords = ["metadata", "alkanes", "metabolomics"]

[tool.poetry.dependencies]
python = "^3.11"
Expand Down Expand Up @@ -47,7 +48,7 @@ line-length = 120

[tool.ruff.lint]
# Enable Pyflakes `E` and `F` codes by default.
select = [
lint.select = [
"F", # Pyflakes
"E", # pycodestyle (error)
"W", # pycodestyle (warning)
Expand All @@ -61,7 +62,7 @@ select = [
# "PLW", # Warning

]
ignore = [
lint.ignore = [
'D100', # Missing module docstring
'D104', # Missing public package docstring
# The following list excludes rules irrelevant to the Google style
Expand All @@ -80,8 +81,8 @@ ignore = [
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]
unfixable = []
lint.fixable = ["A", "B", "C", "D", "E", "F", "I"]
lint.unfixable = []

exclude = [
".bzr",
Expand All @@ -106,11 +107,12 @@ exclude = [
".venv",
"scripts",
]
per-file-ignores = {}
lint.per-file-ignores = {}


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

[tool.ruff.lint.isort]
known-first-party = ["rcx_tk"]
Expand Down
12 changes: 6 additions & 6 deletions src/rcx_tk/process_metadata_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import pandas as pd


def read_file(file_path: str) -> pd.DataFrame:
"""Imports the metadata file to pandas dataframe.
Expand All @@ -15,6 +14,7 @@ def read_file(file_path: str) -> pd.DataFrame:
pd.DataFrame: Dataframe containing the metadata.
"""


file_extension = os.path.splitext(file_path)[1].lower()
if file_extension == '.csv':
return pd.read_csv(file_path, encoding='UTF-8')
Expand Down Expand Up @@ -48,11 +48,11 @@ def process_metadata_file(file_path: str, out_path: str) -> None:
out_path (str): A path where processed metadata dataframe is exported.
"""
columns_to_keep = {
'File name': 'sampleName',
'Type': 'sampleType',
'Class ID': 'class',
'Batch': 'batch',
'Analytical order': 'injectionOrder'
"File name": "sampleName",
"Type": "sampleType",
"Class ID": "class",
"Batch": "batch",
"Analytical order": "injectionOrder",
}

df = read_file(file_path)
Expand Down
1 change: 1 addition & 0 deletions tests/test_process_metadata_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def test_read_save_dataframe_as_tsv_error(dataframe: pd.DataFrame, tmp_path: str
with pytest.raises(ValueError, match = r"Unsupported file format. Please point to a TSV file."):
save_dataframe_as_tsv(dataframe, out_path)

@pytest.mark.skip(reason="Test fails due to a inconsistency in the input file (metadata)")
def test_process_metadata_file(processed_dataframe: pd.DataFrame, tmp_path: str):
file_path = os.path.join("tests", "test_data", "batch_specification1.csv")
out_path = os.path.join(tmp_path, "processed_batch_specification1.tsv")
Expand Down

0 comments on commit 1863439

Please sign in to comment.