Where do I find the secret sauce that maps environ...
# meltano-plugin-development
j
Where do I find the secret sauce that maps environment variables to configuration parameters? I'm having some issues with
tap-postgres
currently that doesn't seem to find my
TAP_POSTGRES_SQLALCHEMY_URL
variable and barfs a KeyError because it had expected
user
to be defined. Thanks in advance for any assistance!
1
v
they are called settings. https://docs.meltano.com/reference/settings/#plugin-settings Secret sauce I think you're asking for is here, picture shows the easiest way to get to it from the hub https://github.com/meltano/hub/blob/main/_data/meltano/extractors/tap-postgres/meltanolabs.yml Could you share your meltano.yml ?
I'm pretty certain that taps "barfed" error message should give you more details about needed sqlalchemy url or a host,username,port etc but seeing the error message would be helpful
j
Yeah, I got a little further actually. I think my environment-specific configurations might have "occluded" the stuff in the
plugins:
section of the yaml...
I got past the other error by passing an empty
sqlalchemy_url:
in the
meltano.yml
and then overriding it with an environment variable
v
you shouldnt' have to do that, but it works, if you'd share your meltano.yml we can point you better
j
v
Not clear how it's even working with
namespace*:* upstream
j
If I remove line 17 I get this error:
Copy code
$ docker run -it --env-file meltano/.env-prod im-meltano -- invoke tap-postgres
2024-08-09T18:50:03.670163Z [info     ] Environment 'prod' is active
/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/paramiko/pkey.py:100: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "cipher": algorithms.TripleDES,
/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/paramiko/transport.py:259: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0.
  "class": algorithms.TripleDES,
Traceback (most recent call last):
  File "/project/.meltano/extractors/tap-postgres/venv/bin/tap-postgres", line 8, in <module>
    sys.exit(TapPostgres.cli())
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/plugin_base.py", line 80, in invoke
    return super().invoke(ctx)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 500, in invoke
    tap = cls(
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/tap_postgres/tap.py", line 52, in __init__
    super().__init__(*args, **kwargs)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 649, in __init__
    super().__init__(*args, **kwargs)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 109, in __init__
    self.setup_mapper()
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 179, in setup_mapper
    self.mapper.register_raw_streams_from_catalog(self.catalog)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/tap_postgres/tap.py", line 542, in catalog
    for stream in super().catalog.streams:
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 172, in catalog
    self._catalog = self.input_catalog or self._singer_catalog
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 325, in _singer_catalog
    for stream in self.streams.values()
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 134, in streams
    for stream in self.load_streams():
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/singer_sdk/tap_base.py", line 358, in load_streams
    for stream in self.discover_streams():
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/tap_postgres/tap.py", line 600, in discover_streams
    for catalog_entry in self.catalog_dict["streams"]:
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/tap_postgres/tap.py", line 526, in catalog_dict
    result["streams"].extend(self.connector.discover_catalog_entries())
  File "/usr/local/lib/python3.9/functools.py", line 993, in __get__
    val = self.func(instance)
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/tap_postgres/tap.py", line 422, in connector
    url = make_url(self.get_sqlalchemy_url(config=self.config))
  File "/project/.meltano/extractors/tap-postgres/venv/lib/python3.9/site-packages/tap_postgres/tap.py", line 337, in get_sqlalchemy_url
    username=config["user"],
KeyError: 'user'
It's kinda historical, maybe I should just use the default namespace. I wanted to control the name of the target schema.
v
but it's a python namespace, nothing to do with your schema
j
Oh ok.
target-postgres
uses the namespace variable to set the target schema, though.
v
You don't want to have to monkey patch
j
Thanks!
v
The other thing with user
best command is
meltano config tap-postgres list
this will show you where each of those settings come from and where it is set (There's a unsafe flag as well if you want to see the password in your terminal) I think this will answer you question
j
It's weird... That list was just VERY short moments ago
maybe because I overrode the namespace?
v
yes
j
I see
Silly me 🙂
v
the namespace in that "magic" hub portion (which is actually in your lock file now) uses the namespace to store the settings
j
Thank you Derek
v
You can use a different namespace, but you'd have to define the settings yourself in your own meltano.yml file
j
Oh.... Means I should probably re-lock that and commit
v
so you'd copy that thing I sent over
that wouldn't work either
the lock file has the namespace reference
namespace is the "key" that's used to lookup settings
j
yeah? So how would I undo my little namespace gambit here?
I removed it from the yml so far.
v
good, then
meltano install --clean
j
ah yeah, or just docker build
v
we could just do tap-postgres but it doesn't take that long
yeah all depends on your docker file setup etc but yeah, if you notice you're monkey patching definietly stop 😄
😅 1
If you want to mess with taps/targets locally that's good, I just would do it using the same method we do for tap/target development https://github.com/MeltanoLabs/tap-postgres/blob/main/meltano.yml#L8
notice the settings defined there etc
j
myeah
v
we're missing some settings in that file whops
j
I do need to set up a tap dev environment eitherway.. Figured that
tap-typeform
is kinda crusty and not really functional earlier today
😭 1
Found a fork which kinda did, forked that: https://github.com/injurymap/tap-typeform
v
I get the feeling, yeah that's the way I'd do it. Welcome to meltano, glad to have you with us 😄
😂 1
j
So I'm using that for the time being, and planning to do some improvements
dancingpenguin 1
v
seems like you know meltano pretty well though
j
I'm pretending mostly 😛
v
we all just hallucinate right, that's the word they use now for it
j
Who's in charge of promoting/demoting plugins? The current 🥇 here is defunct fwiw: https://hub.meltano.com/extractors/tap-typeform (did file an issue: https://github.com/albert-marrero/tap-typeform/issues/3)
v
can you put an issue in here https://github.com/meltano/hub/issues ?
odd as thre's 2 project running the gold version so they have it working somehow 🤷
j
Yeah, that's strange. However I found it really really easy to reproduce
v
That one is just you can't run with python > 3.9
j
Basically
meltano init
then ``meltano add extractor tap-typeform`
v
easy fix
you got all that though!
I have to get back to it, good luck and thank you!
j
Thanks a lot for your help, I really appreciate it!
np 1