Extracting zip in space work enviornment throws : runtime error Space not ready. Reason: Completed, exitCode: 0, message: None

runtime error

Space not ready. Reason: Completed, exitCode: 0, message: None

Hey there, i tried below code to extract a zip file located in my space project directory where i wants to extract the files besides app.py. some how the code runs successfully but can’t find the extracted files and output says ‘# runtime error ## Space not ready. Reason: Completed, exitCode: 0, message: None’


import os
import shutil
from os import path
from zipfile import ZipFile
from shutil import make_archive

def main():
filename = “master.zip”
extract_dir = “master”
archive_format = “zip”

if path.exists(filename):
    print ("yes ur zip location exists.")
    root_dir,tail = path.split(src)
    shutil.unpack_archive(filename, extract_dir, archive_format)
    print ("Archive file unpacked successfully.")
    print ("Error: Archive file unpacked un-successfully.")

if name==“main”:

Is there any push commit query required to make changes in project directory while writing files and folders into it. if it so than please guide on the same.

Hello @nightfury,
Could you provide a link to the failed space please ?
Did the logs give you any information regarding the failure ?

runtime error

Space not ready. Reason: Completed, exitCode: 0, message: None

No container log shows no failure msg,…

Well from what I can see there is no failure.
Your main in app_t.py does not start the gradio app, so the process just ends, hence the Completed in the Reason

yaa but where are the files extracted, i can’t find them in my space project. i needs those files and folders

Not sure what you’re trying to achieve.
Between two run of your space files that were generated/extracted are not kept. If you need the extracted files at runtime you need to extract them before launching your main app within the same run.

hey as you know importing files and folders in huggingface spaces project is not possible and except for creating a file there is no option to create a new directory or something.

what i want is to add additional py codes and use them in references and change wherever applicable. i can see many projects has codes in folders and i don’t know how they are importing them.

So to import multiple .py files and folders i zipped them in my local directory and now using single file upload option has uploaded a zip file… now the issue is i wants them to extract them all in src. now thats where im stuck in. Extracting them is a big question on how to do it.

I dont want them just at run time, i wants the extracted files and codes to use.
so thts all in requirements and issues.

tried this above code but it does extraction at runtime, doesn’t commit to access them in my project.

Nothing you do in the space will have an impact on your space repository.
If you want to add these files you should git clone your repository
git clone https://huggingface.co/spaces/nightfury/SD-InPainting
Then you should add your folder in the project, commit the folder and files and then push.

git clone to where ?
huggingface repository
github repository

You can clone your huggingface repository locally, in this instance huggingface acts as a version control similarly to github.
So simply git clone https://huggingface.co/spaces/nightfury/SD-InPainting locally on your system, add the files, commit and push.

im still not getting it.
im itself in the same project. why to clone my own project. will it execute automatically to extract zip files in it?
& where to write this code ’ git clone https://huggingface.co/spaces/nightfury/SD-InPainting’ ? in requirements file?

Locally you mean via github desktop setup or cmd tool?

Yes locally I meant using the git cmd

1 Like

yup that worked… but had to go through git cmd allover again… cloning, pull, push & commit