-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Write run results to disk (#829) #904
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super happy with the structure here.
there is one comment here that i think is a bug in dbt/compat.py. the rest is non blocking
def default(self, obj): | ||
if isinstance(obj, Decimal): | ||
return float(obj) | ||
return super(JSONEncoder, self).default(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like the way Python handles JSON encoding. This looks like a good start in handling this better in dbt.
fail = named_property('fail', 'True if this was a test and it failed') | ||
status = named_property('status', 'The status of the model execution') | ||
execution_time = named_property('execution_time', | ||
'The time in seconds to execute the model') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love this
dbt/compat.py
Outdated
|
||
def write_json(path, data, **kwargs): | ||
with _open(path, 'w') as fp: | ||
json.dump(data, fp, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't love this as part of the public API of dbt.compat, but i see the need for it. is there an advantage to doing it this way, vs calling write_file
with json.dumps(...)
from dbt.clients.system?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance is different. json.dump()
uses less memory because it streams, but can take longer to run because each 'chunk' of json becomes a file.write()
call and it bypasses the "one shot" encoder in C. I don't know which is faster in any given situation, I'll just change it to use json.dumps()
and hope we never run out of memory, we'll probably gain a lot from using the good encoder anyway.
@@ -4,6 +4,14 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is going to have some rough conflicts w #883
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The merge conflicts will look horrible for sure, but looking at that PR they'll be pretty easy to resolve manually if I rebase on top of that after merge - I really only have to add a couple fields here and there.
dbt/compat.py
Outdated
else: | ||
with open(path, 'w') as f: | ||
return f.write(to_string(s)) | ||
return open(path, 'w') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you want return open(path, mode)
2a8929c
to
d05173d
Compare
d05173d
to
5ccaf5b
Compare
Per discussion, we'll be writing the run results to a separate file from the manifest itself. The run results include the compiled node, so the compiled sql is in there.
The actual code changes are small, the tests are just very verbose.