I’m getting a poetry error that I haven’t seen for...
# singer-tap-development
s
I’m getting a poetry error that I haven’t seen for a long time. I’ve only done a handful of projects with poetry and normally I’m starting from scratch. Wondering if I missed something that resulted in this error. Any help is appreciated.
Copy code
~/projects/my-tap via 🐍 3.7.5 
➜ poetry run my-tap --config ~/singer.io/my-tap/config.json

  ModuleOrPackageNotFound

  No file/folder found for package my-tap

  at ~/.poetry/lib/poetry/_vendor/py3.7/poetry/core/masonry/utils/module.py:59 in __init__
       55│                         }
       56│                     ]
       57│                 else:
       58│                     raise ModuleOrPackageNotFound(
    →  59│                         "No file/folder found for package {}".format(name)
       60│                     )
       61│ 
       62│         for package in packages:
       63│             formats = package.get("format")
v
Can you run
tree
in your my-tap directory. It sounds like you don't have a file/folder called my-tap in that directory anywhere. I'm new to Poetry but it sounds like it's expecting that somewhere
s
I just found the problem. I had
~/projects/my-tap/my-tap/tap.py
and python did not like the hyphen in a folder that would act as a module (or something like that). I changed to
~/projects/my-tap/my_tap/tap.py
@aaronsteers I wonder if the cookiecutter can/should replace the hyphen with an underscore for the subfolder when the project is being created? I think Poetry’s default if you give
my-tap
would be to create a project folder as
my-tap
with a subfolder of
my_tap
. The cookiecutter didn’t do that.
Copy code
~/projects via 🐍 3.7.5 
➜ poetry new my-tap                                              
Created package my_tap in my-tap

~/projects via 🐍 3.7.5 
➜ ls my-tap                  
README.rst     my_tap         pyproject.toml tests
@visch Thanks!
v
Awesome glad to hear!
I believe the cookie cutter template does recommend creating the folder with an underscore (maybe someone changed that?) but when I made mine a few weeks ago it was an _
a
Yes, @visch. The cookie cutter should take a "tap name" with dashes and from that name it would recommend a "library name" which is defaulted to the same, but with dashes replaced with underscores. @stephen_lloyd, let me know if you're seeing something different. Could be a bug if so.
s
I’m guessing you guys know what libraries actually are and that’s why it seems silly to name one with a dash. I sort of know what they are, but not the implication of a folder (which it turns out is a library) having a dash.
Copy code
~/projects via 🐍 3.7.5 
➜ cookiecutter <https://gitlab.com/meltano/singer-sdk> --directory="cookiecutter/tap-template"
You've downloaded /Users/stephenlloyd/.cookiecutters/singer-sdk before. Is it okay to delete and re-download it? [yes]: yes
source_name [MySourceName]: testtap
tap_id [tap-testtap]: 
library_name [tap_testtap]: tap-testtap 
Select stream_type:
1 - Database
2 - REST
3 - GraphQL
4 - Other
Choose from 1, 2, 3, 4 [1]: 2
Select auth_method:
1 - Simple
2 - OAuth2
3 - JWT
4 - Custom or N/A
Choose from 1, 2, 3, 4 [1]: 1

~/projects via 🐍 3.7.5 
➜ cd tap-testtap  

~/projects/tap-testtap via 🐍 3.7.5 
➜ ls
README.md      pyproject.toml tap-testtap
Poetry saves me from that mistake, but the cookiecutter does not. I wonder if the cookiecutter could recommend a name and replace any problematic characters if the user does not take the suggestion. I.e., folks like me thinking it would be better to be consistent with a dash all the way through.
a
@stephen_lloyd - These are good points. I’ve been looking into more advanced cookiecutter scenarios like what you describe but there’s not a lot of documentation in this area on their site. There are actually three versions of the name which we need for the template creation. Each does have very stringent naming restrictions and we could do a better job documenting these and/or giving a hard failure if names don’t fit expected formatting. (1) “source name” (e.g.
MySourceName
) - used in class definitions so it cannot have spaces or special characters. (2) “tap id” (e.g.
tap-my-tap
), which is also the CLI executable and is expected to start with
tap-
and be punctuated by dashes. (3) “library name” (e.g.
tap_my_tap
) which is used as folder name and library name, and (as you’ve found) python won’t allow any special characters here besides underscores. While we do default this to the same as “tap id” except all dashes replaced with underscores, I can see also the perspective of wanting them both to be the same if all else were equal. This is helpful feedback. I’ll log an issue regarding the following, as I think you’ve surfaced some important room for improvement in the process: (1) at minimum clarify in the readme docs about each field’s constraints, (2) add to troubleshooting section the specific symptoms of what you’ve logged here related to dashes, (3) see if we can add better hints or perhaps a hard failure in the cookiecutter process itself. Thanks very much for logging this - I appreciate the feedback on your experience.
s
You’re welcome. I’m super thankful for the work you guys are doing and would love to find more ways to help out. Certainly, I will continue to surface these issues.
v
And tbh I thought the same thing when I made my tap, but decided to go with the recommended folder names because "there must be some reason" , looks like I got lucky going with the flow 🙂
a
Thanks, both! 👍 👍