<@U06CBR1KH0B> - First of all, congrats on your <M...
# contributing
a
@jacob_matson - First of all, congrats on your MDS-in-a-box project and the associated blog post. 🎉 I wanted to reach out on regarding your invitation to work together on a Docker example. We would be excited to work with you on this. Not just dockerization though, I think this could make a compelling devcontainer experience as well! Starting this thread 🧵 to discuss.
cc @Sven Balnojan
j
yes!
d
💯
Also happy to help! I'm only working from devcontainers these days 😅
All of this and twitter conversations inspired me to cleanup/simplify my old duckdb+rill dev in Devcontainer experiment: https://github.com/davidgasquez/datadex
j
I think I can cut a version of this next week, the template is all in David's repo.
I'm chatting with the Rill folks next week too, will prob take out superset and replace with Rill since I think I can predefine charts there in yml? And lean on them to make meltano config files for it
a
Exciting! I personally don't have any experience with Rill and I'm interested to learn more about their solution.
j
same, superset was "fine"
a
j
Thanks AJ, chatting with them in a bit to see where this takes us. Btw have a dumb question specific to tap-spreadsheet-anywhere and grabbing data from the web (no timestamp is persisted, so data is duplicated) - where is the best place to post it?
a
Depending on the nature of the question, perhaps #C013EKWA2Q1 maybe/or #C01PKLU5D1R and/or a new issue in the tap's repo?
j
I think its more of a general question, because its really about "how do I do an upsert for a given key" instead of a full load.
anyway, i'll start there, thanks!
ok checking back in on this thread, I think I have scoped what I am hopping to accomplish over the next few weeks but I want to validate it here. • dev container + docker image (basically done) • use cloud storage w/min.io free tier (instead of local) for output files • have an option to use parquet as target (no database) (done) • scale out to N + 1 nodes on AWS and write back results to one cloud storage location • replace superset with... ◦ Rill Developer (might work, but requires a timestamp for their analytics to work, which this data doesn't really have) ◦ Evidence.dev (need some updates to DuckDB node APIs but Motherduck just submitted a PR so might be soon??)
For the last point, the idea is that "BI as code" works - superset does not support (that feature is part of preset)
a
Sounds like a great plan 👍
j
This BI part will be the hold up I think. Both have bits to clear before I can ship v2.
@edgar_ramirez_mondragon devcontainer working on my dev branch now, thanks for lighting the path up in your fork.
a
@Sven Balnojan -Just now got to watch your demo! Looks fantastic. A couple things... 1. I'd love to see if we could get a VSCode-based database browser in here. Two options that come to mind are (1) the excellent SQLTools extension and (2) @alexander_butler's fork of DBT Power User, which includes some of his unique DBT-Osmosis features. 2. Not sure of the best place/manner to share this with the community but I'd love to get a reference dev container out based on your learnings here. Cc @edgar_ramirez_mondragon, @Sven Balnojan 3. We should host you as a guest of honor sometime soon in our weekly #C01QS0RV78D. I know folks would be interested in seeing the demo of this and discussing with you.
No rush on these, because your efforts to get BI baked in are certainly higher impact overall. But just wanted to put these out there. And again, nice work!
j
for the db browser....hear me out on this - is there a way to pass the dbt-osmosis query to the duckdb cli in the terminal? the duckdb cli is excellent
i'm good with #2 (recommend to get with @david_gasquez on this - he did the Datadex container which is excellent) and I think I'm on the books for a demo on the 26th during office hours (cc @taylor )
a
and I think I'm on the books for a demo on the 26th during office hours...
Fantastic! And also, I probably should have known this already... 😅 🤦‍♂️
for the db browser....hear me out on this - is there a way to pass the dbt-osmosis query to the duckdb cli in the terminal? the duckdb cli is excellent...
Possible, surely. 🙂 May be tricky, though, as I do believe the dbt-osmosis is intending to use dbt itself as the abstraction/interface layer so it doesn't need to understand/support
n
number of DBs/APIs. But to the crux of your question, yeah, I think duckdb CLI can keep a center-stage position. I personally have a horrible memory for CLI commands in general, so I always appreciate Meltano
commands
and VSCode
tasks
to guide me into that CLI command name I can almost remember but just not quite... 😅
j
dbt osmosis is fine. I think I have to add it to the container for dbt power user to work right anyway
i need the cliff notes on meltano commands
i'm using
make
and it feels wrong
a
https://docs.meltano.com/reference/plugin-definition-syntax#commands Anything declared in this way is accessible via
meltano run ... <some stuff here> ... my-tool:my-command <more-commands-here>
and also
meltano invoke my-tool:my-command <extra-args-if-you-need-them>
It's not clear there but you can also override the executable if the plugin's default executable is different from what the command should use.
j
Getting warmer with dbt-osmosis / dbt-power-user. When I try to run queries, I'm getting the following issue:
Copy code
{
  "message": "Runtime Error\n  The profile 'meltano' does not have a target named '{{ env_var('MELTANO_ENVIRONMENT', 'dev') }}'. The valid target names for this profile are:\n   - dev\n   - staging\n   - prod\n   - parquet",
  "data": "Traceback (most recent call last):\n  File \"<string>\", line 22, in <module>\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt_osmosis/core/osmosis.py\", line 244, in _init_\n    self.parse_project(init=True)\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt_osmosis/core/osmosis.py\", line 291, in parse_project\n    self.config = RuntimeConfig.from_args(self.args)\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/runtime.py\", line 228, in from_args\n    project, profile = cls.collect_parts(args)\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/runtime.py\", line 204, in collect_parts\n    profile = cls._get_rendered_profile(args, profile_renderer, profile_name)\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/runtime.py\", line 189, in _get_rendered_profile\n    return Profile.render_from_args(args, profile_renderer, profile_name)\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/profile.py\", line 426, in render_from_args\n    return cls.from_raw_profiles(\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/profile.py\", line 392, in from_raw_profiles\n    return cls.from_raw_profile_info(\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/profile.py\", line 336, in from_raw_profile_info\n    target_name, profile_data = cls.render_profile(\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/profile.py\", line 296, in render_profile\n    raw_profile_data = cls._get_profile_data(raw_profile, profile_name, target_name)\n  File \"/home/vscode/.local/lib/python3.9/site-packages/dbt/config/profile.py\", line 221, in _get_profile_data\n    raise DbtProfileError(msg, result_type=\"invalid_target\")\ndbt.exceptions.DbtProfileError: Runtime Error\n  The profile 'meltano' does not have a target named '{{ env_var('MELTANO_ENVIRONMENT', 'dev') }}'. The valid target names for this profile are:\n   - dev\n   - staging\n   - prod\n   - parquet\n"
}
It looks like dbt-osmosis is not attempting to get the profile name from the env vars.
a
So it’s not that simple. The code written by Michiel which is actually deviated from how I originally authored the integration is pulling the profile string from raw profile yml via typescript code which is obviously not rendered and then passing that into subprocess calls.
j
yeah makes sense.
want me to open an issue? Not sure which repo - dbt power user or dbt osmosis
a
I think I might take a swing at a dev container template that shows an example of how you could integrate it with the forks of the extension that work the way I designed it (datacoves fork and mine). It’s been a slow drag to get parity on the main repo as we are trying to align on some design decisions around sub processes vs server. You could then use that as a reference caveated by whether a dev container can specify an extension from a VSIX to use. Need to confirm :) or make a bash script at worst that automated it. The issue would be on power user side but I think an issue is already open for it.
I'll need to publish our fork as its own on the marketplace as probably the easiest solution TBH, and deprecate it if and only if we reach parity on the main fork But yeah dev containers specify extensions I see
j
Sounds good to me, thanks for the help. I'll eagerly await the (published) fork.
a
It's published. I think ideally we work this stuff back into the original and as a maintainer on the original codebase, I am working with the creator to hash out details but its a slow burn. So in the meantime, I have published my fork which enables faster iteration and more fun stuff on my end that I can work with before it circles round to the main repo ( / if it does) 🙂 Before that ideal state of main repo parity, I would 100% advocate this version to anyone I talk to. Its super fast and easy. You can search for this in vscode extension panel or use this in your dev container extension specifications
z3z1ma.vscode-dbt-power-user-osmosis
dbt-osmosis should be version
0.9.7
https://marketplace.visualstudio.com/items?itemName=z3z1ma.vscode-dbt-power-user-osmosis vscode:extension/z3z1ma.vscode-dbt-power-user-osmosis
j
Awesome, I dropped it into my devcontainer, but queries are not resolving (no error, but don't ever return results). Not sure how to turn on logging etc so I can give better feedback.
a
Interesting. They definitely have a timeout and error handling. Can you
curl <http://localhost:8581/health>
? Also I can clone this (the nba repo) and verify locally right?
j
yes you can clone it a verify locally!
I opened the port and I get the following response on curl:
a
Ok cool. I’ll give it a shot too. Basically as long as dbt-osmosis is installed and available on startup, the extension should spin up a server. If it was not installed or available on start up (based on python extension venv) then the server won’t kick on at the extension will use sub processes instead. Dev containers are sweet!
j
thanks 🙏 I'm sure its some config somewhere but its a bit tough to suss out sometimes.
dropping a note here - would be a cool demo bit of functionality to add to this project https://meltano.slack.com/archives/CMN8HELB0/p1666635551561649
@alexander_butler I'm picking up on getting your fork of dbt power user working for "query results" inside of a dev container. Here is where I am at: I've configured my profile dir override to
/workspaces/my_project/transform/profiles/duckdb/
When I try run a query with ctrl+enter, query window opens and starts spinning. Health check of the server fails. So next I started the server with the following params:
dbt-osmosis server serve --project-dir /workspaces/my_project/transform --profiles_dir /workspaces/my_project/transform/profiles/duckdb --host 127.0.0.1 --port 8581
and the server starts! The health check passes as well. Then when I go back to my model, and run the sql query, i get
Project is not registered. Make a POST request to the /register endpoint first to register a runner
So it looks like when running inside a devcontainer + meltano, it can't find the right parameters to get the runner setup etc.
a
@jacob_matson sounds like there is a registration (aka project parse issue). Try adding this flag to the invocation which will exit early if project parse fails
--exit-on-error
or it might be more elucidating to run this while the server is up
dbt-osmosis server register-project --project-dir /workspaces/my_project/transform --profiles_dir /workspaces/my_project/transform/profiles/duckdb
It should look like this screenshot on server init (notice the INFO log message pointing out project registration success)
meltano default dbt setup uses the env vars provided by meltano (which incidentally makes invoking dbt through meltano a necessity if you follow the paradigm) so I imagine the server starts up just fine -- but it very likely doesnt read the profiles yaml correctly, hence the --exit-on-error flag addition, the only reason it isnt on by default (the exit on error behavior) is because we have many chances to register a project and its nice to start a server resiliently and defer "correct" registration until user resolves the env vars or profiles or project, whilst daemon processes or filesystem watcher triggers just keep reattempting until successful.
I *think I can get it working and share back the reference json config, just need to do it on my linux box since my mac doesnt have docker desktop (I use nerdctl which isnt quite there for the dev container thing) 🙂
j
Totally get it.
so registering the project returns this:
Copy code
dbt-osmosis server register-project --project-name nbamontecarlo --project-dir /workspaces/nba-monte-carlo/transform --profiles-dir /workspaces/nba-monte-carlo/transform/profiles/duckdb
INFO     🌊 Executing dbt-osmosis                                                                             main.py:386
                                                                                                                         
--- Logging error ---
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.9/site-packages/dbt_osmosis/main.py", line 252, in _health_check
    resp = requests.get(address)
  File "/home/vscode/.local/lib/python3.9/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/home/vscode/.local/lib/python3.9/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/vscode/.local/lib/python3.9/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/vscode/.local/lib/python3.9/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/home/vscode/.local/lib/python3.9/site-packages/requests/adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8581): Max retries exceeded with url: /health (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f33f0892040>: Failed to establish a new connection: [Errno 111] Connection refused'))
a
split terminal and ensure server is running in one terminal, then run the command in the other -- thanks for being a rockstar with all this
j
roger doing that now
message has been deleted
a
So the solution is (probably), start the server the exact same way but put
meltano invoke
in front of it 🔥
meltano invoke dbt-osmosis server serve ...
j
oh
ah in that case i need to use the meltano util
it invokes, but can't find the env_var (same error), but i'm rebuilding the container real quick now that i have dbt osmosis in here as a meltano util
yep after rebuilding container same issue as before:
Copy code
{'error': {'code': 3, 'message': "Parsing Error\n  Env var required but not provided:                main.py:403
         'DBT_DUCKDB_PATH'", 'data': {'stack': [], 'node': None, 'msg': "Env var required but not provided:              
         'DBT_DUCKDB_PATH'"}}}
a
I got my docker setup so I can help now 🙂 https://hub.meltano.com/utilities/dbt-osmosis This actually outlines theres an extra 2 steps
I can do it for you and PR it though I think in any case in the add your dbt adapter to the
pip_url
of the dbt-osmosis yaml then override the namespace to
namespace: dbt_duckdb
lastly copy over your config
j
so i missed the namespace step
ok lets see if a query runs
yes!
cc @aaronsteers
a
sweet, it should be fast AF
j
it is crazy fast
a
so break it in
j
dude this rules
a
you can probably add the server invocation here to the dev container (as a
&
backgrounded task) alternatively technically dbt power user (my version you are using) will start the server automatically but there is just a tiny bit more config required that I plan on simplifying for meltano users
also try out realtime compilation, thats cool too
j
for real time invocation, how does that work
wait sorry
so first the server invocation, i should add the server start + the project registration, yes?
a
Cmd+'
on Mac or
Control+'
on windows/linux with a model open. It compiles jinja ~as you type
there is a button on the top right too that opens the realtime compile view
this command will register the project too actually
dbt-osmosis server serve --project-dir /workspaces/my_project/transform --profiles_dir /workspaces/my_project/transform/profiles/duckdb --host 127.0.0.1 --port 8581
just remember to add
meltano invoke
in front of it, add optionally the
--exit-on-error
if you want the server to kill itself if registration fails
so just 1 command is sufficient
and like I said I will make it transparent and invisible for meltano users soon ideally
lastly, feature-wise, highlight a snippet of SQL (for example in a CTE) and it will run just that snippet furthermore you can override the limit similar to dbt cloud if your query or highlighted snippet ends with
limit ...
j
ok so one issue that is duckdb specific
message has been deleted
this is probably worth an issue on the repo tbh
a
is it transient at least? meaning that everything extension wise still works but you intermittently get the above
j
anything that is dbt build/run/compile etc will cause the issue
looks like server serve is not registering the project, so have to do it as two steps
a
If you add this to the extension setting (which you can add to devcontainer.json
And this command to dbt-osmosis section yaml
The server should start itself via the extension FWIW
j
hmmm
i think because duckdb only allows one connection, this is more complex in this scenario, if the server is running i cannot run dbt run
so i'm going to put an issue in later and we can figure out how to proceed
a
Can confirm server management via extension works (see message in bottom right, server was started by extension automatically)
so i'm going to put an issue in later and we can figure out how to proceed
acknowledged ack
j
alright thank you SO MUCH for stepping me through this
i'm out for now, awesome stuff
a
Adding these two to your devcontainer should make the whole shebang work automagically
No problem! Cool project @jacob_matson