Giter Club home page Giter Club logo

cbank's People

Contributors

anderbubble avatar

Stargazers

 avatar  avatar

Watchers

 avatar

cbank's Issues

error handling for explicit entity id references

Traceback (most recent call last):
  File "/usr/local/lib/cbank/cbank", line 7, in ?
    sys.exit(
  File "<string>", line 2, in main
  File "/usr/local/lib/python2.4/site-packages/cbank/cli/controllers.py", line 76, in handle_exceptions
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/cbank/cli/controllers.py", line 128, in main
    return detail_main()
  File "<string>", line 2, in detail_main
  File "/usr/local/lib/python2.4/site-packages/cbank/cli/controllers.py", line 76, in handle_exceptions
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/cbank/cli/controllers.py", line 810, in detail_main
    return detail_allocations_main()
  File "<string>", line 2, in detail_allocations_main
  File "/usr/local/lib/python2.4/site-packages/cbank/cli/controllers.py", line 76, in handle_exceptions
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.4/site-packages/cbank/cli/controllers.py", line 856, in detail_allocations_main
    print_allocations(allocations)
  File "/usr/local/lib/python2.4/site-packages/cbank/cli/views.py", line 308, in print_allocations
    for allocation in allocations:
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/orm/query.py", line 1689, in __iter__
    return self._execute_and_instances(context)
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/orm/query.py", line 1694, in _execute_and_instances
    mapper=self._mapper_zero_or_none())
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/orm/session.py", line 719, in execute
    return self._connection_for_bind(engine, close_with_result=True).execute(
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 1191, in execute
    params)
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 1271, in _execute_clauseelement
    return self.__execute_context(context)
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 1302, in __execute_context
    context.parameters[0], context=context)
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 1401, in _cursor_execute
    context)
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/engine/base.py", line 1394, in _cursor_execute
    context)
  File "/usr/local/lib/python2.4/site-packages/sqlalchemy/engine/default.py", line 299, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DataError: (DataError) invalid input syntax for integer: "-p"
 'SELECT allocations.comment AS allocations_comment, allocations."end" AS allocations_end, allocations.resource_id AS allocations_resource_id, allocations.datetime AS allocations_datetime, allocations.start AS allocations_start, allocations.amount AS allocations_amount, allocations.project_id AS allocations_project_id, allocations.id AS allocations_id \nFROM allocations \nWHERE allocations.id IN (%(id_1)s, %(id_2)s)' {'id_2': 'c03', 'id_1': '-p'}

negative amount available reflected in allocations list

#    End        Resource Project            Jobs       Charged     Available
---- ---------- -------- --------------- ------- ------------- -------------
65   2010-10-01 shaheena k37                   0      618146.8     -118146.8
75   2010-10-01 shaheena k37                   0        3250.6       96749.4
                                         ------- ------------- -------------
                                               0      621397.5      -21397.5
Units are in core-hours.

command name in cli help output changes with filename

Consider hardcoding the script name in cli help output, so that it doesn't have to reflect the name of the file.

We often use a setgid binary wrapper to hide the contents of the .conf file. In this case, we make cbank -> cbank.py, and cbank becomes the wrapper. That makes the -h output display "cbank.py".

We could write the help code to always display "cbank", or we could adjust the file paths to maintain the original filename (possibly in a subdirectory).

support per-resource unit factors

The model is currently unaware of resource factors: the conversion takes place only at the cli. This breaks summary queries (which have recently been abstracted out of the cli, though they were broken then, too) when summary data describes more than one resource with different resource factors.

I need to define different factors for different resources, and any summary query will need to group by resource (in addition) so that the resource factor can be applied later.

While I'm digging about in the resource factor code, clean up the way they're specified. In stead of a rather dirty "value" multiplier or "value / value" multiplier and divisor, interpret a sequential series of operations prefixing the value. (e.g., "2 / 3" becomes "*2 /3", and "1 / 3" becomes "/3")

# Configuration file example

[resources]
bgp.unit.node-seconds = *1
bgp.unit.core-hours = *4 /60 /60
bgp.unit.rack-days = /60 /60 /24 /1024
cluster.unit.node-seconds = *1
cluster.unit.core-hours = *8 /60 /60

[cli]
resources = bgp # default resources to display
factor = core-hours # default factor to display
Resources that do not have the specified factor defined are not displayed by the cli.

A '-u', '--unit' flag should be added to the cli to specify the units requested.

support easily running testsuite against different databases

I want to be able to easily run the testsuite against other databases (besides the default in-memory sqlite). I've done this against postgres by modifying all of the fixtures, but, at the very least, there should be a single place to make such a change. This might necessitate moving the testsuite inside the cbank package (so that parent bits can be imported).

combine cli.controllers.*_main functions

The hierarchical nature of the cli.*_main functions is unnecessarily complex and artificially inflexible. Combine them into a single main function that picks the correct leaf controller.

unknown locality causes traceback

"/usr/local/lib/python2.4/site-packages/cbank/cli/controllers.py", line 48, in ?
from cbank.cli.views import (print_allocation, print_charge,
File "/usr/local/lib/python2.4/site-packages/cbank/cli/views.py", line 24, in ?
locale.setlocale(locale.LC_ALL, locale.getdefaultlocale()[0])
File "/usr/lib/python2.4/locale.py", line 346, in getdefaultlocale
return _parse_localename(localename)
File "/usr/lib/python2.4/locale.py", line 278, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: en_IN

allow allocation start and end to be null

There is no reason to require start and end, as meaningful data can be extracted without either. Requiring them reduces flexibility and requires somewhat arbitrary defaults.

empty holds list emits SA 0.6 warning

iSitOnDesk:cbank janderson$ cbank list holds -r staff
#      Date       Resource Project                  Held
------ ---------- -------- --------------- -------------
/Users/janderson/Library/Python/2.5/site-packages/SQLAlchemy-0.6.0-py2.5.egg/sqlalchemy/sql/expression.py:1511: SAWarning: The IN-predicate on "holds.id" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate.  Consider alternative strategies for improved performance.
  return self._in_impl(operators.in_op, operators.notin_op, other)
                                           -------------
                                                     0.0
Units are undefined.

audit the testsuite

Do a full audit of the testsuite, breaking the tests into "unit" and "integration" tests, and provide docstring explaining the purpose for each.

move jobs functionality to a separate project

Here's what I don't like about the jobs in cbank:

  • Jobs are the only concrete thing in cbank: everything else is abstracted accounting
  • Jobs only really support posix-style jobs; to be useful they should also support other queueing systems, but don't

What does it look like to not have jobs?

  • import jobs goes away
  • jobs column goes away in some reports:
    • list users
    • project list
    • allocation list
    • hold detail
    • charge detail
    • refund detail
  • job reports go away
    • job list
    • job detail
  • charges looses foreign key to jobs
  • holds looses foreign key to jobs
  • can't relate charges or holds to users (currently happens through job)

The only meaningful side-effect would be the removal of the user<->charge and user<->hold relation. There are two ways to go about this:

  • remove users from the model and rename "project" to "account"

This is the road I've been considering for a while. I like it for the purity of the accounting. Users could continue to exist only at the ui for data access control. This simplifies the model even further. However...

The users report would have to go away, as would the user filter on the other reports. There would no longer be any way to show how charges to an allocation are broken down per-user. This isn't necessarily a bad thing: in a perfect world each user would have an account to which time could be allocated and charges would be against those allocations in stead of a shared allocation. There might even be an automatic transfer system where, say, user_account is sourced from project_account, and when user_account runs out of resources project_account is charged and an additional amount is allocated to user_account.

Additionally, if I take jobs out of cbank, I'd want the functionality to move somewhere (probably queueing-system specific). Since the job id is being stored in the charge comment, a superscript could be written over both systems to tie a user to charges; but that is getting a bit more complicated than I'd like. Maybe.

  • recreate the direct user<->charge and user<->hold relationship

This does have the benefit of making the relationship more direct than through jobs, and is easier to understand; but it feels like a step backward, since that's how it was before.

holds are reflected in project availability regardless of resource

janderson@cn96:~> cbank -p k50 -r shaheenxaccess
Name               Jobs         Charged       Available
--------------- ------- --------------- ---------------
k50                   0             0.0        -49152.0
                ------- --------------- ---------------
                      0             0.0        -49152.0
Units are in core-hours.
janderson@cn96:~> cbank list holds -p k50 -r shaheenxaccess
#      Date       Resource Project                  Held
------ ---------- -------- --------------- -------------
                                           -------------
                                                     0.0
Units are in core-hours.
janderson@cn96:~> cbank list holds -p k50 -r shaheenaccess
#      Date       Resource Project                  Held
------ ---------- -------- --------------- -------------
16806  2010-08-30 shaheena k50                   24576.0
16807  2010-08-30 shaheena k50                   24576.0
                                           -------------
                                                 49152.0
Units are in core-hours.

cbank.upstreams, cbank.interfaces should be namespace packages

To support packagable modularity, cbank.upstreams and cbank.interfaces should be namespace packages. This would allow other upstream modules and other interfaces to be maintained as separate packages, but install into the same overall namespace. (That is, if I understand setuptools namespace packages correctly.)

all accounting actions should log to syslog

Anything that changes the database (creating entities, modifying entities, etc) should be logged to syslog using the Python logging system.

This should likely include the username of the user taking the action.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.