Homework 1: Environment Setup
(Acknowledgement: Most of these instructions and inspiration come from Prof. Milind Kulkarni’s excellent instructions at https://engineering.purdue.edu/datamind/datascience/19spring/assignments/hw0/)
The goal of this assignment is two fold:
- Setup and use GIT to submit assignment.
- Setup basic Python environment.
Instead of blackboard, we will be using GIT this semester for assignment submission. The GIT part is based on the ideas from Prof. Milind Kulkarni’s GIT setup (see https://engineering.purdue.edu/~milind/ece20875/2019fall/git.php for some GIT tips).
Task 1: Setup GitHub account and use git to clone your personalized repository
If you haven’t already you need to signup for a GitHub account https://github.com/join and submit your GitHub username via the following form: https://forms.gle/A4to4Q7huAiKaQBN9
Then, you will need to click on the GitHub Classroom assignment signup link that I posted on Piazza to initialize your repository.
Next you need to install git if it is not already installed. Most servers should already have it installed. See https://git-scm.com/book/en/v2/Getting-Started-Installing-Git for more information about how to install git.
Then, you will also need to add an ssh-key to your GitHub account, see https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account.
After adding your ssh-key, you should be able to clone the homework repository via the following bash command-line command:
git clone git@github.com:ece570/hw1-<your GitHub username>.git
For example, I would execute:
git clone git@github.com:ece570/hw1-davidinouye.git
This will create a local folder on your repository called hw1-<your GitHub username>
. If you view the
contents of this folder you will see the skeleton files we have provided.
cd hw1-<your GitHub username>
ls
Task 2: Setup python environment
We will be using Python 3.7 (the most recent version of Python) in this class.
NOTE: Some of the default python on servers is Python2, e.g. ecegrid defaults to python2 when running
the python
command. We will be using Python 3 exclusively in this class so please do not develop
code using Python 2. At least on ecegrid, Python 3 can be accessed via the command python3
though
I would suggest installing anaconda or miniconda instead. See the Python Handbook for instructions on
how to install packages via anaconda and the conda
command
https://jakevdp.github.io/PythonDataScienceHandbook/00.00-preface.html#Installation-Considerations
You can install the following packages using pip (called pip3 on some servers for Python 3) or anaconda,
but they should have the following (recent) version numbers (at least up to the second version number,
i.e. 3.7.3 or 3.7.4 would be fine but 3.6.1 could be problematic).
If you have installed these Python packages before you may need to update your packages to the latest versions.
(You could create a new environment via conda
or venv
if you don’t want to change your default packages.)
python 3.7.4
numpy 1.16.4
scipy 1.3.1
pandas 0.25.1
sklearn 0.21.2
matplotlib 3.1.0
seaborn 0.9.0
Task 3: Modify code
Modify print_versions.py
to print the versions of all packages above in that order. The template file already has
examples of how to do python, numpy and scipy. NOTE: The scikit-learn
package is imported under the
module name of sklearn
.
After modification, run the program and save the output into the file out_print_versions.txt
python print_versions.py > out_print_versions.txt
The greater than symbol >
puts the output of the program into the file out_print_versions.txt
.
Task 4: Submit assignment via git
Please see https://guides.github.com/ for guides on how to use git or other online resources. A very brief overview:
git add <filename>
- This adds a file to a “staging” area.git commit -m "<your description of changes called a commit message>"
- This commits changes in the “staging” area to your local repository (i.e. only on your computer).git tag -a <tagname> -m "<description of tag>"
- This adds a tag or a little label to your current commit.git push
- UPDATE This pushes changes (but not tags) from your local repository to the remote repository on GitHub. NOTE: We can only see your changes if you push them to GitHub.git push --tags
- UPDATE: This only pushes tags to the remote repository on GitHub. NOTE: We can only see your changes if you push them to GitHub.
Generally you should commit and push changes as often as you can so that you have a history of your code edits.
For submitting an assignment you must tag your commit with the “submission” tag and then push this tag to the remote:
git tag -a submission -m "Submission for hw1"
git push --tags
If you want to update your submission, you must retag the commit with “submission” and push the new tag to GitHub.
git tag -a -f submission -m "Submission for hw1"
git push --tags -f
Note the extra “-f” tag in both commands which forces the submission tag to be overwritten. In general, you should not use the “-f” force flag unless you are updating your submission tag because it can overwrite history.
For this assignment, you will need to add your print_versions.py
and out_print_versions.txt
files and submit.
Here is an example of how to do all the commands for submission
(UPDATE: You should do run both git push
, which pushes your changes to GitHub and git push --tags
which pushes your submission tag to GitHub):
git add print_versions.py out_print_versions.txt
git commit -m "Added version printout"
git push
git tag -a submission -m "Submission for hw1"
git push --tags
NOTE: We will use the date/timestamp for the “submission” tag to determine whether something is submitted late. It is your responsibility to tag the correct commit with “submission” and update it if you change something.