Hi, I'm having an issue running edr report. I am u...
# community-support
m
Hi, I'm having an issue running edr report. I am unable to get edr to run on my project-dir. I have a .venv folder to hold my python virtual environment. when I set project-dir to my current directory, it will go into the nested .venv folder to find the elementary project. I have validated: •
dbt run -s elementary
successfully built the required tables in my target schema •
dbt test
successfully runs tests and elementary anomaly detection tests •
elementary_test_results
has my test results my dbt_project.yml sets
+schema: elementary
and the above runs go into the correct schema When I run edr report, I find that, because the cli is grabbing the nested elementary project dependency within .venv, all of my config is ignored and I end up with an empty report. Is there any way to explicitly point to the dbt_project.yml path?
elementary 0.16.1 for both cli and dbt package
l
Yes, there is! You might be good with
--project-dir
🙏 1
💯 1
m
yeah, I should have highlighted that better in my original post. but it seems like when I set
project-dir
it searches in a recursive fashion. the INFO block in my
edr report
command tells me it finds:
Copy code
--project-dir <path-to-my-project>/.venv/lib/python3.12/site-packages/elementary/monitor/dbt_project
when, unless I understand incorrectly, it should look like this:
Copy code
--project-dir <path-to-my-project>
j
Mac do you have your dbt_project in your .venv? I'm trying to understand what is happening
m
we use uv as our python dependency and virtual environment manager. uv creates a .venv folder to hold all of the python dependencies for the project. since elementary is a python dependency, its code goes into that directory. It sounds like the elementary dbt repo is also being thrown in their as supporting package code
I think what I'm really looking for is, when I set project-dir, edr looks for the relevant folders at that specific directory level. instead it sounds like elementary tries to smart-find whatever dbt project could be inside that directory. But, there is no way for me with the CLI to tell it to not be smart and take what I give it at face value
j
I understand. So it seems you have your dbt project also stored inside of your .venv directory? You are right that all the python dependencies should be in there, but your dbt project should not be within your .venv folder
m
our project isn't stored in the .venv. But, the elementary package as a dependency is in there when it gets pip installed
our project looks more or less like this:
Copy code
my_project
  models/
  tests/
  etc
  .venv/
    lib/
      python-3.12/
        site_packages/
          elementary/
            monitor/
              dbt_project/
when I run edr, no matter what I specify as project-dir, edr ultimately finds my_project/.venv/lib/python3.12/site-packages/elementary/monitor/dbt_project
but, I'd like when I specify
.
from cwd my_project, that elementary uses
.
not some nested path
where .venv would not be something we version control. but it is created when installing dependencies to run dbt, edr, etc
j
I understand 🙂 So generally I wouldn't put my .venv folder inside my dbt project (
my_project
) in your case. The .venv folder you can install anywhere and you source it to make sure python will use those packages and pythin installation etc. the dbt_project that you are seeing in the elementary package in your tree is not your dbt project but rather the dbt project elementary uses (elementary uses dbt internally to create models too :)) So generally you shouldn't even have to look at what is inseide the
.venv
folder
m
yeah, I realize having a venv in the project is not as status quo for python and I'm pretty familiar with the elementary dbt project vs the elementary client.
uv
is a newer python dependency manager, and it works somewhat more similarly to js dependencies, where your venv/dependencies get created in your project via a pyproject.toml file, which does get version controlled. I'd prefer not to refactor the whole project dependency management just to get elementary edr to point to the right file. the elementary dbt package works with no problems as does our dbt project and CI/CD. I'm really trying to get edr to not look in the .venv folder. Is there no workaround to get elementary to not "smart search" for some sort of dbt directory? If there were an .edr-ignore file I could set or if I could specify the dbt_project.yml file (instead of a directory) elementary should look at that would resolve it. I think really where I'm stuck is that edr doesn't take project-dir at face value. It seems to just search for a dbt project somewhere in the directory I've specified and it happens to be finding the wrong one, instead of just looking at the directory I input
j
I see! Do you think you can find the code that is responsible for this in the open source package? Maybe we can have a look to see if there is a fix possible
m
so, it actually seems like project-dir never gets passed to anything inside the client code, which might be part of the issue. elementary/monitor/data_monitoring/report/data_monitoring_report.py inherits data_monitoring.py, which on line 60 takes is more or less hard-coded path from elementary. I'm not sure if this is required. But, it sounds like the project-dir argument does not impact
edr report
as a result. One other clue around this might be, in our dbt project I've overrided the generate_schema_name macro. If I reset this macro to be the dbt default, I can get the data that I've build / recorded in the dbt package to show up in the elementary report. If I use our custom, modified schema, elementary does not find the correct schema. I'm assuming this is because elementary is running the package from the .venv which has no knowledge of the modified generate_schema_name macro
I'm not sure if that is helpful context, but just what I could find digging into the code a bit
j
Hey Mac! Sorry it's been a bit hectic this week. The community is important for us, but as you understand we have to prioritize our cloud customers. I am hoping to look into this today, is it ok if we reconnect after the weekend?
👍 1
j
Hi, @Mac Fluehr, @Joost Boonzajer Flaes were you able to find a solution? I’m having the same issue, but the only difference is that my venv is outside my dbt project
m
I ended up playing around with the schema name specified in the profiles.yml I was using for elementary and it worked out. I had actually found that even changing over to pip was not resolving my issue and realized there was a config issue. the
--project-dir
flag still doesn't work, but you might not need it
j
Hi, @Mac Fluehr! Thanks for the insights. Actually I ended up realising the same, my issue was regarding the profiles, actually. It wasn’t detecting the profiles because of the project-dir not working, but specifying the
--profiles-dir
actually ended up working