Notes
Notes
Notes
o Next you need to build this dockerfile into an image. You do this
by running this command in the folder where the Dockerfile
recides:
o docker build -t my_custom_image:v1
o This will create an image called my_custom_image with v1 as the
version number. You can change that to whatever you want.
CH8- Pipelines
- Think of different functions / operations / containers as blocks. For
executing the whole project, you need to connect all of them the right
just like a plumber fits the pipes in a specific manner to make the
underground pipeline of a city work right. This same process of
connecting all the blocks of a project is called pipelining
Example:
https://streamsets.com/blog/getting-started-streamsets-data-collector-
docker/
CH9-Defensive Programming
- From whom to defend ? From Failing ?? NO!! Its about
o ensuring that any failures are quick to surface,
o hard to miss, and
o easy to understand.
- 3 things from whom we have to save our program
o Unanticipated user inputs
In correct format of the input (TRUE instead of true)
Incorrect unit of the input (meters instead of
centimeters )
Incorrect option (linear instead of (hyperbolic and
polynomial))
o Unanticipated results
You expected a vector from a certain function which you
used in your code but it returned a list instead.
o Unreliable processes
These processes are prone to random failures
For example, imagine your code is opening teams and
uploading a mp4 file in it. You can come from the internet
connectivity.
Principles of Defensive Programming
- Make sure if your program fails it should fail,
o Conspicuously
Errors produced with stop()
Warnings() are used when your program can mostly
achieve what was required but the output might not be the
same as expected
Messages() are used to give the user status updates at
different points of the program. The user can then infer
from those messages if there is something going wrong or
not.
The good things about these above mentioned error
messages are
Bright color
User can call traceback on any condition to identify
where the error originated from
Selected warnings and messages can be ignored
using suppressMessages() and suppressWarnings().
o Fast
It’s almost always better for a function to fail right away
than to wait and keep trying for two reasons because
otherwise
It takes time and computational resource to keep on
trying
The program will eventually terminate abnormally
leaving behind messy partial outputs
The best way of finding errors fast is using if statement s
coupled with error messages mentioned above (stop(),
message(), warning())
R offers some built-in error handling for some common
outputs.
Arguments in a function are not equal to the
parameters in the function definition
o For less arguments: argument "x" is missing,
with no default.
o For more argument : unused argument (y = 3)
o Match.org for matching / comparing values
from a defined set just like we did in the vote()
in pset3
One Exception where retries are better
If you are processing something in your code which has
something to do with the internet retry can be beneficial
because internet is a flaky process.
o Informatively
If on a certain cases where it’s inevitable for your program
to fail, you need to communicate clearly to the user, what
went wrong.
For doing that you can use if and stop() but if you want to
save time by writing less code but still get this job of
writing elaborative error messages done you can use,
checkmate, assertive, assertr, and assertthat
packages.