I have a Linear Function, $Y= a+bX$. The Mean Absolute Error would be $$f(a,b)=\frac1n \sum |y-(a+bx)|$$ To find the partial derivative I used this formulae
$$\frac{\partial f(x,y)}{\partial x} = \frac{g(x,y)\frac{\partial g(x,y)}{\partial x}}{|g(x,y)|}$$
and arrived at
$$\frac{\partial f}{\partial a} = \frac{-(y-(a+bx))}{|y-(a+bx)|}$$ $$\frac{\partial f}{\partial b} = \frac{-x(y-(a+bx))}{|y-(a+bx)|}$$
Is this the right way to do it?
Yes, that is the right way. You only have to add the sigma sign. The formula can be derived if you use that $|g(x)|=\sqrt{(g(x))^2}$ , $\forall \ x, g(x) \in \mathbb R$ .
The derivative is $\frac{d}{dx}\sqrt{(g(x))^2}=\frac{d}{dx} \left((g(x))^2\right)^{\frac12}$. Now we apply the chain rule twice.
$$=\frac12\cdot \left((g(x))^2\right)^{-\frac12}\cdot 2\cdot g(x)\cdot g^{'}(x)$$
$$=\frac12\cdot 2\cdot \frac1{ \left((g(x))^2\right)^{\frac12}}\cdot g(x)\cdot g^{'}(x)=\frac1{ |g(x)|}\cdot g(x)\cdot g^{'}(x)$$