-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Support declaring variant for use in package name #1241
feat: Support declaring variant for use in package name #1241
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1241 +/- ##
=======================================
Coverage 85.19% 85.19%
=======================================
Files 54 54
Lines 4722 4722
Branches 803 803
=======================================
Hits 4023 4023
Misses 507 507
Partials 192 192 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
pre-commit.ci autofix |
@edgarrmondragon @aaronsteers FYI this resolves an issue I found where |
for more information, see https://pre-commit.ci
@kgpayne Can you use |
Co-authored-by: Edgar R. M. <edgar@meltano.com>
Here is the pyproject.toml I am working on. The project name is |
@kgpayne That makes a lot of sense, thanks for the detailed explanation! Yeah, the package name is only really necessary for extracting the package version at the moment. |
@kgpayne can you update the cookiecutter templates to
|
@edgarrmondragon what do you think about adding a |
@kgpayne I think that would require also adding the variant name attribute to the plugin class, which is probably beyond the scope of this PR. That's definitely useful and worth its own issue, though. I'm not proposing a completely free-form sdk/cookiecutter/tap-template/cookiecutter.json Lines 4 to 5 in 18aca68
Wdyt? |
…e' of github.com:meltano/sdk into kgpayne/version-when-package-name-differs-from-exec-name
@edgarrmondragon as I was working on the class TapExample(Tap):
name = "tap-example"
variant = "meltanolabs"
# Rather than:
# package_name = "meltanolabs-tap-example" This PR is accompanied by a docs PR in meltano#7050 |
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.
All of this basically makes sense. The last thing I want to confirm before we merge is the comment in #1241 (comment):
Does python provide any facility to auto-detect the library name? For instance, can we do something like import sys; module_name = vars(sys.modules[__name__])['__package__']
, except using the class name reference and not our own SDK code as the __name__
ref?
Possible lead here.
Maybe this way, if we assume (and it seems like a safe bet) that the tap is being invoked as an app and not as a library?
import sys
sys.modules['__main__']
I feel like there should be some way to auto-detect the library name - although it's also feasible that it just isn't possible to do so. (And if not, for my part, I think this PR is basically ready to go.)
I just noticed the above in the thread. @kgpayne - In the context of #1241, I really don't know if we should add any new references to Also, if I read this correctly, the above infers that the folder name will have the variant as a prefix, which I think we would not want to implement as default. 🥷 Edit: Regarding the case with None of this changes the importance of this issue though, since we either way want to properly support taps and targets even if library name is not what we expect. |
@aaronsteers @edgarrmondragon we are completely aligned on folder and invocation names - as above the [tool.poetry]
{%- if cookiecutter.variant != "None (Skip)" %}
name = "{{cookiecutter.variant}}-{{cookiecutter.target_id}}"
{%- else %}
name = "{{cookiecutter.target_id}}"
{%- endif %}
version = "0.0.1"
description = "`{{cookiecutter.target_id}}` is a Singer target for {{cookiecutter.destination_name}}, built with the Meltano Singer SDK."
readme = "README.md"
authors = ["{{ cookiecutter.admin_name }}"]
keywords = [
"ELT",
"{{cookiecutter.destination_name}}",
]
license = "Apache 2.0"
{%- if cookiecutter.variant != "None (Skip)" %}
packages = [
{ include = "{{cookiecutter.library_name}}" },
]
{%- endif %}
|
…e' of github.com:meltano/sdk into kgpayne/version-when-package-name-differs-from-exec-name
Another update re: @aaronsteers question on avoiding hard-coding the variant or package name:
I was able to figure something out 🎉 Have removed the version-related changes in this PR to here, so as to separate any ongoing variant packaging discussions from the bug fix that prompted them. Initially I found |
Awesome, great news, @kgpayne ! |
@edgarrmondragon no, this is standalone. It basically just adds the |
This resolves a case where the package name differs from the executable name (e.g.
meltanolabs-tap-snowflake
with executabletap-snowflake
)📚 Documentation preview 📚: https://meltano-sdk--1241.org.readthedocs.build/en/1241/