-
Notifications
You must be signed in to change notification settings - Fork 129
Conversation
- lock requests to 2.25 - add cloudpathlib - add dropbox
- AnyPath falls back to Path when recognizing a local path. - custom FilePath for "file://" handling. - custom DropboxPath for "dropbox://" handling.
- and cache to local user data directory.
Needed for start.py is_inside check. Just returns the local cached path.
This reverts commit 895cfd8.
If a latest version is valid we return that rather than validating all versions.
# Conflicts: # openpype/version.py
resolves #1908 |
We could potentially unify the setup process with #1979, by using Team Folders, so people only have to make one Dropbox app, and one place for all the settings. |
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've just found one unpleasant side-effect of this - if you enable dropbox module, set your token and then enter path to OpenPype repositories to dropbox://...
and it will fail for some reason, you can't run settings anymore (anything from openpype in fact) as get_openpype_path_from_db()
is called early in bootstrap process and it will pull in dropbox to check if path exists.
Some solution is with changing order how path is determined here:
https://github.com/pypeclub/OpenPype/blob/2a01fb8f3165b237161f2ad6877d9a6213c79087/start.py#L811
so check for OPENPYPE_PATH
should be before this, but nevertheless we should probably handle dropbox errors more gracefully.
Do you have any stack trace of the errors? |
yeah, sorry:
but that error is not really relevant. I've added |
Good point! We'll need to gracefully authenticate Dropbox else use the local path I guess? |
Maybe it would be enough to catch exception in: if AnyPath(path).exists():
... because you can say that if |
True, we could do a try catch all. And fallback on the local user directory? |
Yeah, issue warning and fallback to what can be found locally. That warning should be in UI if not in headless mode so artist would know exactly that he's not using "official" studio version but possibly outdated one and he need to contact someone to fix it. |
Note to self. Something that keeps tripping me up when working with the Dropbox API is that the permissions are attached to the token. So if you update the permissions you'll need to update the token as well. |
# Conflicts: # igniter/tools.py # openpype/settings/entities/schemas/system_schema/schema_modules.json
This is ready for another review. |
# Conflicts: # igniter/tools.py # poetry.lock # pyproject.toml
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 missing dependency in pyproject.toml
:
cloudpathlib = "^0.6.2"
and we are missing documentation for this, but otherwise it seem to be working ok
also let's remove the clean versions function and put it to different pull request so we can track it cleanly in changelog. This cleanup should be configurable on local settings level - because you actually might need multiple versions of OpenPype on render nodes - version si passed to Deadline as environment variable. |
@tokejepsen could you please alter this based on @antirotor last comment, this included two features that are not related and the one with version cleanup need a bit more love. Also needs to be separate for the changelog which is generated automatically |
Yup, this is on my list to do at some point. |
@@ -128,6 +428,39 @@ def validate_path_string(path: str) -> (bool, str): | |||
return True, "valid path" | |||
|
|||
|
|||
def get_openpype_system_settings(url: str) -> dict: |
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 afraid it is not possible to use system settings before defying which OpenPype is used. That's why we separated few settings into global settings get_openpype_global_settings
. Main reason is that we knew that we will want to store settings by version (implemented with #2570).
|
||
# Hack to share url to AnyPath paths. | ||
MODULE = sys.modules[__name__] | ||
URL = "" |
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.
You should use os.environ["OPENPYPE_MONGO"]
instead of storing the value into global scope variable. Or pass the value into function where is needed.
@@ -14,6 +15,305 @@ | |||
ConfigurationError, | |||
OperationFailure | |||
) | |||
from cloudpathlib import AnyPath |
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.
Code specific for dropbox should be in separated file and only code that is used here should be imported. There is a lot of code which is dropbox specific but does not make sense in context of igniter/tools
for example class FilePath
is dropbox specific but I this context it is confusing.
I will soon start implementing the same for Google Drive. Wouldn't the easiest way be to fork cloudpathlib and add the class for |
Yeah, it might be. I just didnt have time to figure out where it should be. Also a fork might be more trouble managing with OP than a custom class, but forking might lead to a PR to origin repository which would be better. |
We had to actually put this on hold, until we finish refactor of the repository. To implement this cleanly it should be modules that provide the path cloud location, however those are not loaded until we start OP. there's a bit of an chicken and egg situation. We're counting on separating these responsibilities properly soon. |
Unfortunatelly, we won't be able to merge this in this state. It is however one of the first things to tackle as soon as we're done with the refactor of the client application, which is being changed to allow for this to be re-implemented a lot more robustly, without having to hardcode any specific providers into the product. |
Goal
Support URI paths like
file://
anddropbox://
.Closes #1908
Motivation
For some of our remote users we cant ensure access to local repository paths, so we have a need for storing our versions in the cloud.
Steps to test
Dropbox is the only supported cloud storage atm. For Dropbox you'll need to create an app: https://developers.dropbox.com/oauth-guide
I opted to use an app because you can have a separate root folder for the app, which makes it easier to organize.
Input the access token in the settings
Dropbox
section.Implementation
I initially tried to do custom implementations of Path like objects, but quickly found that the library https://cloudpathlib.drivendata.org/ had already figured things out, so I opted to use that.
The library does not however support Dropbox (which we need), so there is a custom class for Dropbox. That same goes for the uri
file://
which is just a wrapper for the built-in Path object.The
AnyPath
wrapper determines which class to use depending on the uri and if its a local path it'll revert to built-in Path object. This means we can use theAnyPath
as a replacement forPath
everywhere.I've initially put its all in
tools
but it might need a separate module.There is a caching system in
cloudpath
that'll localize the data when reading it. In order for this to work smoothly with the user data directory, I'm using the user data directory as the cache directory. To optimize download I changed to keeping the zip file after extraction. To further optimize download I've changed the validation to happen after the versions have been found, else we would be downloading zip files just validate against theversion.py
inside.To keep the user data directory clean, we delete any zip file that is not the current and any directory. Let me know if there is any issues with this, that you can think of.
The only thing I dont like about this implementation is the hack to get the system settings inside of the Dropbox class. This is because when we get the repository paths and validate their existence, we need the dropbox token.
[cuID:yjx9fd]