It is recommended to install Python in your local machine. You can download the latest version of Python from Anaconda. Please read the installation documents on the Anaconda website for your own Operation System (i.e. Windows OS, Mac OS, or linux).
We will use Discord as our main communication channel. Please join the Discord server for this course. We will use the #labs channel for all labs.
Please use this adventage to get to know your classmates and ask questions about the course.
NOTE: The Discord server is not set up yet. I will update the link here once it is set up.
ChatGPT and Bard are two chatbots that can help you with your work. Please use the advantage of these chatbots when you have questions at the first place. They are the most accessible tools than any other human beings.
Here are strategies for getting better results from chatGPT, which is gathered from the [OpenAI docs](Reference: https://platform.openai.com/docs/guides/prompt-engineering/six-strategies-for-getting-better-results). Other strategies require GPT4 models, which is under a subscription.
As the model cannot read your mind. You need to write clear instructions for the model to understand what you want. If outputs are too long, ask for brief replies. If outputs are too simple, ask for more details and examples. If you don't like the format of the output, provide a sample output you'd like to see. The less the model has to guess, the better the results will be.
Try: Write a clear question for ChatGPT to help you install Python according to your OS.
Just as it is good practice in software engineering to decompose a complex system into a set of modular components, the same is true of tasks submitted to a language model. Complex tasks tend to have higher error rates than simpler tasks. Further more, complex tasks can often be re-defined as a workflow of simpler tasks in which the outputs of earlier tasks are used to construct the inputs to later tasks.
Models make more reasoning errors when trying to answer right away, rather than taking time to work out an answer. Asking for a "chain of thought" before an answer can help the model reason its way toward correct answers more reliably.
Improving performance is easier if you can measure it. In some cases a modification to a prompt will achieve better performance on a few isolated examples but lead to worse overall performance on a more representative set of examples. Therefore to be sure that a change is net positive to performance it may be necessary to define a comprehensive test suite (also known an as an "eval").
We will use Git and Gitlab for submitting your assignments. The submission format of your assignments will be text and python files. Github is another popular version control repository. However, we will use Gitlab for this course.
Note: You need to install git in your local machine. You can download the latest version of git from here.
You need to generate a ssh key for your Gitlab account. You can follow the instructions here to generate a ssh key for your Gitlab account. You can use the following command to generate a ssh key.
-
On Windows:
- Open Git Bash (you can download it from Git for Windows if you don't have it).
- Use the command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" - When prompted to "Enter a file in which to save the key," press Enter to accept the default file location.
- Enter a secure passphrase when prompted.
-
On MacOS:
- Open the Terminal.
- Run the same command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" - Follow the prompts as above to choose a save location and passphrase.
- Add the Key to GitLab:
- Go to GitLab and sign in to your account.
- Click on your profile picture in the top right corner, then click on "Settings".
- In the User Settings sidebar, click on "SSH Keys".
- Paste your key into the "Key" field.
- Add a title in the "Title" field to help you identify the key (e.g., "MacBook Pro" or "Windows Desktop").
- Click "Add key".
Once you've added your SSH key to GitLab, you should be able to perform Git operations over SSH, which is more secure and often more convenient than using HTTPS, especially for frequent Git users.
Remember, the email you use in the ssh-keygen command should be the same one associated with your GitLab account. This helps in easily identifying the key's purpose and also in troubleshooting, should any issues arise with your GitLab connection.
- Step 1: Use your UARK email and password to login to Gitlab.
- Step 2: Go to the website MATH-499V-599V-MFML and click the button
Forkon the top right corner. - Step 3: Name your forked repository as
MFML-{First Name}-{Last Name}. For example,MFML-John-Doe. - Step 4: Clone Your Forked Repository. You can use the following command to clone your forked repository to your local machine. You can try the following code in your Powershell (WinOS) or terminal (MacOS) or VSCode (both).
git clone https://git.uark.edu/{your-username}/MFML-{First Name}-{Last Name}.git- Step 5: Add me as a Developer to your forked repository. You can do this on your repository page. Click
Manageon the left side bar and chooseMembers. ClickInvite memberson the rightup corner of the webpage. In the search panel, checkjiahuicorjiahuic@uark.eduand select the role asDeveloperand clikeinvite.
The second task 2 is to practice the basic git commands. You can use the following commands to practice git commands. At the beginning of our course, it is enough to use the following Git commands. As we go deeper of this course, we will revisit more git skill.
- Step 1: Create a new folder at
./labs/and name it aslab0. You can use the following command to create a new folder.
mkdir ./labs/lab0- Step 2: Create a markdown file at
./labs/lab0/and name it asREADME.md. You can use the editor of your choice to create this file. Or, you can try the following commend to create this file.
touch ./labs/lab0/README.mdOr use your editor to create this file.
- Step 3: Editor the
README.mdfile. On the first line, type# Lab 0. On the second line, typeThis is a lab for practicing Git commands.. On the third line, typePlease type your name below.. On the fourth line, type your name. For example,John Doe. - Step 4: Add the
README.mdfile to the staging area. You can use the following command to add theREADME.mdfile to the staging area.
git add ./labs/lab0/README.md- Step 5: Commit the changes. You can use the following command to commit the changes.
git commit -m "Add README.md file"- Step 6: Push the changes to your forked repository. You can use the following command to push the changes to your forked repository.
git push origin main- Step 7: Check the changes on your forked repository at the GitLab website. You can see the changes on your forked repository at the GitLab website.
Overall, the steps follow that you make changes to your local repo, add the changes to the staging area, commit the changes, and push the changes to your forked repository. You can check the changes on your forked repository at the GitLab website.
NOTE: You can have the full credits after you finish the first two tasks.
The third task is to practice the fork repository and pull request. You can use the following commands to practice fork repository and pull request as I will update the code in the center repository.
This case happens when your forked repository is both behind and ahead of the center repository, it means you have made changes that aren't in the upstream repository (ahead) and there are changes in the upstream repository that you don't have (behind). To synchronize your repository with the upstream while keeping your own commits, you can use a combination of git fetch, git merge, or git rebase.
To check if the central (upstream) repository has been updated since you forked or last updated your repository, you can follow these steps:
-
Configure a Remote for the Upstream Repository: If you haven't already configured a remote for the upstream repository (the original one that you forked), you'll need to do that first. You can do this by running:
git remote add upstream URL_OF_CENTRAL_REPO
Replace
URL_OF_CENTRAL_REPOwith the actual URL of the central repository.URL_OF_CENTRAL_REPO = https://git.uark.edu/jiahuic/math-499v-599v-mfml.gitfor this course. -
Fetch the Latest Changes from Upstream: Now, fetch the changes from the upstream repository. This command won't merge any changes into your local repository; it will just fetch the updates for review. Pull updates from the upstream repository.
git fetch upstream git merge upstream/main
-
Check the Status Against Upstream: To see if your local branch is behind the upstream repository's branch, you can use:
git status
Or, to see more detailed information, compare your branch with the upstream branch:
git diff --stat HEAD upstream/main
Replace
mainwith whatever branch you are tracking (e.g.,masterif the main branch is namedmaster). We usemainfor this course.- Using
git statusafter merging helps to ensure that your local branch is up-to-date with the upstream branch. git diff --stat HEAD upstream/mainis useful for seeing a summary of what changes have been incorporated from the upstream.
- Using
-
Viewing the Commit Log: If you want to see the actual commits that are in the upstream repository but not in your repository, you can use:
git log HEAD..upstream/main --oneline
This command will list the commits present in the upstream
mainbranch but not in your current branch. Again, replacemainwith the appropriate branch name if different. -
Merge the Upstream Changes into Your Repository Now, you have a couple of choices on how to integrate these changes: merging or rebasing.
-
Option 1: Merging Merging is a non-destructive operation and will keep the history of your changes and the upstream changes.
First, switch to your main branch (if you're not already on it):
git checkout main
Then, merge the changes from the upstream repository:
git merge upstream/main
This command will create a new commit in your history that merges the two histories. If there are any merge conflicts, you'll need to resolve them. Use
git diffin step 3 to check the difference. -
Option 2: Rebasing Rebasing will place your changes on top of the upstream changes, resulting in a cleaner, linear history.
First, switch to your main branch:
git checkout main
Then, rebase your changes onto the upstream branch:
git rebase upstream/main
During a rebase, you might encounter conflicts. Resolve them as they arise and continue the rebase process. After resolving conflicts, you can continue the rebase with
git rebase --continue. Repeat this until the rebase is complete.
-
-
Push Your Changes If you've rebased, you'll need to force-push your changes back to your repository (since you've rewritten history):
git push origin main --force
If you merged, a regular push will suffice:
git push origin main
- After completing these steps, your local branch should be synchronized with the upstream
mainbranch. However, if you have local commits that are not in the upstream, they will still be present in your local branch. - If there are conflicts during the
git mergestep, you will need to resolve these conflicts manually before you can complete the merge. - It's a good practice to regularly fetch and merge changes from the upstream, especially before starting new work or pushing changes to your fork. This minimizes conflicts and keeps your fork up-to-date.
By following these steps, you can easily keep track of any updates or changes that have been made to the central repository and ensure that your fork stays up-to-date with those changes.
This is something beyond the scope of this lab. However, I would like to introduce this concept to you. You can read more about PR here.
Here's a breakdown of how pull requests work and their impact:
-
Scope of a Pull Request:
- A pull request is essentially a request to merge one branch into another within the same repository or across forks.
- When you create a pull request, it is isolated to your own fork and the branch from which you're making the request.
-
Impact on Your Repository:
- Within your repository, the pull request tracks the changes between the base branch (the one you want to merge into) and the compare branch (the one with your changes).
- The PR allows for discussion, review, and additional commits until it gets merged or closed.
-
No Direct Effect on Others' Repositories:
- Your pull request does not directly affect the state of anyone else's repository until it is merged by a maintainer of the target repository.
- Other contributors will not see your changes in their own forks or clones unless they explicitly fetch and merge your branch into their own branches.
-
After Merging:
- If your pull request is accepted and merged into the main repository (the upstream repository from which you forked), then your changes become part of that main repository.
- Once merged, other contributors can pull the changes from the main repository into their own forks or clones.
-
Best Practices:
- Keep your PRs focused and small to facilitate easier review and quicker integration.
- Regularly sync your fork with the main repository to avoid merge conflicts.
- Engage in any discussion or requests for changes that arise during the PR review process.
-
Open PRs and Syncing:
- If you're syncing your fork with the upstream repository while having an open pull request, ensure that your syncing process (merge or rebase) does not disrupt the PR. Typically, changes to other branches or unrelated commits won't affect the PR.
In summary, your pull requests are confined to your own repository and the upstream repository you wish to merge your changes into. They provide a controlled environment for proposing changes, receiving feedback, and collaboratively refining your contributions.