[PYTHON] saving script results as artifact

I have a python script that runs an MLOps pipeline, and in the end, I get the accuracy.

I want to put the accuracy in a file and upload it as an artifact during the workflow to the github actions.

I know how to upload an artifact, the problem is writing a file in python during the workflow run that holds the information I want. It is important to point out that the script does not return the accuracy.

what I have tried until now is using ‘with open(file.txt, ‘w’)…’ and writing to it. however, when I try to upload file.txt as an artifact, I attempt to upload from ${{github.workspace}}/path/to/file/file.txt, the workflow can not find it

After a couple of attempts, and using “run: ls ${{github.workspace}}/path/to/file/” I have noticed that it does not even create the file, nor does it write to it.

I have tried creating the file as an individual step in the workflow, and then writing to it, but writing to it during the python script does not work.

Is there any way that I can retrieve the accuracy information from the python script without returning it in the method?

I wonder if the path might be wrong? If you do open('file.txt', 'w') the file will appear in the current working directory, not the directory where the script file is.

so are you suggesting it may be under ${{github.workspace}}/ ?

I will run a test now, and print out the directory to see if it is there

If you didn’t change the default working directory that’s where it should be, yes. :slightly_smiling_face: