Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no Python library for chapter 11 and chapter 15. #413

Open
nitinkhandelwal26 opened this issue Jun 25, 2024 · 9 comments
Open

There is no Python library for chapter 11 and chapter 15. #413

nitinkhandelwal26 opened this issue Jun 25, 2024 · 9 comments
Assignees

Comments

@nitinkhandelwal26
Copy link

Describe the bug
There is no python library exists for both chapter 11 and 15.

Additional context
These library require to understand implementation and learning.

Copy link

👋 Thanks for contributing @nitinkhandelwal26! We will review the issue and get back to you soon.

@koreyspace
Copy link
Collaborator

Thanks for reporting, will look into this!

@taitaitai1777
Copy link

Step 1: Understanding the Missing Content

  1. Read Chapters 11 and 15 Thoroughly:

    • Objective: Identify all the concepts, algorithms, and code references mentioned.
    • Action: Make detailed notes of the techniques and examples that require Python libraries.
  2. Identify Specific Requirements:

    • Objective: Pinpoint the exact libraries and code examples that are missing.
    • Action: Create a checklist of functions, classes, and modules that need to be implemented or located.

Step 2: Gather Necessary Tools and Resources

  1. Research Existing Python Libraries:

    • Objective: Find libraries that match the concepts discussed in the chapters.
    • Action: Evaluate libraries using criteria such as:
      • Documentation quality
      • Community support and activity on platforms like GitHub
      • Suitability for the requirements (e.g., specific functions, performance)
  2. Prepare Development Environment:

    • Objective: Set up a robust environment to write, test, and document your code.
    • Action:
      • Install Python and necessary tools like Jupyter notebooks.
      • Use a virtual environment:
        python -m venv venv
        source venv/bin/activate  # On Linux/Mac
        .\venv\Scripts\activate   # On Windows
      • Install required libraries:
        pip install numpy pandas matplotlib scikit-learn

Step 3: Develop or Locate Code Examples

  1. Write Incremental Code Samples:

    • Objective: Develop code that aligns closely with the chapter content.
    • Action: Start with small, manageable snippets and gradually build them into comprehensive examples.
  2. Document Each Step:

    • Objective: Ensure the code is easy to understand and follow.
    • Action: Use comments extensively and Markdown for detailed explanations.
      import numpy as np
      
      def advanced_algorithm(data):
          """
          Function to demonstrate advanced techniques.
          Args:
          data (np.array): Input data for the algorithm.
      
          Returns:
          np.array: Processed data.
          """
          # Example transformation
          processed_data = data ** 2
          return processed_data
      
      # Sample data
      sample_data = np.array([1, 2, 3, 4])
      result = advanced_algorithm(sample_data)
      print(result)
  3. Testing and Debugging:

    • Objective: Ensure the examples are functional and reliable.
    • Action: Conduct smoke testing on various data sets and scenarios.
      sample_data_1 = np.array([1, 2, 3, 4])
      sample_data_2 = np.array([-1, 0, 1])
      print(advanced_algorithm(sample_data_1))  # Expected: [1, 4, 9, 16]
      print(advanced_algorithm(sample_data_2))  # Expected: [1, 0, 1]

Step 4: Integrate with Documentation

  1. Update Repository Structure:

    • Objective: Organize the new content systematically.
    • Action: Create directories for chapters 11 and 15, if they do not exist.
      mkdir chapter11
      mkdir chapter15
  2. Link Code to Chapters:

    • Objective: Ensure documentation and examples are seamlessly integrated.

    • Action: Update README files and include instructions for running the examples.

      ## Chapter 11: Advanced Techniques
      
      ### Example Code
      ```python
      # Place relevant code here

      Instructions

      1. Clone the repository.
      2. Navigate to the chapter directory.
      3. Run the example script:
        python example_script.py
      
      

Step 5: Review and Test

  1. Peer Review:

    • Objective: Obtain feedback from colleagues or other contributors.
    • Action: Share the code and documentation for review. Incorporate feedback to improve clarity and functionality.
  2. Comprehensive Testing:

    • Objective: Validate the robustness of the examples.
    • Action: Conduct intensive testing on different scenarios and edge cases to cover all aspects of the chapters.

Step 6: Submit Pull Request (PR)

  1. Create a Pull Request:

    • Objective: Share your updates with the main project.
    • Action:
      • Create a new branch:
        git checkout -b add-missing-libraries
      • Commit changes:
        git add .
        git commit -m "Add missing Python libraries for chapters 11 and 15"
  2. Draft Detailed Pull Request:

    • Objective: Provide context and clarity on the changes made.
    • Action:
      • Open a pull request from your branch.
      • Write a comprehensive description referencing issue There is no Python library for chapter 11 and chapter 15.  #413.
      • Outline key changes, code examples, and any areas needing attention.
        ## Pull Request: Add Missing Libraries for Chapters 11 and 15
        
        This PR addresses issue #413 by adding the necessary Python libraries and code examples for chapters 11 and 15.
        
        ### Key Changes:
        - Implemented advanced techniques in chapter 11.
        - Developed specific use cases in chapter 15.
        
        ### Testing:
        - Conducted thorough testing on sample datasets.
        - Peer-reviewed for code quality and clarity.
        
        Please review and provide feedback.
  3. Engage with Reviewers:

    • Objective: Ensure a smooth review process.
    • Action: Respond to comments, address concerns, and make necessary revisions. Once approved, merge the PR.

By iteratively refining and enhancing each step, you ensure that your approach is not only thorough but also aligns well with best practices in software development and documentation.

@Abhijitk914
Copy link

Hi @koreyspace ,

We are going through the chapter 11 and wanted to try sample code provided by you. But this code uses BING maps URL.

We were trying to create new BING maps account but it's not allowing to create new account. Do you have any other option or example code where we can use another API for hands on for this "Function calling" Ai feature?

image

@koreyspace
Copy link
Collaborator

Hey @Abhijitk914 - can you explain a bit more of when you need the Bing Maps API when running the code? The code should only be using the Microsoft API - url = "https://learn.microsoft.com/api/catalog/"

@taitaitai1777
Copy link

7-Word Title:

Access Microsoft API Data Efficiently and Easily

77-Word Summary:

This Python script demonstrates how to retrieve data from the Microsoft API using the requests library. It sends a GET request to a specified URL, checks the response status, and parses the data if the request is successful. The script is designed to be beginner-friendly with clear and straightforward steps, making it accessible for anyone new to programming. By following this guide, you can effortlessly fetch and display data from Microsoft's API.

Enhanced Code:

import requests
import json

# Define the API URL
url = "https://learn.microsoft.com/api/catalog/"

# Send the GET request
response = requests.get(url)

# Check the response status code
if response.status_code == 200:
    print("Request was successful!")
    
    # Parse and print the JSON data
    data = response.json()  # Parse JSON data from the response
    print(json.dumps(data, indent=4))  # Pretty-print the JSON data for readability
else:
    print(f"Request failed with status code: {response.status_code}")

# Explanation:
# 1. Import Modules: Import the necessary libraries for making HTTP requests and handling JSON data.
# 2. Define URL: Specify the endpoint for the Microsoft API.
# 3. Send Request: Use the `requests.get()` method to retrieve data from the API.
# 4. Check Status: Ensure the request was successful by checking the status code (200).
# 5. Parse Data: If successful, parse the JSON data from the response.
# 6. Print Data: Display the parsed JSON data in a readable format.

Detailed Steps:

  1. Import Modules:

    • The requests module is used for making HTTP requests.
    • The json module is used for parsing and printing JSON data.
  2. Define the API URL:

    • Specify the endpoint URL for the Microsoft API (https://learn.microsoft.com/api/catalog/).
  3. Send the GET Request:

    • Use the requests.get(url) method to send a GET request to the specified URL.
  4. Check the Response Status Code:

    • The response.status_code property is checked to ensure the request was successful (status code 200).
  5. Parse and Print the JSON Data:

    • If the request was successful, the response.JSON() method parses the JSON data from the HTTP response.
    • The json.dumps(data, indent=4) method pretty-prints the JSON data to make it more readable.

Recap:

By following these detailed steps and using the provided code, you can efficiently and easily access and display data from the Microsoft API. This guide is designed to be beginner-friendly, ensuring that even those new to programming can understand and implement it.

@Abhijitk914
Copy link

Hey @Abhijitk914 - can you explain a bit more of when you need the Bing Maps API when running the code? The code should only be using the Microsoft API - url = "https://learn.microsoft.com/api/catalog/"

Hi @koreyspace , I am referring the chapter 11 sample code provided in git. Here code is trying to fetch this details from env file.

const bingMapsBaseUrl = process.env.BING_MAPS_BASE_URL || "";
const bingApiKey = process.env.BING_API_KEY || "";

image

To use / try this code we need BING MAPS BASE URL and BING API KEY. Issue is we cant do new registration with BING now. so can you help us with this issue ?

@taitaitai1777
Copy link

Title: Transition from Bing Maps to Google Maps API


Summary:

Transitioning from Bing Maps API to Google Maps API involves choosing an alternative service due to new registration issues with Bing. Follow detailed steps to install necessary packages, update environment variables, and modify code for seamless integration with Google Maps. Utilize existing keys, explore free/open data alternatives, and seek support if needed. This ensures continued functionality of your application’s geolocation features despite Bing API limitations.


Step-by-Step Guide:

1. Choose an Alternative Service:

  • Google Maps API: Comprehensive and widely used; requires API key.
  • OpenStreetMap (via Mapbox): Free, open-source, highly versatile.
  • Here Maps: Robust, significant free tier.
  • MapQuest: Reliable alternative, offers free tier.

2. Install Necessary Packages:

For Google Maps, install the required npm package:

npm install @googlemaps/google-maps-services-js

3. Update Environment Variables:

Create or update your .env file with the following:

GOOGLE_MAPS_BASE_URL=https://maps.googleapis.com/maps/api
GOOGLE_API_KEY=your_google_maps_api_key_here

4. Modify Your Code:

Update your code to integrate Google Maps API. Here is an example:

require('dotenv').config();
const { Client } = require("@googlemaps/google-maps-services-js");

const googleMapsBaseUrl = process.env.GOOGLE_MAPS_BASE_URL || "https://maps.googleapis.com/maps/api";
const googleApiKey = process.env.GOOGLE_API_KEY || "";

const client = new Client({});

async function getGeocode(address) {
    try {
        const response = await client.geocode({
            params: {
                address: address,
                key: googleApiKey
            },
            baseUrl: googleMapsBaseUrl
        });
        console.log(response.data.results);
        return response.data.results;
    } catch (e) {
        console.error("Error fetching data from Google Maps API:", e);
    }
}

// Example usage:
getGeocode("1600 Amphitheatre Parkway, Mountain View, CA");

5. Testing:

  • Ensure your environment variables are loaded correctly.
  • Run the updated code to fetch geolocation data and verify its correctness.

6. Utilize Existing Keys:

If you have any existing Bing Maps API keys, check their validity and use them if still functional.

7. Explore Free/Open Data Alternatives:

Consider services like OpenStreetMap for free and open geolocation data which can be integrated using tools like Mapbox.

8. Seek Support If Required:

  • Contact Microsoft support if a business or enterprise account might provide alternative solutions.
  • Check forums and community support for similar transition issues experienced by other developers.

Following these steps ensures a seamless transition from Bing Maps API to a new service, maintaining the geolocation capabilities of your application without interruption.

@koreyspace
Copy link
Collaborator

Ah I see now, I was looking at the Python example. Thanks @Abhijitk914 for the detail!

Pinging @glaucia86 who is the creator of the TS sample. Is there an alternative the the Bing Maps API or a way people can get access? Seems like the permissions have changed since creating the lesson.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants