Finally had a target debug scenario where I needed...
# singer-target-development
v
Finally had a target debug scenario where I needed to make it work in vscode instead of hacking together testing vscode launch examples for target
Copy code
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "target-hubspot Python Debug",
            "type": "debugpy",
            "request": "launch",
            "module": "target_hubspot",
            "console": "integratedTerminal",
            "args": [
                "--config",
                "config.json",
                "--input",
                "data.singer",
            ]
        }
    ]
}
I've gotten away for this long with pdb and some remote pdb telnet trickery
🙌 1
Tried to figure out how to pipe data in instead of --input but couldn't get
< data.singer
to work in the args list. --input exists so why not use it!
d
I'm trying to do something similar, and was wondering if the config needs to be in json format. I have an existing meltano.yml file from my actual etl project with the configuration, but I noticed that there's already another meltano.yml in the root of the target that I'm trying to debug. Do I have to convert it into json format? Is there some tool for that? Also, is the input file here just the output file when you run
meltano invoke tap > output.json
, or something different? I did make some changes to the launch.json based on the doc example for taps
Copy code
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "target-snowflake Python Debug",
            "type": "debugpy",
            "request": "launch",
            "program": "${workspaceRoot}/target_snowflake/target.py",
            "console": "integratedTerminal",
            "args": [
                "--config",
                "config.json",
                "--input",
                "output.json",
            ],
            "env": { "PYTHONPATH": "${workspaceRoot}"},
            "justMyCode": true
        }
    ]
}
v
@Daniel Luo sounds like 2-3 things you're talking about. What 1 problem do you want me to think about here?
d
It's just one thing. I currently have a meltano.yml from my ELT project. Do I have to convert it to json to use it with --config, or set it up using .env, or can it just be used directly?
Oh, sorry, I guess it was two, but that's the first one
v
Got it, yeah I currently convert it
meltano invoke --dump=config tap-name > config.json
would be nice to have that baked in too 😄
d
Got it, glad there's a command to make it easy, and then the other was your input file. Is that just the output of
meltano invoke tap > output.json
Except you named it data.singer?
v
yes 😄
d
Thanks, will give it another try!
💯 1
v
Good luck!
d
Wish you could pin this here somehow, very useful for getting started. The documentation online is lacking a bit in details if you're not already very familiar with meltano, I think
v
hmm maybe we should add it to the SDK page for debugging https://sdk.meltano.com/en/v0.39.1/dev_guide.html#vscode-debugging
d
There seems to be multiple places where it's maintained. I didn't even know there was something there. I had found this page from Google https://docs.meltano.com/guide/debugging-custom-extractor/
I just adapted it to the target
v
😄
d
Would you be able to share how you set up your entry point? If I use it with module as your code does, it says
No module named target_snowflake.__main__; 'target_snowflake' is a package and cannot be directly executed
and if I use
"program": "${workspaceRoot}/target_snowflake/target.py",
, then it throws this
Copy code
TargetSnowflake.cli()
AttributeError: 'NoneType' object has no attribute 'name'
What do you have in your
__main__.py
? target_snowflake doesn't come with one
v
https://github.com/meltano/sdk/blob/main/cookiecutter/target-template/%7B%7Bcookie[…]rget_id%7D%7D/%7B%7Bcookiecutter.library_name%7D%7D/__main__.py It's the same as the cookier cutter. I think you can still specify it without a code change but this is probably the easiest
d
That worked, thanks!
dancingpenguin 1