InstituteforDiseaseModeling / idmtools

https://docs.idmod.org/projects/idmtools/en/latest/
Other
4 stars 4 forks source link

Can not download AssetCollection files with platform.get_files_by_id #1574

Open shchen-idmod opened 3 years ago

shchen-idmod commented 3 years ago

try to help Ye to download AssetCollection file to local as following code, but it throws error:

      try:
            out_filenames = [ 'ubuntu.sif']
            output_path = tempfile.mkdtemp()
            self.platform.get_files_by_id("978c1f34-f0c7-eb11-92dd-f0921c167860", ItemType.ASSETCOLLECTION,
                                           out_filenames, output_path)
        finally:
            shutil.rmtree(output_path)
in get_files_by_id
    return self.get_files(idm_item, files, output)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Platform COMPSPlatform - id: c18b51bd6739785a97eb8c847e805ab7>
item = AssetCollection(_uid=UUID('978c1f34-f0c7-eb11-92dd-f0921c167860'), _IItem__pre_creation_hooks=[], _IItem__post_creatio...XHN0b3JhZ2VcQXNzZXRzXDk4Mlw5NzZcMTU0XDk4Mjk3NjE1LTRiODgtMjBhMC1kYTVlLTc4OGY4OGRiMzljOA__/ubuntu.sif"
        }
    ]
})
files = ['ubuntu.sif']
output = 'C:\\Users\\shchen\\AppData\\Local\\Temp\\tmpi2efa7w7', kwargs = {}
interface = '_assets'

    def get_files(self, item: IEntity, files: Union[Set[str], List[str]], output: str = None, **kwargs) -> \
            Union[Dict[str, Dict[str, bytearray]], Dict[str, bytearray]]:
        """
        Get files for a platform entity.

        Args:
            item: Item to fetch files for
            files: List of file names to get
            output: save files to
            **kwargs: Platform arguments

        Returns:
            For simulations, this returns a dictionary with filename as key and values being binary data from file or a
            dict.

            For experiments, this returns a dictionary with key as sim id and then the values as a dict of the
            simulations described above
        """
        if item.item_type not in self.platform_type_map.values():
            raise UnsupportedPlatformType("The provided type is invalid or not supported by this platform...")
        interface = ITEM_TYPE_TO_OBJECT_INTERFACE[item.item_type]
>       ret = getattr(self, interface).get_assets(item, files, **kwargs)
E       AttributeError: 'CompsPlatformAssetCollectionOperations' object has no attribute 'get_assets'

..\..\..\idmtools_core\idmtools\entities\iplatform.py:601: AttributeError
shchen-idmod commented 3 years ago

Also DownloadWorkItem did not work either

YeChen-IDM commented 3 years ago

Thanks @shchen-idmod

shchen-idmod commented 3 months ago

Update: This issue is still there. example.py.txt