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

ci: add formatting for python files #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand All @@ -36,11 +35,14 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade poetry
- name: Install
run: |
python setup.py install
poetry install
- name: Format
run: |
poetry run pre-commit run --all-files
- name: Run tests
run: |
cd tests
python -m unittest tests
poetry run python -m unittest tests
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Configuration file for pre-commit (https://pre-commit.com/)
# Please run `poetry run pre-commit run --all-files` when adding or changing entries.

repos:
- repo: local
hooks:
- id: black
name: black
entry: black
language: system
stages: [commit]
types: [python]

- id: isort
name: isort
entry: isort
language: system
stages: [commit]
types: [python]

# REDACTED AS MULTIPLE CHANGES REQUIRED TO MAKE WORK
# - id: mypy
# name: mypy
# entry: mypy
# args: [--no-incremental]
# language: system
# stages: [commit]
# types: [python]
# require_serial: true

# REDACTED AS MULTIPLE CHANGES REQUIRED TO MAKE WORK
# - id: pylint
# name: pylint
# entry: pylint
# language: system
# stages: [commit]
# types: [python]
# require_serial: true
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ the key is to be assigned to must be `LDS_APIKEY=<lds_apikey>`
### Execute metadata_update.py
Once the config.yaml file has been updated simply run

```metadata_updater``` (if installed via the recommended setup.py method)
```poetry shell```

```metadata_updater```

### Output

Expand Down
14 changes: 4 additions & 10 deletions metadata_updater/INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Installation instructions

## Requirements
* **Linux** - Operating System. In theory works with others OSs but not tested
* **Git** - Source code storage and versioning
* **Python 3** - Programming language. Version > 3.2 required
* **setuptools** - download, build, install, upgrade, and uninstall Python packages
* **Python 3** - Programming language. Version > 3.9 required
* **Poetry** - [Python packaging and dependency](https://python-poetry.org/)


### Get source code
Expand All @@ -20,11 +19,6 @@ change to git dir
Clone lds-metadata-updater project
* `git clone https://github.com/linz/lds-metadata-updater.git`

### Install metadata_updater package

### Setup.py

ensure you are in the lds-metadata-updater project directiry
* `cd ~/git/lds-metadata-updater`

install metadata_updaer and its dependencies see (requirements.txt)[requirements.txt])
* `python3 setup.py install`
`poetry install`
2 changes: 1 addition & 1 deletion metadata_updater/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env python

from .metadata_updater import main
from .metadata_updater import main
19 changes: 9 additions & 10 deletions metadata_updater/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@
import logging
import logging.handlers


def conf_logging(name):
''' logging '''
"""logging"""

# CREATE LOGGER
log_file = 'metadata_updater.log'
log_file_max_size = 1024 * 1024 * 20 # megabytes
log_file = "metadata_updater.log"
log_file_max_size = 1024 * 1024 * 20 # megabytes
log_num_backups = 3
log_format = "%(asctime)s [%(levelname)s]: %(filename)s(%(funcName)s:%(lineno)s) >> %(message)s"
log_date_format = "%m/%d/%Y %I:%M:%S %p"
log_filemode = 'w' # w: overwrite; a: append
log_filemode = "w" # w: overwrite; a: append

# SET UP LOGGER
logging.basicConfig(filename=log_file, format=log_format, filemode=log_filemode ,level=logging.DEBUG)
rotate_file = logging.handlers.RotatingFileHandler(
log_file, maxBytes=log_file_max_size, backupCount=log_num_backups
)
logging.basicConfig(filename=log_file, format=log_format, filemode=log_filemode, level=logging.DEBUG)
rotate_file = logging.handlers.RotatingFileHandler(log_file, maxBytes=log_file_max_size, backupCount=log_num_backups)
logger = logging.getLogger(name)
logger.addHandler(rotate_file)

Expand All @@ -36,5 +35,5 @@ def conf_logging(name):
logFormatter = logging.Formatter(log_format)
consoleHandler.setFormatter(logFormatter)
logger.addHandler(consoleHandler)
return logger

return logger
Loading
Loading