pub async fn kernels_output(
        &self,
        name: impl AsRef<str>,
        path: Option<PathBuf>,
    ) -> anyhow::Result<Vec<PathBuf>> {
        let name = name.as_ref();
        let (owner_slug, kernel_slug) = self.get_user_and_identifier_slug(name)?;

        let folder = path.unwrap_or_else(|| {
            self.download_dir
                .join(format!("datasets/{}/{}/output", owner_slug, kernel_slug,))
        });

        fs::create_dir_all(&folder)?;

        let resp = self.kernel_output(name).await?;

        let mut outfiles = Vec::with_capacity(resp.files.len());

        let mut outstream = stream::iter(resp.files.into_iter().map(|file| async {
            let outfile = folder.join(file.file_name);
            let content = file.url.content;
            tokio::fs::write(&outfile, content).await?;
            Ok::<_, std::io::Error>(outfile)
        }))
        .buffer_unordered(3);

        while let Some(f) = outstream.next().await {
            outfiles.push(f?);
        }

        if let Some(log) = resp.log {
            let outfile = folder.join(format!("{}.log", kernel_slug));
            tokio::fs::write(&outfile, log).await?;
            outfiles.push(outfile);
        }
        Ok(outfiles)
    }
/// Retrieve output for a specified kernel.
Retrieve output for a specified kernel.
Retrieve output for a specified kernel .
pub async fn kernels_output(
        &self,
        name: impl AsRef<str>,
        path: Option<PathBuf>,
    ) -> anyhow::Result<Vec<PathBuf>> {
        let name = name.as_ref();
        let (owner_slug, kernel_slug) = self.get_user_and_identifier_slug(name)?;
        let folder = path.unwrap_or_else(|| {
            self.download_dir
                .join(format!("datasets/{}/{}/output", owner_slug, kernel_slug,))
        });
        fs::create_dir_all(&folder)?;
        let resp = self.kernel_output(name).await?;
        let mut outfiles = Vec::with_capacity(resp.files.len());
        let mut outstream = stream::iter(resp.files.into_iter().map(|file| async {
            let outfile = folder.join(file.file_name);
            let content = file.url.content;
            tokio::fs::write(&outfile, content).await?;
            Ok::<_, std::io::Error>(outfile)
        }))
        .buffer_unordered(3);
        while let Some(f) = outstream.next().await {
            outfiles.push(f?);
        }
        if let Some(log) = resp.log {
            let outfile = folder.join(format!("{}.log", kernel_slug));
            tokio::fs::write(&outfile, log).await?;
            outfiles.push(outfile);
        }
        Ok(outfiles)
    }
pub async fn kernels_output ( & self , name : impl AsRef < str > , path : Option < PathBuf > , ) -> anyhow :: Result < Vec < PathBuf > > { let name = name . as_ref ( ) ; let ( owner_slug , kernel_slug ) = self . get_user_and_identifier_slug ( name ) ? ; let folder = path . unwrap_or_else ( | | { self . download_dir . join ( format ! ( " " owner_slug kernel_slug ) ) } ) ; fs :: create_dir_all ( & folder ) ? ; let resp = self . kernel_output ( name ) . await ? ; let mut outfiles = Vec :: with_capacity ( resp . files . len ( ) ) ; let mut outstream = stream :: iter ( resp . files . into_iter ( ) . map ( | file | async { let outfile = folder . join ( file . file_name ) ; let content = file . url . content ; tokio :: fs :: write ( & outfile , content ) . await ? ; Ok :: < _ , std :: io :: Error > ( outfile ) } ) ) . buffer_unordered ( 3 ) ; while let Some ( f ) = outstream . next ( ) . await { outfiles . push ( f ? ) ; } if let Some ( log ) = resp . log { let outfile = folder . join ( format ! ( " " kernel_slug ) ) ; tokio :: fs :: write ( & outfile , log ) . await ? ; outfiles . push ( outfile ) ; } Ok ( outfiles ) }
Retrieve output for a specified kernel.
Retrieve output for a specified kernel .
&self
name
impl AsRef<str>
path
Option<PathBuf>
&self
name
impl AsRef<str>
path
Option<PathBuf>