-
Notifications
You must be signed in to change notification settings - Fork 148
[WIP] support for building nodejs_npm functions #44
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
Conversation
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.
Thank you so much for contributing. Really appreciate all the hardwork you have put in here.
It might look like there are a lot of comments. But most of my comments are in general about Python or the conventions used in this project. So feel free to ignore or let me know if you disagree. I am happy to hear your thoughts. I believe we can get to a better design by collaborating this way.
|
||
LOG.debug("NODEJS packaging %s to %s", package_path, self.scratch_dir) | ||
|
||
tarfile_name = self.subprocess_npm.main(['pack', '-q', package_path], cwd=self.scratch_dir) |
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.
Is tarball the only option? We need to tar and untar again unnecessarily.
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.
yes, as far as I know. npm pack
produces a tarball (https://docs.npmjs.com/cli/pack)
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.
okay, cool. Let's stick with this then.
One downside of this is, when we implement hot-reloading we have to modify this implementation. But that's for later :)
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.
ok, should I leave some kind of todo note there?
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.
also, in theory, we can do hot reloading to check if package.json got modified. if yes, then rerun the whole tar thing. if only a file within the project got modified, and not package.json, then it's pretty safe to assume that packaging didn't change and dependencies did not change as well, so it's OK to just safe-reload that file.
Copying conversation from slack on difference between
|
- restored old osutils into python_pip to avoid unnecessary changes - removed the guard for manifest not existing (as per #44 (comment))
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.
Couple of other minor comments..
This is starting to shape up really well :)
self.osutils = osutils | ||
|
||
if npm_exe is None: | ||
npm_exe = 'npm' |
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.
In the future if there are multiple paths of npm on your system, how would you imagine passing them in? or maybe thats not a big concern.
I started a PR here: #35 that would help with that. But I'm going to take a step back and maybe write a mini design doc to get started on it. I was curious to know if you had any comments on that?
#44 (comment)) - using ValueError for argument type error (as per #44 (comment))
@gojko we also need to setup Travis & AppVeyor to run tests with a node environment. This is going to be interesting. I am happy to punt this work to a separate PR because it requires more wrangling.. |
It looks like the overall design of the code is OK? I'll then add unit tests and we can start closing off the first release of this. Regarding NPM, we could somehow split out integration tests that require NPM from the rest, so you can run them on two different integration test environments. Let me know if that's an option. |
Everything looks good, except for the unique_dir comment. Do start writing unit tests. I will create a separate Travis/Appveyor PR to run integ tests |
Also, is there a min version of Nodejs & NPM that this implementation assumes? |
this just runs the NPM executable, so as long as there is one on the path, it will work. NPM tends to ignore parameters that it does not understand, so |
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.
We are in the homestretch here. Logic all looks great! One minor comment about exceptions, and everything else is docstrings.
Can you add docstrings to the classes & methods? Following a reStructuredText
doc format (like this: https://github.com/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflow.py#L84-L117)
I will also keep the PR open for unit tests
I've updated the base to merge into develop using the github UI, not sure if that will do the trick or not. if this looks wrong to you, i'll create a completely clean PR |
Yup, that's good enough :) Looks like the integ tests are failing on Windows because its not able to find node/npm :( |
I wonder if npm is a separate package you need to install there? it looks like node is installed, but it's not finding NPM. |
that's surprising. I tested the appveyor config here - sanathkr@713d5b2. It did print npm version - https://ci.appveyor.com/project/sanathkr/aws-lambda-builders/builds/20767787/job/5k44u8p3pujh7kg3 |
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.
Overall this looks really good @gojko Nothing super critical in my feedback.
|
||
if npm_exe is None: | ||
if osutils.is_windows(): | ||
npm_exe = 'npm.cmd' |
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.
Does npm have a npm.exe
at all?
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.
no it doesn't unfortunately. I verified on a windows box
|
||
from aws_lambda_builders.workflows.nodejs_npm.actions import NodejsNpmPackAction, NodejsNpmInstallAction | ||
|
||
from aws_lambda_builders.actions import CopySourceAction |
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.
PEP 8 imports
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.
hi, I'm not actively working with python do I don't know what you mean by this. What would you like me to change?
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.
resolved in 6863067
Just realized, we never wrote a design document for this. This is just a simple markdown file that explains what the workflow does, like this - https://github.com/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/python_pip/DESIGN.md. Goal is to let other implementors understand why certain decisions were made. It helps us set context for future design changes. If you got time, can you add a short design document? If you feel the PR is already big, we can do it in a separate PR later |
I added this here 09d4190 |
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.
Two small comments on the design doc. This looks really good!
:param osutils: An instance of OS Utilities for file manipulation | ||
|
||
:type npm_exe: str | ||
:param npm_exe: Path to the NPM binary. If not set, |
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.
I'm ok with keeping this here for the PR, but eventually we need the workflow to start with absolute paths to dependency managers, language etc to ensure a correct build?
I have started a PR here with design notes: https://github.com/awslabs/aws-lambda-builders
Let me know on your thoughts!
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.
@thesriram I guess as long as you pass an executable into the workflow as a standard parameter, we can easily pass it to the NPM wrapper there, so it should be a single line of code change once it is ready.
The PR looks good to me. My only concern was to be able plugin path resolvers and path validators appropriately without much effort after this gets merged, which is what I have commented. |
@gojko Please confirm this contribution is under the terms of the Apache 2.0 license. Thanks. |
@sanathkr I confirm that my contribution is made under the terms of the Apache 2.0 license. |
Description of changes: Initial support for building nodejs_npm, for early code review. This does not yet support building projects with local dependencies.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.