Skip to content

20210512 pip setuptools #8

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

Closed
wants to merge 21 commits into from
Closed
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: 5 additions & 5 deletions python/KAPEL.py → kapel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# This is a python script for container-native publishing of kubernetes job data for APEL accounting.
# It follows container-native practices such as using environment variables for configuration
Expand All @@ -13,7 +13,7 @@
import datetime
from dateutil.rrule import rrule, MONTHLY

from KAPELConfig import KAPELConfig
from kapel import kapelConfig
from prometheus_api_client import PrometheusConnect
from dirq.QueueSimple import QueueSimple
from timeit import default_timer as timer
Expand Down Expand Up @@ -139,7 +139,7 @@ def rearrange(x):
yield item['metric']['exported_pod'], float(item['value'][1])

# process a time period (do prom query, process data, write output)
# takes a KAPELConfig object and one element of output from getTimePeriods
# takes a kapelConfig object and one element of output from getTimePeriods
def processPeriod(config, iYear, iMonth, iInstant, iRange):

print(f'Processing year {iYear}, month {iMonth}, starting at {iInstant} and going back {iRange}.')
Expand Down Expand Up @@ -203,8 +203,8 @@ def processPeriod(config, iYear, iMonth, iInstant, iRange):

def main(envFile):
# TODO: need error handling if env file doesn't exist. See https://github.com/theskumar/python-dotenv/issues/297
print('Starting KAPEL processor: ' + __file__)
cfg = KAPELConfig(envFile)
print('Starting kapel processor: ' + __file__)
cfg = kapel.kapelConfig.kapelConfig(envFile)

periods = getTimePeriods(cfg.publishing_mode, startTime=cfg.query_start, endTime=cfg.query_end)
print('time periods:')
Expand Down
4 changes: 3 additions & 1 deletion python/KAPELConfig.py → kapel/kapelConfig.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python3

# Configuration module for KAPEL

from environs import Env

# Read config settings from environment variables (and a named env file in CWD if specified),
# do input validation, and return a config object. Note, if a '.env' file exists in CWD it will be used by default.
class KAPELConfig:
class kapelConfig:
def __init__(self, envFile=None):
env = Env()
# Read a .env file if one is specified, otherwise only environment variables will be used.
Expand Down
9 changes: 0 additions & 9 deletions python/requirements.txt

This file was deleted.

21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3

from setuptools import setup, find_packages
from os import environ

setup(
name='kapel',
version='0.6',
packages=['kapel'],
# packages=find_packages(),
install_requires=[
'environs', # for handling configuration
'dirq', # for sending messages
'prometheus-api-client' # for querying Prometheus
],
entry_points={
'console_scripts': [
'kapel = kapel:main',
],
},
)