Skip to content
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

Adds a flag 'skip_package_lock_generation' to FTL #741

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ftl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ py_test(
srcs = ["common/util_test.py"],
deps = [
":ftl_lib",
"@mock",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was it a bug that this was missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to run this test without . this dependency.

],
)

Expand Down
6 changes: 6 additions & 0 deletions ftl/common/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def base_parser():
default=True,
action='store_true',
help='Upload to cache during build (default).')
parser.add_argument(
'--skip_package_lock_generation',
dest='skip_package_lock_gen',
default=False,
action='store_true',
help='Do not create package lock file before checking cache.')
parser.add_argument(
'--output-path',
dest='output_path',
Expand Down
3 changes: 3 additions & 0 deletions ftl/node/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def __init__(self, ctx, args):
self._should_use_yarn = self._should_use_yarn(self._ctx)

def _gen_package_lock_if_required(self, ctx):
if self._args.skip_package_lock_gen:
return
if not ftl_util.has_pkg_descriptor(self._descriptor_files, self._ctx):
return

Expand Down Expand Up @@ -76,6 +78,7 @@ def Build(self):
directory=self._args.directory,
destination_path=self._args.destination_path,
should_use_yarn=self._should_use_yarn,
reuse_cache_key=self._args.skip_package_lock_gen,
cache_key_version=self._args.cache_key_version,
cache=self._cache)
layer_builder.BuildLayer()
Expand Down
12 changes: 8 additions & 4 deletions ftl/node/layer_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self,
directory=None,
destination_path=constants.DEFAULT_DESTINATION_PATH,
should_use_yarn=None,
reuse_cache_key=False,
cache_key_version=None,
cache=None):
super(LayerBuilder, self).__init__()
Expand All @@ -41,14 +42,17 @@ def __init__(self,
self._directory = directory
self._destination_path = destination_path
self._should_use_yarn = should_use_yarn
self._reuse_cache_key = reuse_cache_key
self._cache_key_version = cache_key_version
self._cache = cache
self._cache_key = None

def GetCacheKeyRaw(self):
all_descriptor_contents = ftl_util.all_descriptor_contents(
self._descriptor_files, self._ctx)
cache_key = '%s %s' % (all_descriptor_contents, self._destination_path)
return "%s %s" % (cache_key, self._cache_key_version)
if not self._cache_key or not self._reuse_cache_key:
all_descriptor_contents = ftl_util.all_descriptor_contents(
self._descriptor_files, self._ctx)
self._cache_key = '%s %s' % (all_descriptor_contents, self._destination_path)
return "%s %s" % (self._cache_key, self._cache_key_version)

def BuildLayer(self):
"""Override."""
Expand Down