Skip to content

Python files from unrelated modules present when using package: individually #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jimpudar opened this issue Jan 4, 2020 · 5 comments

Comments

@jimpudar
Copy link

jimpudar commented Jan 4, 2020

I'm expecting my final module's zip file to include something like:

package_name/app.py
package_name/file.py
tests/test_package_name.py
.flake8
.pylintrc
...

but I'm also seeing files from unrelated modules:

SomeUnrelatedModule/is_showing_up/app.py
OtherUnrelatedModule/something_saas_function/app.py
package_name/app.py
package_name/file.py
tests/test_package_name.py
.flake8
.pylintrc
...

The regex in this filter expression appears to be too general:
https://github.com/UnitedIncome/serverless-python-requirements/blob/master/lib/inject.js#L70

I'm getting files from unrelated modules which match this regex, e.g.
OtherModule/some_cool_function_is_matching/the_regex.py

I don't fully understand the purpose of that regex in the filter, but my assumption is that rather than s_.*\.py it should be ^s_.*\.py.

If this is the case let me know and I can raise a PR to correct the regex.

@jimpudar
Copy link
Author

jimpudar commented Jan 5, 2020

Paging @dschep for the background on the purpose of the regex

@dschep
Copy link
Contributor

dschep commented Jan 9, 2020

@jimpudar the purpose of that regex is to support serverless pro, which injects wrappers for each function named s_FUNCNAME.py as well as the serverless_sdk directory in the line above.

@jimpudar
Copy link
Author

jimpudar commented Jan 9, 2020

Thanks @dschep, so I take it ^s_.*\.py is the correct regex to use here? If so, I have a PR open to fix this. If not, let me know and I can correct it. Thanks!

@dschep
Copy link
Contributor

dschep commented Jan 9, 2020

Ah, yes! that is correct. i imagine it can still cause this bug if you just have a file named s_foobar.py but at least it won't for files lke foobs_ar.py

@jimpudar
Copy link
Author

jimpudar commented Jan 9, 2020

In my testing it seemed like it was matching against the entire path rather than just the filename. So if the intent is to match only files in the top level directory beginning with s_ and ending with .py then the regex in my PR should work just fine.

bsamuel-ui added a commit that referenced this issue Feb 18, 2020
Correct imprecise regex in moveModuleUp function (fixes #444)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants