Week 1 Assignment W200: Introduction to Data Science Programming This assignment is due at 11:59 PM PST the day before your second (week_02) live class. (So if you have class on Tuesday this is due...

1 answer below »
Please ALL and create ALL of the files and scripts needed. Thank you!


Week 1 Assignment W200: Introduction to Data Science Programming This assignment is due at 11:59 PM PST the day before your second (week_02) live class. (So if you have class on Tuesday this is due Monday night at 11:59 PM PST) Command line and bash scripting Objectives: Build a Conda environment and make a requirements file Build a file tree using the command line Write a short shell script to make a file tree Demonstrate uploading files to Github Edit a shared file on Github which might include fixing merge conflicts 1.1. Make a Conda environment and requirements.txt file For exercise 1.1, you will be creating a conda virtual environment. Virtual environments are important for programming projects because they manage package dependencies. We will discuss packages, modules and dependencies more later, but let’s just say that each programming project requires a different set of Python packages (sets of programs), and these sets can be incompatible. An environment lets you run compatible sets of packages together and keep them away from other environments. Use a command line: 1. Create an environment: 2. When conda asks you to proceed, type 'y': proceed ([y]/n)? This creates the myenv environment in /envs/. No packages will be installed in this environment. 3. Create an environment with a specific version of Python: 4. Create an environment with a specific package: In the next steps: 1 - Build an environment 2 - Practice switching in and out of the environment 3 - List the component packages in the ‘requirements.txt’ conda create --name myenv Note: Replace myenv with the environment name. conda create -n myenv python=3.7 af://n136 af://n138 af://n140 af://n141 af://n153 5. Create an environment with a specific version of a package: 6. To create an environment with a specific version of Python and multiple packages: 7. Remember how we said that we need to switch in and out of environments, there are a few syntaxes based on your system but it basically involves activating the environment doing your work then deactivating. As you switch in and out of environments note how the CLI prompt (parenthesis to the far left) changes to indicate that you have moved from base to myenv. 8. PART to turn-in Make an environment with 1) jupyter 2) python 3.6 and 3) scipy For this environment, don’t specify the package versions, let conda figure that out. Make a “requirements.txt” file and submit it as part of your github push. The requirements.txt is a list of all the packages in that environment and it allows you to share your dependencies with consumers of your code. Make sure that you are inside the environment that you just made and use this command. 1.2. Using the command line to build a folder & file tree In your main classroom Github repository on your local computer make a folder called SUBMISSIONS. Under this folder make a folder named week_01. This week_01 folder is where all of the submissions for this week will go. Please use the command line to build a folder tree with the below files within your week_01 folder as shown below. conda create -n myenv scipy conda create -n myenv scipy=1.5.0 conda create -n myenv python=3.7 scipy=1.5.0 For conda versions 4.6 and later, use: conda activate and conda deactivate For conda versions prior to 4.6, use: Windows: activate or deactivate Linux and macOS: conda activate myenv or conda deactivate conda list -e > requirements.txt af://n193 Record your commands in a text file named answers.txt and put this file in your week_01 folder s1, s2, s3, Advanced are folder (or directory) names (for example: under the week_01 folder will be the s1 folder and then the rest of the folder & file structure as shown above) Make a file named conf.txt that contains the sentence (without the quotes): Make a file named text_chunk1.txt write a sentence or two describing what conda environments good for (without quotes): text_chunk2.txt is a copy of text_chunk1.txt with one extra text line appended about why you like virtual environments (without the quotes) 1.3. Writing a Shell script Shell scripts are files with lines of shell commands. They are designed to be run at the command line terminal and are a full featured language (although no one programs completely in shell scripts). Shell scripts are an automated way of programming tedious tasks like repeated sets of commands that need to be performed. For example, you might write one to run a series of python programs every morning or when you deploy a website. You might write one to automatically create a file structure for a project (like a project template). Since you are on different systems choose either the Mac/UNIX instructions or the Windows instructions below Note: On Windows, you can use the git bash prompt to emulate the UNIX environment and use the UNIX instructions below if you prefer. Mac/Unix Only do this if you are on Mac or Unix - if you are using Windows skip to that section! Write a bash script that generates the above folder and files as shown in 1.2 excluding the answers.txt file (as if you are starting under the week_01 folder so do not include the week_01 folder) and save it as make_tree.sh. To do so, you can simply save the commands you use to generate the folder and files in a .sh file. Note: Do NOT use the "cd" command. For folder and file paths, please use "relative paths" instead of "absolute paths". If you are not sure what that means, this website might help: https://www.computerhope.com/issues/ch001708.htm |--answers.txt |--s1   |---s3   |   |---conf.txt   |---s2       |---text_chunk1.txt       |---Advanced           |---text_chunk2.txt "Virtual (conda) environments are my favorite new technology" "Virtual environments are good for ..." "Virtual environments are good for ..." "I like them because ..." af://n213 af://n220 https://www.computerhope.com/issues/ch001708.htm Hint: You should try running your script before you submit it to make sure it works before we grade it. There are several ways of executing bash files. Most simply, you can execute them via a command line call like sh make_tree.sh. In order to make this file executable, you should: Add this to the top of your file: #!/bin/bash This is called a "shebang" and it points to where your bash scripting is located (in this case bash is in /bin/bash which I can see by calling: which bash or type -a bash) make the file executable (do this on the command line NOT in the file) : chmod +x make_tree.sh This is modifying the permissions to make the file executable (+x) Windows Write a bash script that generates the above folder and files as shown in 1.2 excluding the answers.txt file (as if you are starting under the week_01 folder so do not include the week_01 folder) and save it as make_tree.bat. To do so, you can simply save the commands you use to generate the folder and files in a .bat file. Note: Do NOT use the "cd" command. For folder and file paths, please use "relative paths" instead of "absolute paths". If you are not sure what that means, this website might help: https://www.computerhope.com/issues/ch001708.htm Hint: You should try running your bat file before you submit it to make sure it works before we grade it. There are several ways of executing bat files. Firstly, you can execute them via a command line call by simply typing make_tree.bat. You can also just double-click on the file from a Windows folder. In order to print text to a file from a .bat script, you must type the command slightly differently than we did in the command line. Instead of: "this is some text to output" >> output_file.txt You will need to use: @echo this is some text to output >> output_file.txt Other commands like cp, mv and touch are different in windows command line syntax also. For example, cp is copy, mv is move and touch is not used in windows. Hint: You can google something like: "mv command in windows command line" or "windows mv equivalent" to find out what these commands are translated to the windows environment. 1.4. Github commits Please make at least two commits to the github-playground repository at: https://github.com/UC- Berkeley-I-School/mids-w200-github-playground. The commits must be separated by at least one full day and can be small but they must edit a single file called edit.txt . This is to show you how to deal with merge conflicts and multiple editors [i.e. people editing the repository]. If this file does not exist, please go ahead and be the first to create it. A few notes: To clone into the github-playground, you do not need to set up a "three way" repository like you have for your homework repository. You can instead use the default git command, "git clone" to clone the repository. You can then use just "git pull" and "git push" to pull from and push to the repository. (git clone https://github.com/UC-Berkeley-I-School/mids-w200-github- playground) af://n232 https://www.computerhope.com/issues/ch001708.htm af://n240 https://github.com/UC-Berkeley-I-School/mids-w200-github-playground https://github.com/UC-Berkeley-I-School/mids-w200-github-playground You may find these instructions helpful to clone into the repository (note, that the repository name will not have your username but instead will have the course group name): https://hel p.github.com/articles/cloning-a-repository/ You may also run into a "merge conflict" if you try submitting your changes to edit.txt at the same moment in time as somebody else. These conflicts occur when two people edited the same lines of code at the same time. Git does not know how to resolve the conflict, so it asks the user to help. Some merges are easy and will be done automatically however some are more complicated and have to be done manually. This resource can help you resolve difficult merge conflicts: h ttps://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/ Remember - when in doubt, use "git status". Good luck! Turn-In Checklist / Grading Rubric Please be sure you submit the following: 1. (20 pts) Your requirements.txt from the environment that you built for part 1.1 2. (20 pts) Your folder structure, as discussed in part 1.2. 3. (20 pts) The answers.txt file, as discussed in part 1.2
Answered Same DayNov 15, 2021

Answer To: Week 1 Assignment W200: Introduction to Data Science Programming This assignment is due at 11:59 PM...

Shubham Kumar answered on Nov 15 2021
127 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here