The SNP saw off a confident challenge from Labour in Dundee after a difficult first few months in power for Sir Keir Starmer's side.