Dislocation dynamics and brittle-to-ductile transitions