rez icon indicating copy to clipboard operation
rez copied to clipboard

Do not fail rez-env on missing package.py

Open herronelou opened this issue 9 months ago • 4 comments

I'm putting this as a Feature request rather than a Bug because I believe the current behavior to be intentional.

Currently, if there is a folder within a PackageFamily folder (which may or may not be a Package Version), and it does not contain a package.py, the entire rez-env command will fail with PackageDefinitionFileMissing: Missing package definition file: FileSystemPackageResource({'location': '/path/to/location', 'name': 'package_name', 'version': x.x.x', 'repository_type': 'filesystem'}).

I wonder if this could be more of a warning rather than an error. Skip this version and move on. I understand Rez doesn't like this format, and that something is very wrong when this happens, however due to some other external problems it could end up happening, and completely failing rez-env commands seems a bit overkill.

Motivation In our case, it happens occasionally because the system we have in place to sync our rez repository across facilities has a tendency to create the folder structure first, then the files, so the directory appears first, before the .building lock file gets synced, then the rest of the files, then the .building is removed. However when the sync queue is larger there may be a gap between the dir creation and the files arriving, causing the entire facility receiving the updates to not being able to use rez whatsoever if this is a common packages.

Really while I agree our failure is due to issues with our sync system, I can't really think of a drawback of ignoring directories without a package.py, besides making it obvious that something is wrong.

Related Issues/PRs Somewhat related to: https://github.com/AcademySoftwareFoundation/rez/issues/1618

herronelou avatar Apr 02 '25 23:04 herronelou

Error is raised in https://github.com/AcademySoftwareFoundation/rez/blob/29336360a45dd9ef4b501eae3095de98dc2da450/src/rezplugins/package_repository/filesystem.py#L189

herronelou avatar Apr 02 '25 23:04 herronelou

From my understanding, by default Filesystem Repository doesn't check for the existence of package.py files, and this done for speed purposes and to lessen file system stat requests. If you want the fault tolerance to not fail rez-env when the file existence is not there, there is config setting you can try. example on plugins setting of rezconfig

plugins = {
    "package_repository": {
        "filesystem": {
            "check_package_definition_files": True
            } 
    },

vanridal avatar Apr 06 '25 03:04 vanridal

I'll double check, I'm pretty sure we didn't change the settings from the default but it's been a while since I checked them.

herronelou avatar Apr 06 '25 18:04 herronelou

@vanridal re-reading your answer with some hindsight, I realize you were not saying that we may have changed that setting causing the error, but that you were suggesting changing that setting as a way to fix it, as indeed it would skip packages without a package.py.

From reading the code, it does seem like it would fix it, but indeed I'd rather avoid too many stats, wondering if it could be handled with a judicious try/except of that PackageDefinitionFileMissing error.

herronelou avatar Jun 29 '25 17:06 herronelou