mirror of
https://github.com/clearml/clearml-agent
synced 2025-02-07 05:19:17 +00:00
Add support for setting mode on files applied by the agent
This commit is contained in:
parent
3ed63e2154
commit
ccf752c4e4
@ -52,6 +52,7 @@ def apply_files(config):
|
|||||||
target_fmt = data.get("target_format", "string")
|
target_fmt = data.get("target_format", "string")
|
||||||
overwrite = bool(data.get("overwrite", True))
|
overwrite = bool(data.get("overwrite", True))
|
||||||
contents = data.get("contents")
|
contents = data.get("contents")
|
||||||
|
mode = data.get("mode")
|
||||||
|
|
||||||
target = Path(expanduser(expandvars(path)))
|
target = Path(expanduser(expandvars(path)))
|
||||||
|
|
||||||
@ -110,3 +111,14 @@ def apply_files(config):
|
|||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print("Skipped [{}]: failed saving file {} ({})".format(key, target, ex))
|
print("Skipped [{}]: failed saving file {} ({})".format(key, target, ex))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
if mode:
|
||||||
|
if isinstance(mode, int):
|
||||||
|
mode = int(str(mode), 8)
|
||||||
|
else:
|
||||||
|
mode = int(mode, 8)
|
||||||
|
target.chmod(mode)
|
||||||
|
except Exception as ex:
|
||||||
|
print("Skipped [{}]: failed setting mode {} for {} ({})".format(key, mode, target, ex))
|
||||||
|
continue
|
||||||
|
@ -481,6 +481,7 @@ sdk {
|
|||||||
# target_format: format used to encode contents before writing into the target file. Supported values are json,
|
# target_format: format used to encode contents before writing into the target file. Supported values are json,
|
||||||
# yaml, yml and bytes (in which case the file will be written in binary mode). Default is text mode.
|
# yaml, yml and bytes (in which case the file will be written in binary mode). Default is text mode.
|
||||||
# overwrite: overwrite the target file in case it exists. Default is true.
|
# overwrite: overwrite the target file in case it exists. Default is true.
|
||||||
|
# mode: set the file mode after writing. use an integer value or a string (e.g. 600 / 777 etc.)
|
||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
# files {
|
# files {
|
||||||
|
Loading…
Reference in New Issue
Block a user