Conversation
it was possible to do things like
but now it fails with your changes |
jardin/model.py
Outdated
|
||
@classmethod | ||
def query_from(self, sql=None, filename=None, **kwargs): | ||
kwargs['stack'] = self.stack_mark(inspect.stack()) | ||
if filename: | ||
filename = os.path.join(os.path.dirname(inspect.stack()[1][1]), filename) | ||
return self.db().dataframe(sql=sql, filename=filename, **kwargs) | ||
filename = os.path.join(os.environ['PWD'], filename) |
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 fails for me
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.
why do you think we need os.environ['PWD']
instead of the dir path of the file that calls the method
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.
Modules get imported from the directory python is running in, even if the code importing the module is deeper in the tree. The pattern I'm seeing in airflow is also to define paths (config files, resources...) with respect to the directory where python runs. I think it makes sense to follow that pattern.
This way modules can move around independently without the whole downstream tree having to follow.
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.
ok that works!
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.
hmm, but it could lead to issues, if we have some shared code from different services?
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 thought that would have been safer to define the path to sql file relative from where it is called, but i'll see when i use it in batching
@mathieuripert Yes, the correct syntax according to the rest of the API is
|
:( |
i dont think it is intuitive to have the |
at least |
It is the same argument as when doing a
because there are no |
Yes we could name it |
vendu pour |
see #5