Skip to content

allegheny-college-cmpsc-101-spring-2024/object-processing-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object Processing

build Platforms: Linux, MacOS, Windows Language: Python Code Style: Black Commits: Conventional Discord

Introduction

  • Due date: Check Discord or the Course Materials Schedule
  • This assignment is graded as described in the syllabus section for an Engineering Efforts Assignment Evaluation
  • Submit this assignment on GitHub following the expectations in the syllabus on Assignment Submission.
  • To begin, read this README based on the Proactive Programmers' project instructions
  • This project has been adapted from Proactive Programmers' material, thus discrepancies are possible.
  • Post to the #data-structures Discord channel for questions and clarifications.
  • For reference, check the starter repo
  • Modifications to the gatorgrade.yml file are not permitted without explicit instruction.

Learning Objectives

The learning objectives of this assignment are to:

  1. Read in data from a CSV file
  2. Define a class with multiple attributes and methods
  3. Implement code to store data objects
  4. Implement code to retrieve and format requested data
  5. Demonstrate professional skills in testing and linting
  6. Write clearly about the programming concepts in this assignment.

Seeking Assistance

Please review the course expectations on the syllabus about Seeking Assistance. Students are reminded to uphold the Honor Code. Cloning the assignment repository is a commitment to the latter.

For this assignment, you may use class materials, textbooks, notes, and the internet. Ensure that your writing is original and based on your own understanding of the concepts.

To claim that work is your own, it is essential to craft the logic and the writing together without copying or using the logical structure of another source. The honor code holds everyone to this standard.

If outside of lab you have questions, the #data-structures Discord channel, TL office hours, instructor office hours, and GitHub Issues can be utilized.

Project Details (Project Overview Below)

This engineering effort invites you to implement and use a program called objectprocessor that searches a large data structure for objects that have certain patterns. The objectprocessor works by reading in a text file in a comma-separate value (CSV) format that contains raw data about a person on each row of the file. Next, the program converts each row of data into an instance of the Person class, stores that instance inside of a List, and then performs one of several configurable searches for instances of Person that match the constraints specified on the command-line of the objectprocessor. Finally, the program will save all of the matching rows of data in a specified file. In addition to implementing the functions that perform the file input and output and the searching for matching Persons in the List, you will use a comprehensive command-line interface, implemented with Typer, that allows you to easily confirm the files for input and output and the terms for the query for matching people.

Raw Data

The raw data in the input file correspond to information about fake people, organized in the following fashion.

Cindy Burns,Dominican Republic,(102)481-3875,"Pharmacist, hospital",[email protected]
Jason Bailey,Falkland Islands (Malvinas),+1-552-912-2326,Leisure centre manager,[email protected]
Andrew Johnson,Portugal,733-554-3949,"Engineer, site",[email protected]
Carol Poole,Isle of Man,365.529.7270,Pensions consultant,[email protected]
Riley Gonzalez,Libyan Arab Jamahiriya,7752827092,Materials engineer,[email protected]

It is worth noting that all of the data in the input file is automatically generated by a tool that uses the Faker library and is thus synthetic in nature.

Expected Output

After you finish a correct implementation of all the objectprocessor's features you can run it with the command poetry run objectprocessor --search-term tylera --attribute email --input-file input/people.txt --output-file output/people.txt and see that it produces output like the following.

🧮 Reading in the data from the specified file input/people.txt

🚀 Parsing the data file and transforming it into people objects

🕵  Searching for the people with an email that matches the search term
'tylera'

✨ Here are the matching people:

- Debra Williams is a Retail merchandiser who lives in Guadeloupe. You can
call this person at 407-035-6634 and email them at tyleranderson@example.com
- Christopher Lin is a Embryologist, clinical who lives in United Kingdom.
You can call this person at (515)580-8082x35082 and email them at
tyleranthony@example.com
- William Valdez is a Air broker who lives in Algeria. You can call this
person at 408.592.1306 and email them at tylerashley@example.net
- Joshua Chaney is a Water engineer who lives in San Marino. You can call
this person at 310.624.7694x64127 and email them at tylerallen@example.net

✨ Saving the matching people to the file output/people.txt

It is important to note that since objectprocessor is deterministic and not dependent on the performance characteristics of your computer, your implementation of the program should produce exactly the above output. The above invocation of the program looks for people with records that have an email address containing the search term tylera. After inputting the 50,000 records from the file called input/people.txt and converting each one to an object-oriented format, the program searches and ultimately determines that there are four people in the input file that match the search parameters.

Finally, don't forget that you can display objectprocessor's help menu and learn more about its features by typing poetry run objectprocessor --help to show the following output. It is worth noting that all of the parameters to the objectprocessor program, excepting those connected to completion of command-line arguments or the help menu, are required. This means that the objectprocessor will produce an error if you do not specify the four required parameters respectively related to the search term, the "attribute" of a person stored in a row of data (e.g., the email address or the country), and both the input file and the output file that will save the search results.

 Usage: objectprocessor [OPTIONS]

 Input data about a person and then analyze and save it.

