Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -37,7 +37,7 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.x'

Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
name: Python testing

on:
- push
- pull_request
push:
branches:
- '**'

pull_request:
branches:
- '**'

jobs:
test:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2

- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions

python -m pip install tox tox-gh-actions
python -m pip install poetry poetry poetry-plugin-export
- name: Test with tox
run: tox
14 changes: 10 additions & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
# Required
version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
# Do not use shallow clone, as reno will complain
post_checkout:
- git fetch --unshallow

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: doc/source/conf.py
Expand All @@ -13,10 +23,6 @@ sphinx:
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
install:
Expand Down
20 changes: 18 additions & 2 deletions caso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@

"""cASO is an accounting extractor."""

import pbr.version
import importlib.metadata
import pathlib
from contextlib import suppress

__version__ = "4.2.0"


def extract_version() -> str:
"""Return either the version of the package installed."""
with suppress(FileNotFoundError, StopIteration):
root_dir = pathlib.Path(__file__).parent.parent.parent
with open(root_dir / "pyproject.toml", encoding="utf-8") as pyproject_toml:
version = (
next(line for line in pyproject_toml if line.startswith("version"))
.split("=")[1]
.strip("'\"\n ")
)
return f"{version}-dev (at {root_dir})"
return importlib.metadata.version(__package__ or __name__.split(".", maxsplit=1)[0])

__version__ = pbr.version.VersionInfo("caso").release_string()

user_agent = f"caso/{__version__} (OpenStack)"
2 changes: 1 addition & 1 deletion caso/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def parse_args(argv, default_config_files=None):
cfg.CONF(
argv[1:],
project="caso",
version=caso.__version__,
version=caso.extract_version(),
default_config_files=default_config_files,
)
2 changes: 2 additions & 0 deletions caso/extract/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ def voms_map(self):
"Using deprecated 'tenant' mapping, please "
"use 'projects' instead",
DeprecationWarning,
stacklevel=2,
)
if tenants:
warnings.warn(
"Using deprecated 'tenants' mapping, please "
"use 'projects' instead",
DeprecationWarning,
stacklevel=2,
)
tenants.append(tenant)
projects = vomap.get("projects", tenants)
Expand Down
6 changes: 5 additions & 1 deletion caso/extract/openstack/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import operator

import datetime
import dateutil.parser
from oslo_config import cfg
from oslo_log import log
Expand Down Expand Up @@ -52,7 +53,10 @@ def _build_record(self, volume, extract_from, extract_to):
if vol_created < extract_from:
vol_created = extract_from

active_duration = (extract_to - vol_created).total_seconds()
active_duration_delta = extract_to - vol_created
ms = active_duration_delta.microseconds
td = datetime.timedelta(microseconds=ms)
active_duration = (active_duration_delta - td).total_seconds()

r = record.StorageRecord(
uuid=volume.id,
Expand Down
2 changes: 1 addition & 1 deletion caso/extract/openstack/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _build_record(self, server):
disk = flavor["disk"] + flavor["OS-FLV-EXT-DATA:ephemeral"]
else:
bench_name = bench_value = None
memory = cpu_count = disk = None
memory = cpu_count = disk = 0

if not all([bench_name, bench_value]):
if any([bench_name, bench_value]):
Expand Down
2 changes: 1 addition & 1 deletion caso/messenger/ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,5 @@ def __init__(self):
"'ssm' as messenger instead in order to use the latest "
"version."
)
warnings.warn(msg, DeprecationWarning)
warnings.warn(msg, DeprecationWarning, stacklevel=2)
super(SSMMessengerV04, self).__init__()
Loading
Loading