anderbubble / cbank Goto Github PK
View Code? Open in Web Editor NEWResource allocation management
Home Page: http://www.civilfritz.net/wiki/projects/cbank
Resource allocation management
Home Page: http://www.civilfritz.net/wiki/projects/cbank
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'}
# 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.
Now that cbank can handle having no upstream module configured, the default upstream module is only useful as a volatile upstream module for testing.
One day there will be a web interface, probably based on pylons.
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).
Provide a cli command to release a hold and create a charge as part of the same transaction.
The detail view allows multiple entities to be specified. The edit commands should, too.
Primary use case: disabling multiple holds at once.
Combine the various subcommand manpages into one single document, "cbank".
I've been reading the repoze.who documentation, and it provides a really good example of how to document a plugin interface: with simple examples!
Do something similar in the documentation for cbank's upstream interface.
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.
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).
Have a -v, --verbose flag to show the full details as now.
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.
I don't know that cbank should care about user-level data. Just account data.
"/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
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.
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.
Do a full audit of the testsuite, breaking the tests into "unit" and "integration" tests, and provide docstring explaining the purpose for each.
If stdout and stderr are redirected to the same place, it should still produce them, preferably unbuffered.
Here's what I don't like about the jobs in cbank:
What does it look like to not have jobs?
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:
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.
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.
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.
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.)
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.