Create a symlink file, which can be followed by :func:`get_file`. Unlike unix symlinks, symlink files can be created by this function are normal text files and can be uploaded to object stores via :meth:`.ObjectStore.upload_object` or loggers via :meth:`.Logger.upload_file` that otherwi
(
existing_path: str,
destination_filename: Union[str, pathlib.Path],
)
| 752 | |
| 753 | |
| 754 | def create_symlink_file( |
| 755 | existing_path: str, |
| 756 | destination_filename: Union[str, pathlib.Path], |
| 757 | ): |
| 758 | """Create a symlink file, which can be followed by :func:`get_file`. |
| 759 | |
| 760 | Unlike unix symlinks, symlink files can be created by this function are normal text files and can be |
| 761 | uploaded to object stores via :meth:`.ObjectStore.upload_object` or loggers via :meth:`.Logger.upload_file` |
| 762 | that otherwise would not support unix-style symlinks. |
| 763 | |
| 764 | Args: |
| 765 | existing_path (str): The name of existing object that the symlink file should point to. |
| 766 | destination_filename (str | pathlib.Path): The filename to which to write the symlink. |
| 767 | It must end in ``'.symlink'``. |
| 768 | """ |
| 769 | # Loggers might not natively support symlinks, so we emulate symlinks via text files ending with `.symlink` |
| 770 | # This text file contains the name of the object it is pointing to. |
| 771 | # Only symlink if we're uploading files to begin with |
| 772 | # Write remote file name into file to emulate symlink |
| 773 | # Add .symlink extension so we can identify as emulated symlink when downloading |
| 774 | destination_filename = str(destination_filename) |
| 775 | if not destination_filename.endswith('.symlink'): |
| 776 | raise ValueError('The symlink filename must end with .symlink.') |
| 777 | with open(destination_filename, 'x') as f: |
| 778 | f.write(existing_path) |
| 779 | |
| 780 | |
| 781 | def validate_credentials( |
no test coverage detected