Python rendering animation saves frame twice So I have a fairly simple method in my blender python script that either renders and saves an individual frame or renders an animation given a frame range. Now the former option works perfectly, the frame lands where it should be in the newly created folder and everything is fine. The latter, not so much:
For some reason, Blender saves the animation frames twice, once in the newly created folder with the name specified by output_path as it should and once, for some damn reason, in the parent folder above WITHOUT the frame name (just the usual 000X.exr). I should mention that I have just one output node with multi-layered OpenEXR that has an Image channel and a depth channel. I've tried different combinations for the parameters of bpy.ops.render.render and also confirmed it is only this line causing this since it doesn't render or save anything if I comment it out. Obviously I call this method with animation=True when this problem occurs.

I'd appreciate it if you could explain to me why it does that or where the source code for this damn function is.

def render_frame_and_save(output_name, animation=False, start=0,end=240):
    #Determine incremental output path
    i = 0
    while os.path.exists(output_path + '{:03d}'.format(i)):
        i +=1
    path = output_path + '{:03d}'.format(i)
    os.makedirs(path )

    bpy.context.scene.render.filepath = path + "/" + output_name 
    if animation: 
        bpy.context.scene.frame_start = start
        bpy.context.scene.frame_end = end
        bpy.ops.render.render(animation=True)
    else:
        bpy.ops.render.render(write_still = True)

    #Dump config
    cfg_file = open(path + '/samples.cfg', 'w')
    cfg_file.write('time: ' + datetime_str) #TODO Add config
    cfg_file.close()
So if anyone stumbles over this: I did find out what caused it

A bit unintuitively, Blender automatically saves animation but not single frames. I assumed that after I removed the default composite node (after activation nodes) in the Composition View, Blender would not save anything out of my designated output nodes. But well, it still does (but again, only when you render animations).

Edit (27-03-2020): To make it a bit clearer, the problem is that while you can choose not to save the output when rendering frames, Blender WILL saved rendered animations regardless of your dedicated output nodes. The option not to save this animation output (in addition to your output nodes) seems to be missing. 

There also doesn't seem an obvious way of preventing Blender from doing so which is quite annoying.