django-pipeline icon indicating copy to clipboard operation
django-pipeline copied to clipboard

Pipeline does not fail when a file is missing for a bundle

Open duilio opened this issue 8 years ago • 8 comments

Currently during collectstatic, pipeline doesn't warn or fail at all when a file is missing. Issue #158 raised the same problem but it was closed without a note. I think this shouldn't be the default behavior of django-pipeline as I guess most of the times it's not what the user want.

duilio avatar May 19 '16 12:05 duilio

Totally agree. At least a warning should be generated.

Also, I would like to propose a setting for this. What to do: fail, warn, silent.

sobolevn avatar Jun 01 '16 13:06 sobolevn

@davidt what do you think of it?

sobolevn avatar Jun 01 '16 20:06 sobolevn

I think this is absolutely a great idea.

davidt avatar Jun 03 '16 19:06 davidt

Ok, I will try to implement it on the weekends.

sobolevn avatar Jun 03 '16 19:06 sobolevn

I'm not sure if this helps but I currently do this with a custom mixin that serves as the basis for my actual storage class:

class MakePipelineExplodePleaseMixin(PipelineMixin):
    """
    This class exists solely to cause collectstatic to fail loudly if anything is not findable by the `STATICFILES_FINDERS` *and* they
    have been configured within the Django Pipeline configuration settings.
    """

    def post_process(self, paths, dry_run=False, **options):
        packager = Packager(storage=self)

        def _verify_package(p, p_name):
            sources = p.config.get("source_filenames")
            if len(p.sources) != len(sources):
                raise IOError("Could not find all collected files for => %s with %s" % (p_name, sources))

        for package_name in packager.packages["css"]:
            package = packager.package_for("css", package_name)
            _verify_package(package, package_name)
        for package_name in packager.packages["js"]:
            package = packager.package_for("js", package_name)
            _verify_package(package, package_name)

        super_class = super(MakePipelineExplodePleaseMixin, self)
        if hasattr(super_class, "post_process"):
            for name, hashed_name, processed in super_class.post_process(paths.copy(), dry_run, **options):
                yield name, hashed_name, processed

fredpalmer avatar Jun 09 '16 20:06 fredpalmer

Trying to dig into it. Came up with several ideas:

  1. Updating the finders, since it is their jobs to get the file or warn if it does not exist.
  2. Updating the Compiler class, basically the _compile function.
  3. Creating a custom mixin, since it is the easiest approach. Something similar to what @fredpalmer suggested.

What do you think of it? @cyberdelia

sobolevn avatar Jun 29 '16 10:06 sobolevn

Updating the finders, since it is their jobs to get the file or warn if it does not exist.

My interpretation was that the job of the finders is to find the file if it does exist, and allow for other finders in the chain to attempt to find it if it does not.

kevin-brown avatar Jun 30 '16 23:06 kevin-brown

Any update on this?

andyhasit avatar Nov 30 '18 10:11 andyhasit