Skip to main content

LangTrace - Trace Attributes

Project description

LangTrace - Trace Attributes

This repository hosts the JSON schema definitions and the generated model code for both Python and TypeScript. It's designed to streamline the development process across different programming languages, ensuring consistency in data structure and validation logic. The repository includes tools for automatically generating model code from JSON schema definitions, simplifying the task of keeping model implementations synchronized with schema changes.

Repository Structure

/
├── schemas/                      # JSON schema definitions
│   └── openai_span_attributes.json
├── scripts/                      # Shell scripts for model generation
│   └── generate_python.sh
├── generated/                    # Generated model code
│   ├── python/                   # Python models
│   └── typescript/               # TypeScript interfaces
├── package.json
├── requirements.txt
├── README.md
└── .gitignore

Prerequisites

Before you begin, make sure you have the following installed on your system:

  • Node.js and npm
  • Python and pip
  • ts-node for running TypeScript scripts directly (install globally via npm install -g ts-node)
  • datamodel-code-generator for Python model generation (install via pip install datamodel-code-generator)

Generating Models

Python Models

To generate Python models from a JSON schema, use the generate_python.sh script located in the scripts directory. This script takes the path to a JSON schema file as an argument and generates a Python model in the generated/python directory.

./scripts/generate_python.sh schemas/openai_span_attributes.json

TypeScript Interfaces

To generate TypeScript interfaces from a JSON schema, use the schema_to_interface.ts script located in the src/models directory. This script also takes the path to a JSON schema file as an argument and generates a TypeScript interface in the generated/typescript directory. t

ts-node scripts/generate_typescript.ts schemas/langtrace_span_attributes.json
ts-node scripts/generate_typescript.ts schemas/openai_span_attributes.json

To include instructions for building and uploading your Python package to PyPI, as well as how to automate this process using GitHub Actions, you can update your README.md file with the following sections:


Building and Uploading Your Package to PyPI

This guide provides instructions on how to manually build your Python package and upload it to the Python Package Index (PyPI), as well as how to automate this process using GitHub Actions.

Manual Upload to PyPI

To manually upload your package to PyPI, follow these steps:

Prerequisites

Ensure you have the latest versions of setuptools, wheel, and twine installed:

pip install --upgrade setuptools wheel twine

Building Your Package

Navigate to your project root (where setup.py is located) and run:

python setup.py sdist bdist_wheel

This command generates distribution archives in the dist/ directory.

Uploading Your Package

To upload your package to PyPI, use twine:

twine upload dist/*

You'll be prompted for your PyPI username and password. For token-based authentication, your username is __token__, and your password is the PyPI token.

Generating a PyPI Token

  1. Log in to your PyPI account.
  2. Navigate to Account Settings > API tokens > Add API token.
  3. Follow the prompts to generate a new token.
  4. Use this token with twine for uploading your package.

To update your README.md with instructions for building and publishing your TypeScript library to npm, you can include the following sections:


Building and Publishing to npm

This guide outlines the steps to build your TypeScript library and publish it to the npm registry, making it available for installation and use in other projects.

Prerequisites

Before you begin, ensure you have:

  • Node.js and npm installed. Download here.
  • An npm account. Sign up here if you don't have one.
  • Logged into npm in your command line. Run npm login and follow the prompts.

Building Your TypeScript Library

  1. Navigate to Your Project Directory where your package.json is located, typically src/typescript.

    cd src/typescript
    
  2. Install Dependencies if you haven't already:

    npm install
    
  3. Build Your Project to compile TypeScript files into JavaScript:

    npm run build
    

    This step assumes you have a "build" script in your package.json that runs the TypeScript compiler, typically "build": "tsc".

Publishing Your Package to npm

  1. Update the package.json to ensure it has the correct "name" (scoped if necessary, e.g., @langtrase/trace-attributes), "version", and other relevant information.

  2. Build Your Library as described in the previous section to ensure you have the latest compiled version.

  3. Publish Your Package:

    npm publish --access public
    

    The --access public flag is necessary if you're publishing a scoped package and want it to be publicly available.

  4. Verify that your package is now available on npm by visiting https://www.npmjs.com/package/@langtrase/trace-attributes (adjust the URL to match your package name).

Updating Your Package

If you make changes and wish to publish an updated version of your package:

  1. Make your changes and commit them to your repository.
  2. Update the "version" in your package.json following Semantic Versioning.
  3. Repeat the build and publish steps.

Contributing

Contributions are welcome! If you'd like to add a new schema or improve the existing model generation process, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or fix.
  3. Make your changes.
  4. Test your changes to ensure the generated models are correct.
  5. Submit a pull request with a clear description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


This README provides a comprehensive overview of the repository, including its purpose, structure, prerequisites for generating models, and guidelines for contributing. Adjust any paths, installation commands, or other details as necessary to fit your project's specific setup and requirements.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trace-attributes-1.0.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

trace_attributes-1.0.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file trace-attributes-1.0.2.tar.gz.

File metadata

  • Download URL: trace-attributes-1.0.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.6

File hashes

Hashes for trace-attributes-1.0.2.tar.gz
Algorithm Hash digest
SHA256 cc8ed59e453cdd2fac978fce692c73ca681b6fb9cfdb6fdfbc36e3ac8823f4a6
MD5 9a423a2565644feff074909b08afa2bd
BLAKE2b-256 c2b302413b16e6821927ddccf73867d919ad270561fa038eb444949ade531375

See more details on using hashes here.

File details

Details for the file trace_attributes-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for trace_attributes-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7994f8243204597054d3b515bc292e19a36e9e20a3015f57f6b3f5ea533247ee
MD5 e8a759a975b109620960c024db8d1adc
BLAKE2b-256 f8fef16b42866d18d2a03995c52541c65901e29f05390b0037caee57b2d8c949

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page