python-lambda icon indicating copy to clipboard operation
python-lambda copied to clipboard

Support for version in Amazon API and filenames

Open kilna-magento opened this issue 8 years ago • 4 comments

Currently filenames are coded only with a timestamp... ideally there would be provisions for creating the filename based on a version string. The same input could then in turn be used to set the version as per the AWS Lambda API:

https://docs.aws.amazon.com/lambda/latest/dg/versioning-intro.html

This could be implemented by adding a "version: x.x.x" line to the config.yaml file, if present then the version provided will be used, otherwise the code will exhibit the current behavior for backward compatibility. Another option would be to add a '--version=x.x.x' command line parameter to 'lambda build' and the pending S3 change 'lambda upload'.

It would break 100% compatibility with current outputs, but it would also likely be more intuitive to have the filenames generated be in the format -<version|timestamp>.zip rather than the current -.zip.

kilna-magento avatar Sep 06 '17 18:09 kilna-magento

Tagging my other non-work account @kilna

kilna-magento avatar Sep 06 '17 18:09 kilna-magento

Also, bears mentioning... looking at the codebase, I can do this. Just curious if others have the same need.

kilna avatar Sep 06 '17 19:09 kilna

Me too

alvsanand avatar Dec 14 '18 10:12 alvsanand

Yes, I think this would be a very useful feature. I was thinking about submitting a patch for this along the same lines, so if you're doing it, I'll definitely support and use it. I realised (later) that this issue was submitted a while ago. I since tried to write a patch, but got into trouble running: python setup.py sdist bdist_wheel upload

First Issue is that README.rst has been renamed to README.md (No such file or directory: 'README.rst'). I renamed it Second Issue: the command line upload doesn't seem to work without specifying a .pypirc file Third Issue: my user cannot upload patches to this project, and I can't see any way of getting those permissions.

So an additional issue is that it seems to be very hard to contribute to this project.

Anyway, it would be a very simple change in aws_lambda.py:

instead of:

    # Combine the name of the Lambda function with the current timestamp to use
    # for the output filename.
    function_name = cfg.get('function_name')
    output_filename = '{0}-{1}.zip'.format(timestamp(), function_name)

Have:

    function_name = cfg.get('function_name')
    function_version = cfg.get('version')

    # If no version is set in config.yaml
    # Combine the name of the Lambda function with the current timestamp
    # otherwise combine the name of the Lambda function with the version
    # for the output filename.
    output_filename = (
        '{0}-{1}.zip'.format(timestamp(), function_name)
        if not function_version
        else '{0}-{1}.zip'.format(function_name, function_version)
    )

mikeycoxon avatar Mar 09 '19 22:03 mikeycoxon