Skip to content

Commit f702f39

Browse files
author
Måns Magnusson
authored
Removes pipfile (#88)
* Removes pipfile * Replace ruamel with pyyaml
1 parent 8238a1c commit f702f39

9 files changed

+38
-524
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ alembic.ini
7272
*.mod.yaml
7373
meta.yaml
7474

75+
# Environement stuff
76+
77+
venv
78+
7579
# Local files
7680
local/
7781

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ Please add a new candidate release at the top after changing the latest one. Fee
1212
### Changed
1313
### Fixed
1414

15+
## [3.2.1]
16+
17+
### Changed
18+
- Replace ruamel.yaml with pyyaml for consistency in prod environment
19+
- Deleted unused Pipfile and Pipfile.lock since they trigger dependabots
20+
21+
1522
## [3.2.0]
1623

1724
### Added

Dockerfile

+4-10
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LABEL about.license="MIT License (MIT)"
1010
LABEL about.tags="files,database"
1111
LABEL maintainer="Måns Magusson <[email protected]>"
1212

13-
RUN pip install -U pip
13+
RUN pip install --no-cache-dir -U pip
1414
# Avoid running as root for security reasons
1515
# More about that: https://pythonspeed.com/articles/root-capabilities-docker-security/
1616
# Solution inspired from
@@ -19,21 +19,15 @@ RUN useradd --create-home worker
1919
USER worker
2020
WORKDIR /home/worker
2121

22-
# Based on https://pythonspeed.com/articles/pipenv-docker/
23-
RUN pip install --user micropipenv pymysql cryptography
24-
# Update the path for micropipenv
25-
ENV PATH="/home/worker/.local/bin:${PATH}"
2622

2723
# Copy the lockfile to temporary directory. This will be deleted
28-
COPY --chown=worker:worker Pipfile.lock /tmp/
29-
# Generate reqs with locked dependencies for deterministic build
30-
RUN cd /tmp && micropipenv requirements > requirements.txt
24+
COPY --chown=worker:worker requirements.txt /tmp/
3125
# Install deps
32-
RUN pip install --user -r /tmp/requirements.txt
26+
RUN pip install --no-cache-dir --user -r /tmp/requirements.txt
3327
# Copy package
3428
COPY --chown=worker:worker . /tmp/housekeeper
3529
# Install package
36-
RUN pip install /tmp/housekeeper
30+
RUN pip install --no-cache-dir /tmp/housekeeper
3731

3832
ENTRYPOINT ["housekeeper"]
3933
CMD ["--help"]

Pipfile

-28
This file was deleted.

Pipfile.lock

-471
This file was deleted.

housekeeper/cli/core.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Module for base CLI"""
22
import logging
3+
from typing import Optional
34

45
import click
56
import coloredlogs
6-
import ruamel.yaml
7+
import yaml
78

89
import housekeeper
910
from housekeeper.store import Store
@@ -20,12 +21,15 @@
2021
@click.option("-l", "--log-level", default="INFO")
2122
@click.version_option(housekeeper.__version__, prog_name=housekeeper.__title__)
2223
@click.pass_context
23-
def base(context, config, database, root, log_level):
24+
def base(context: click.Context, config: click.File, database: Optional[str], root: Optional[str], log_level: str):
2425
"""Housekeeper - Access your files!"""
2526
coloredlogs.install(level=log_level)
26-
context.obj = ruamel.yaml.safe_load(config) if config else {}
27-
db_path = database if database else context.obj.get("database")
28-
root_path = context.obj["root"] = root if root else context.obj.get("root")
27+
config_values = {}
28+
if config:
29+
config_values = yaml.full_load(config)
30+
context.obj = config_values
31+
db_path = database or context.obj.get("database")
32+
root_path = context.obj["root"] = root or context.obj.get("root")
2933
if not db_path:
3034
LOG.error("Please point to a database")
3135
raise click.Abort

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ Alchy
22
Click<7
33
coloredlogs
44
marshmallow
5-
ruamel.yaml
5+
pyyaml
66
SQLAlchemy
77
rich

tests/cli/test_cli_core.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Tests for the core cli"""
2+
import logging
23

34
import housekeeper
45
from housekeeper.cli.core import base
@@ -79,8 +80,9 @@ def test_init_database_no_specified_root_dir(cli_runner, db_uri):
7980
assert "Please specify a root dir" in result.output
8081

8182

82-
def test_init_existing_database(cli_runner, base_context, db_path):
83+
def test_init_existing_database(cli_runner, base_context, db_path, caplog):
8384
"""Test to initialise a housekeeper instance when db already exists"""
85+
caplog.set_level(logging.INFO)
8486
# GIVEN the uri to an initialised database, a project dir and a cli runner
8587
assert db_path.exists()
8688

@@ -90,11 +92,12 @@ def test_init_existing_database(cli_runner, base_context, db_path):
9092
# THEN a controlled exit should be made
9193
assert result.exit_code == 1
9294
# THEN it should communicate that the database exists
93-
assert "Database already exists" in result.output
95+
assert "Database already exists" in caplog.text
9496

9597

96-
def test_override_existing_database(cli_runner, db_path, base_context):
98+
def test_override_existing_database(cli_runner, db_path, base_context, caplog):
9799
"""Test init housekeeper database and overwrite existing one"""
100+
caplog.set_level(logging.INFO)
98101
# GIVEN the uri to an initialised database, a project dir and a cli runner
99102
assert db_path.exists()
100103

@@ -104,16 +107,17 @@ def test_override_existing_database(cli_runner, db_path, base_context):
104107
# THEN it should communicate that the database exists
105108
assert "Delete existing tables?" in result.output
106109
# THEN it should communicate success
107-
assert "Success!" in result.output
110+
assert "Success!" in caplog.text
108111

109112

110-
def test_force_override_existing_database(cli_runner, db_path, base_context):
113+
def test_force_override_existing_database(cli_runner, db_path, base_context, caplog):
111114
"""Test init housekeeper database and overwrite existing one"""
115+
caplog.set_level(logging.INFO)
112116
# GIVEN the uri to an initialised database, a project dir and a cli runner
113117
assert db_path.exists()
114118

115119
# WHEN intitializing and overriding existing db
116-
result = cli_runner.invoke(init_command, ["--force"], obj=base_context)
120+
cli_runner.invoke(init_command, ["--force"], obj=base_context)
117121

118122
# THEN it should communicate success
119-
assert "Success!" in result.output
123+
assert "Success!" in caplog.text

tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from typing import List
99

1010
import pytest
11-
import ruamel.yaml
11+
import yaml
1212

1313
from housekeeper.date import get_date
1414
from housekeeper.store import Store, models
@@ -297,7 +297,7 @@ def fixture_config_file(config_dir: Path, configs: dict) -> Path:
297297
"""Create a config file and return the path to it"""
298298
conf_path = config_dir / "config.json"
299299
with open(conf_path, "w") as out_file:
300-
out_file.write(ruamel.yaml.safe_dump(configs))
300+
yaml.dump(configs, out_file)
301301
return conf_path
302302

303303

0 commit comments

Comments
 (0)