semvec/pypi-packages huggingface dataset:
CosmoTech-SupplyChain 6.4.1
A support package for Cosmotech SupplyChain

# Supplychain Python Library


![Linter](https://github.com/Cosmo-Tech/supplychain-python-library/actions/workflows/linter.yml/badge.svg)
![Tests](https://github.com/Cosmo-Tech/supplychain-python-library/actions/workflows/tests.yml/badge.svg)

This library was made to have an accessible way to use the supplychain python code


# Getting Started

```bash
git clone https://github.com/Cosmo-Tech/supplychain-python-library
pip install -e supplychain-python-library
```

## Code structure

```bash
.	
├── LICENSE	
├── README.md	
├── setup.py                                         # Python library setup file
├── Supplychain	
│   ├── Generic	                                     # Generic components and helpers
│   │   ├── adt_writer.py 
│   │   ├── adx_and_file_writer.py
│   │   ├── ...

│   ├── Protocol	                                 # Optimization protocol and CMAES implementation
│   │   ├── cmaes_optimization_algorithm.py	
│   │   ├── ...
│   │   ├── README.md	
│   ├── Run	                                         # Callable entry points for handlers
│   │   ├── cmaes_optimization.py                    # CMAES optimization run entry point
│   │   ├── simulation.py                            # single simulation entry point
│   │   └── uncertainty_analysis.py                  # uncertainty analysis entry point
│   ├── Schema                                       # describes the domain model
│   │   ├── adt_column_description.py                # defines the domain schema
│   │   ├── default_values.py                        # domain model default values definition
│   │   ├── simulator_files_description.py           # simulator files definition
│   │   └── validation_schemas.py                    # defines the domain model (json definition) : schema and graph relationships
│   ├── Transform	
│   │   ├── complete_dict.py                         # apply default values to the domain model 
│   │   ├── from_dict_to_simulator.py                # transforms domain model data to simulator model 
│   │   ├── from_dict_to_table.py                    # transforms domain model to tabular data to be stored in database ( and transfoms time step based values stored as map to tabular values)
│   │   ├── from_table_to_dict_old.py                # obsolete
│   │   ├── from_table_to_dict.py                    # obsolete
│   │   ├── patch_dict_with_parameters.py            # apply parameters to domain model
│   │   ├── production_route.py                      # compute the production routes based on the graph for the differents products (to be sent to adx by the prerun step)
│   │   └── requirements.txt	
│   ├── Validate                                     # domain model validator definition
│   │   └── validate_dict.py                         # validates the data against the domain schema and graph
│   └── Wrappers	
│       ├── environment_variables.py                 # wrapper for platform environment variables
│       └── simulator.py                             # cosml model wrapper
└── Tests	
└── test.py	
```
drf-lookup 1.0.1
Helper for retrieve select options of drf fields and django-filter filters.
Requires Python: >=3.10
Keywords: django-filter, drf

# Drf-lookup

![PyPI - Version](https://img.shields.io/pypi/v/drf-lookup?logo=python)
![Tests](https://github.com/kindlycat/drf-lookup/actions/workflows/tests.yml/badge.svg)
[![Codecov](https://codecov.io/gh/kindlycat/drf-lookup/graph/badge.svg?token=J6wGdU9YH6)](https://codecov.io/gh/kindlycat/drf-lookup)

Drf-lookup helps you retrieve options for serializer fields and django-filter
filters. It adds additional actions to the viewset, checks the ``queryset`` and
``choices`` attributes and returns valid values for the requested field/filter. 
This is useful when you are retrieving parameters asynchronously and don't need 
to create a view for each case.

## Install

```bash
pip install drf-lookup
```

## Example

```python

# models
from django.db import models

class Category(models.Model):
    name = models.CharField(max_length=100, db_index=True)
    is_public = models.BooleanField(default=True)

    class Meta:
        verbose_name = 'category'
        verbose_name_plural = 'categories'
        ordering = ['name']

    def __str__(self) -> str:
        return self.name


class Article(models.Model):
    title = models.CharField(max_length=100, db_index=True)
    category = models.ForeignKey(Category, on_delete=models.CASCADE, null=True)

    class Meta:
        verbose_name = 'news'
        verbose_name_plural = 'news'
        ordering = ['-pk']

    def __str__(self) -> str:
        return self.title


# Create some objects
category = Category.objects.create(name='Category 1')
Category.objects.create(name='Category 2', is_public=False)
Category.objects.create(name='Category 3')
Article.objects.create(title='Test title', category=category)


# serializers
from rest_framework.serializers import ModelSerializer

class ArticleSerializer(ModelSerializer):
    class Meta:
        model = Article
        fields = ('id', 'title', 'category')

        # Limit categories by the `is_public` attribute
        extra_kwargs = {
            'category': {'queryset': Category.objects.filter(is_public=True)},
        }

# filters
import django_filters

class ArticleFilterSet(django_filters.FilterSet):
    class Meta:
        model = Article
        fields = ('category',)


# views
from rest_framework.viewsets import ModelViewSet

from drf_lookup.views import LookupMixin


class ArticleViewSet(LookupMixin, ModelViewSet):
    queryset = Article.objects.all()
    serializer_class = ArticleSerializer
    filterset_class = ArticleFilterSet
```

Now, it's possible to retrieve valid options for the serializer's `category` field.

```jsonc
// GET /api/articles/lookup_serializer/?lookup_action=create&lookup_field=category
// Only public categories will be returned

[
  {
    "id": 1,
    "name": "Category 1"
  },
  {
    "id": 3,
    "name": "Category 3"
  }
]
```

And for the filter's `category` field.
```jsonc
// GET /api/articles/lookup_filter/?lookup_action=list&lookup_field=category
// Only categories specified in articles will be returned

[
  {
    "id": 1,
    "name": "Category 1"
  },
]
```