╭─ Options ─────────────────────────────────────────────────────────────╮
│ *  --search-term               TEXT  [default: None] [required]       │
│ *  --attribute                 TEXT  [default: None] [required]       │
│ *  --input-file                PATH  [default: None] [required]       │
│ *  --output-file               PATH  [default: None] [required]       │
│    --install-completion              Install completion for the       │
│                                      current shell.                   │
│    --show-completion                 Show completion for the current  │
│                                      shell, to copy it or customize   │
│                                      the installation.                │
│    --help                            Show this message and exit.      │
╰───────────────────────────────────────────────────────────────────────╯

Please note that the provided source code does not contain all of the functionality to produce the output displayed in this section. As the next section explains, you should add the features needed to ensure that objectprocessor produces the expected output! Although you don't need to add any functionality to the person module, you will need to address all of the TODO markers in the process and main modules.

Adding Functionality

If you study the file objectprocessor/objectprocessor/process.py you will see that it has many TODO markers that designate the sorting algorithms that you must implement so as to ensure that objectprocessor will produce correct output. For instance, you will need to implement most of the steps in the def extract_person_data(data: str) -> List[person.Person] function that takes as input all of the text in the input CSV file and produces as output a List of instances of the Person class in the person module. You will also need to implement the functions that determine if a specific instance of Person matches the criteria specified on the program's command-line interface and those that perform the file input and output. Finally, you are invited to implement the functions in the main module that call the functions in process.

Once you complete a task associated with a TODO marker, make sure that you delete it and revise the prompt associated with the marker into a meaningful comment! After you revise all of the TODO markers your project should feature polished source code that is ready for contribution to an open-source project or described on your professional web site. Finally, you will notice that this project does not come with test cases. If you want to both establish a confidence in the correctness of and find defects in your program, then you will need to design, implement, and run your own tests using Pytest!

Running Checks

If you study the source code in the pyproject.toml file you will see that it includes the following section that specifies different executable tasks like ruff. If you are in the palindromechecker directory that contains the pyproject.toml file and the poetry.lock file, the tasks in this section make it easy to run commands like poetry run task ruff to automatically run the ruff linter designed to check the Python source code in your program and its test suite to confirm that your source code adheres to the industry-standard. You can also use the command poetry run task fix to automatically reformat the source code. poetry run task ruffdetails will print out detailed linting errors that point to exactly what ruff views as a linting error. Make sure to examine the pyproject.toml file for other convenient tasks that you can use to both check and improve your project!

Along with running tasks like poetry run task ruff, you can run the command gatorgrade --config config/gatorgrade.yml to check your work. If your work meets the baseline requirements and adheres to the best practices that proactive programmers adopt you will see that all the checks pass when you run gatorgrade. You can study the config/gatorgrade.yml file in your repository to learn how the :material-github: GatorGrade program runs :material-github: GatorGrader to automatically check your program and technical writing.

Project Reflection

Once you have finished both of the previous technical tasks, you can use a text editor to answer all of the questions in the writing/reflection.md file. For instance, you should provide the output of the Python program in several fenced code blocks, explain the meaning of the Python source code segments that you implemented, and answer all of the other questions about your experiences in completing this project. A specific goal for this project's reflection is to ensure that you can explain Python source code written in an object-oriented fashion and discuss the trade-offs associated with this approach. For instance, you should understand how the following constructor, implemented in the __init__ method, is used to create a new instance of the Person class.

def __init__(
    self, name: str, country: str, phone_number: str, job: str, email: str
) -> None:
    """Define the constructor for a person."""
    self.name = name
    self.country = country
    self.phone_number = phone_number
    self.job = job
    self.email = email

Project Assessment

Since this project is an engineering effort, it is aligned with the evaluating and creating levels of Bloom's taxonomy. You can learn more about how a proactive programming expert will assess your work by examining the assessment strategy. From the start to the end of this project you may make an unlimited number of reattempts at submitting source code and technical writing that meet all aspects of the project's specification.

Project Overview

After cloning this repository to your computer, please take the following steps:

  • Use the cd command to change into the directory for this repository.
  • Specifically, you can change into the program directory by typing cd objectprocessor.
  • Install the dependencies for the project by typing poetry install.
  • Run the program with its different configurations by typing:
    • poetry run objectprocessor --search-term john79 --attribute email --input-file input/people.txt --output-file output/people.txt
    • Please note that the program will not work unless you add the required source code
    • You should run the program in many different configurations so as to ensure it is working correctly
  • Confirm that the program is producing the expected output described above
  • Run the automated grading checks by typing gatorgrade --config config/gatorgrade.yml.
  • You may also review the output from running GatorGrader in GitHub Actions.
  • Don't forget to provide all of the required responses to the technical writing prompts in the writing/reflection.md file.
  • Please make sure that you completely delete the TODO markers and their labels from all of the provided source code.
  • Please make sure that you also completely delete the TODO markers and their labels from every line of the writing/reflection.md file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages