Using Choreo’s VS Code Extension for Seamless Python Development

Nirhoshan
Choreo Tech Blog
Published in
6 min readAug 17, 2024

In today’s rapidly evolving development environment, speed and efficiency are key. Developers need a seamless process to move their applications from code to production quickly, without compromising on quality or performance. This is where Choreo, an innovative Internal Developer Platform as a Service, plays a transformative role.

In this article, we’ll guide you on how to use Choreo’s VS code extension to deploy a Python service in production in just five minutes. We will deploy a reading-books-list-service written in python in this article. Similar to a library management system, we can perform CRUD operations on the reading list service.

Introducing Choreo

Choreo is a versatile platform designed to streamline and accelerate the entire application development lifecycle. By merging development, operations, and observability into a single, cohesive platform, Choreo offers developers a powerful tool to deploy their applications swiftly and efficiently.

Why Opt for Choreo for Your Python Service?

Before we jump into the deployment process, here’s why Choreo is an ideal choice for Python developers:

  • Ease of Use: Choreo’s user-friendly interface and simplified workflows makes deployment a straightforward process.
  • Rapid Deployment: Deploy your services in a matter of minutes with Choreo, cutting down on the typical time required.
  • Seamless Scalability: As your application grows, Choreo ensures it continues to perform well, scaling effortlessly to meet demand.
  • All-in-One Platform: From version control to continuous integration and deployment, Choreo provides everything you need in one place.
  • Robust Security and Availability: With Choreo’s solid infrastructure, your application remains secure and reliably accessible to users.

Prerequisites

  1. Create an account in Choreo.
  2. Fork this repository, clone it and open it on VS code.
  3. Download the Choreo extension in your VS code.

Deploy your python service

  1. Create a Procfile in your root directory. A Procfile is a configuration file used to declare the commands that are run by your application’s containers.
web: gunicorn app:app - bind 0.0.0.0:5000

2. Select the Choreo VScode extension and click on the Sign In button to sign into Choreo.

3. Click on the Create Component button to create a component for your service.

4. This will prompt you to select your organization in Choreo.

5. You will then be prompted to create a new project.

6. Next, you will see an interface to create a component in your project. Specify the build configuration and the Endpoint configuration as shown in the image below.

Name: Library System Backend
Type: Service
BuildPack: Python
Port: 5000
Visibility: Public

7. This action will create a component-config.yaml file and place it in the .choreo directory in the root directory. This file is mandatory to expose the endpoints in Choreo. Commit and push this change to your repository.

apiVersion: core.choreo.dev/v1beta1
kind: ComponentConfig
spec:
# +optional Incoming connection details for the component (AKA endpoints).
inbound:
# +required Unique name for the endpoint. (This name will be used when generating the managed API)
- name: library-system-backend
# +required Numeric port value that gets exposed via the endpoint
port: 5000
# +required Type of traffic that the endpoint is accepting. For example: REST, GraphQL, etc.
# Allowed values: REST, GraphQL, GRPC, TCP, UDP.
type: REST
# +optional Network level visibility of the endpoint. Defaults to Public
# Accepted values: Project|Organization|Public.
networkVisibility: Public
# +optional Context (base path) of the API that gets exposed via the endpoint.
# This is mandatory if the endpoint type is set to REST or GraphQL.
context: /reading-list
# +optional The path to the schema definition file. Defaults to wildcard route if not specified.
# This is only applicable to REST endpoint types.
# The path should be relative to the Docker context.
schemaFilePath: openapi.yaml

8. After creating the component you will be given an interface to build your component and deploy the component to a specific environment as shown below.

9. Firstly, click on the Build Component button and select the commit ID with which we want to build. This action will take a few minutes. After the build is successful you can deploy the built image by clicking on the Deploy button next to the built image status. This will trigger the deployment to a specific environment you selected.

10. The image above shows that the python service has been deployed to the development environment. We can further observe the deployed service by inspecting the gateway logs and the application logs by clicking on View Runtime Logs. You can find the logs fetched and displayed in the terminal.

Application logs focus on the internal workings of a particular application, while gateway logs cover the interactions between clients and the backend services through the gateway.

Application logs: These logs capture the events and operations within an application or service. Application logs provide detailed insights into the application logic and user interactions

Gateway logs: These logs are generated by an API gateway or any network gateway in a system. A gateway serves as an entry point that manages and routes client requests to the appropriate backend services or microservices. Gateway logs are essential for monitoring traffic, enforcing security policies, analyzing API usage patterns, and ensuring that requests are correctly routed and handled by the appropriate services.

11. We can also test this service by clicking on Open Swagger View. This will take you to another tab where a test key will be generated and the resources will be listed. You can click on any resource and test your service.

You would have successfully performed all the stages in your python service development within a few minutes with the Choreo VScode extension. Depending on the outcome of the testing of the service or analysis of the runtime logs or build logs, if there are any problems occurring in the deployment (e.g. Mismatch in the environment variable names) we can simply make the changes in the code in VScode itself and push the changes to GitHub and rebuild and deploy the service. The development and debugging would be convenient as we can test out the service deployment and debug errors in the same IDE.

With Choreo’s VS Code extension, you can seamlessly manage the entire development lifecycle — from coding to deployment and debugging — all within a single, familiar environment, making it the ultimate tool for accelerating your Python service development.

--

--