Comments (2)
valya: This can be easily accomplished by using HTTP headers. Here is discussion with Simon.
Hi,
I think taking the HTTP header is the best general solution. I guess you could co-routine something to over ride that if you find a DAS header...
This does bring up the question - do we still need the DAS header? What do you use it for these days? There are services which don't have it, so is it really needed?
Cheers
Simon
On 4 Oct 2010, at 20:37, Kuznetsov Valentin wrote:
Hi Simon,
while working with DAS header I fall into one problem. The code I have reads data from data-service in a lazy way. I do use generators. So I open URL and parse it as I go through. This proven to be very efficient (in memory consumption way) for parsing large XML outputs. I apply the same for JSON. So, when I address the issue with reading expire part from DAS compliant data-service I fall into the problem. Due to generator nature I can't read the header, until the time I start looping over the data. This step is only happens by final routine which inject data into mongo. At this point I already strip off everything (including DAS header info, since it is not part of records themselves). Imaging
rec = {'response_expires': 123, 'results': [{record1}, {record2}] }
So, the expire timestamp (response_expires) is not part of the records structure. In a code I look at record content, so I ask for rec['results'] in order to do the processing and yield the records.
But at the same time I want to read the DAS header since it contains expire timestamp. One easy way to deal with that would be to read 'Expires' from HTTP header, rather the data itself. I had a look at WebTools/Page.py code and do see that we "suppose" to set Expires in HTTP header. Do you think of any problems if I'll read Expires from HTTP header instead of DAS record?
Basically I will do this
{{{
data = urllib2.urlopen(req) # ask for data from data-service
info = data.info() # it contains HTTP header info and therefore Expires
...
code which deal with data, where data is file-like object I read, for instance
res = json.load(data)
yield res
process res
for row in res:
# process row
insert rows into DB
...
}}}
I looked at Tie0data-service, and able to read Expires in this way, but I found that Expires in HTTP header is not the same as Expires in das header of the returned records. May be it is a bug. But according to WebTools/Page.py
{{{
def exposedasjson (func):
def wrapper (self, data, expires, contentType = "application/json"):
data = runDas(self, func, data, expires)
try:
jsondata = JsonWrapper.dumps(data)
_setCherryPyHeaders(jsondata, contentType, expires)
return jsondata
except:
raise
.....
def runDas(self, func, data, expires):
"""
Run a query and produce a dictionary for DAS formatting
"""
start_time = time.time()
results = func(self, data)
call_time = time.time() - start_time
res_expire = make_timestamp(expires)
...
dasdata = {'application':'%s.%s' % (self.config.application, func.name),
'request_timestamp': start_time,
'request_url': request.base + request.path_info + '?' +
request.query_string,
'request_method' : request.method,
'request_params' : request.params,
'response_version': res_version,
'response_expires': res_expire,
'response_checksum': res_checksum,
'request_call': func.name,
'call_time': call_time,
'results': results,
}
return dasdata
}}}
Please let me know what do you think.
V.
from das.
valya: (In 29f1b00) Work on code based on Code Audit, fixes #290, #493, #494, #446, #449, #447
Signed-off-by: Valentin Kuznetsov [email protected]
from das.
Related Issues (20)
- pagination links do not remember DBS instance in DAS2GO HOT 3
- Handling of large run range queries HOT 4
- Duplicate entries in JSON output HOT 2
- Perform final migration of DAS python server to DAS go server HOT 3
- Display of Fraction of Datasets with invalid Files HOT 20
- Given a block name and a run number, query for file names HOT 2
- status filter not working HOT 3
- 'plain' option sometimes misbehaves HOT 3
- DAS not found but by "crab status" it exists HOT 2
- Config files not available from the Configs link in web queries HOT 7
- Error="invalid character 'p' after array element" HOT 14
- "DAS query guide" link points to nowhere HOT 1
- finding the file that contains a run,lumi is not working HOT 6
- error=invalid character '<' looking for beginning of value" HOT 2
- for results format = list, total number of entries is not correct HOT 1
- panic: runtime error from dasgoclient HOT 2
- Turn on Rucio requests from DAS by default HOT 1
- Explore data consistency checking between Rucio and PhEDEx HOT 3
- Remove Rucio-Account header from command line version of DAS HOT 2
- Remove PhEDEx from default list of services to query HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from das.