Working with Projects
How Projects work
Understanding the Project Class
The Project class is a fundamental component of the Kodexa SDK, representing a container for your data extraction and processing tasks. Here’s the definition of the Project class:
Let’s break down the key attributes of the Project class:
id
: A unique identifier for the project.organization
: The organization to which the project belongs.name
: The name of the project.description
: A brief description of the project.metadata
: Additional metadata associated with the project.has_image
: Indicates whether the project has an associated image.status
: The current status of the project.owner
: The user who owns the project.options
: Additional options for the project.
The Project class uses Pydantic’s BaseModel, which provides data validation and settings management. The model_config
settings enable features like populating by field name, using enum values, and allowing arbitrary types.
Now that we understand the structure of a Project, let’s proceed with creating a project and loading a taxonomy.
Step 1: Initialize the Kodexa Client and Organization
First, you need to have a Kodexa client and an organization endpoint:
Step 2: Create the Project
Next, create a new Project object with a name and description:
Here, we’re initializing a Project object with the name and description we’ve specified. The organization.detach()
method is used to ensure we’re working with a detached copy of the organization object.
Step 3: Create the Project Using a Template
Use the Kodexa client to create the project based on a template:
This step uses the Kodexa client to create the project on the Kodexa platform, using the specified template as a starting point.
Step 4: Load a Local Taxonomy (Optional)
If you have a local taxonomy file, you can load it and update the project’s taxonomy:
This code block loads a local taxonomy file (if specified), creates a TaxonomyEndpoint object, and updates the project’s existing taxonomy with the loaded taxons.
Putting It All Together
Here’s the complete code that combines all these steps:
By following these steps, you can create a new project based on a template and optionally load a custom taxonomy from a local YAML file. This approach allows you to quickly set up projects with custom configurations and taxonomies, streamlining your workflow with the Kodexa SDK.
Remember to replace the placeholder values (like the client initialization and organization endpoint) with your actual Kodexa account details. Also, ensure you have the necessary permissions to create projects and modify taxonomies in your Kodexa environment.