Metadata-Version: 2.3
Name: cosapp-creator
Version: 0.1.0
Summary: A Django app providing Rest APIs to create CosApp system.
Author: Virginie Zell
License: Copyright (C) 2023-2024 Safran SA - All Rights Reserved
        
        CoSApp Open Source License:
        
        Licensed under the Apache License, Version 2.0 (the "License");
        you may not use this software except in compliance with the License.
        You may obtain a copy of the License at
        
            http://www.apache.org/licenses/LICENSE-2.0
        
        Unless required by applicable law or agreed to in writing, software
        distributed under the License is distributed on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        See the License for the specific language governing permissions and
        limitations under the License.
License-File: AUTHORS.md
License-File: LICENSE
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: cosapp~=0.16
Requires-Dist: django
Requires-Dist: django-cors-headers
Requires-Dist: djangorestframework
Description-Content-Type: text/markdown

# CosApp Creator

`cosapp_creator` is a Django application providing a web interface to create CosApp systems.

### Installation

You can install `cosapp_creator` using `pip` or `conda`

```bash
# Using pip
pip install cosapp_creator
# Using conda
conda install -c conda-forge cosapp_creator
```

### Getting started

`cosapp_creator` provides the `cosapp-creator` command to interact with the web server.

- Before starting the application for the first time, you need to create the database:

```bash
cosapp-creator migrate
```

- To start the application in production mode, you need to have `gunicorn` installed:

```bash
# Start the web server at the default 8000 port
cosapp-creator start
```

`cosapp-creator` uses `gunicorn` to serve the Django application, any arguments after `start` will be passed to `gunicorn`. You can refer to `gunicorn` documentation for advanced configuration, for example, to start the application with 4 workers:

```bash
cosapp-creator start --workers 4
```

By default, the frontend will connect to the API server at `http://127.0.0.1:8000`, you can modify this URL by setting the variable `COSAPP_CREATOR_API` before starting up the server:

```bash
# Start the web server at a custom port
COSAPP_CREATOR_API=http://127.0.0.1:1234 cosapp-creator start -b 0.0.0.0:1234
```

- To start the application in development mode:

```bash
cosapp-creator runserver
```

- To show all available commands:

```bash
cosapp-creator -h
```

## Using the application

![alt text](images/CoSAppCreator.png 'CoSApp Creator')

### Import package

The first step in creating an assembly is to import a package. To do so, the "Import Package/Assembly" button must be clicked, and the JSON file describing the Python module must be imported. This file can be generated by the `parse_module` function in CoSApp.

### Use resulting code

Clicking on "Generate code" will display a frame containing the code to create the object class in the graph.
To use it, this code needs to be executed in a Python environment in which the modules used by the assembly are installed.
This code will create the class. To instantiate an object, `systemName = ClassName('systemName')` has to be added after the code for the class.

```Python
# Code generated by CoSApp Creator
from cosapp.base import System
import module

class Assembly(System):
    def setup(self):
        self.add_child(module.SystemClass('sys1'))
        self.add_child(module.SystemClass('sys2'))

    def compute(self):
        pass

# Instanciate object
assembly = Assembly('assembly')
```

### Change assembly or child system names

In order to change the name of the assembly or the name of any child system, the old name must be double-clicked. An input field will appear, and it will be possible to write a new name. To confirm it, it is possible to click "Enter" or to just click outside of the field.

![alt text](images/RenameChild.png 'Rename child system')

### Get details on ports

A description of a port in a child system will be shown by hovering over it with the mouse. If more details are needed, it is possible to click on the port, and a more detailed description will be shown.

Port description before clicking :

![alt text](images/PortDesc.png 'Port Description')

Port description after click :

![alt text](images/DetailledPortDesc.png 'Detailled Port Description')

### Kwargs

It is possible to change the value of each kwargs in a system by right-clicking this system. However, if the value of a kwarg changes the structure of a system, this change will ne be reflected in CoSApp Creator, and it may cause bugs.

![alt text](images/ChangeKwargs.png 'Change kwargs')

### Pullings

The assembly inputs and outputs are represented by these two nodes.

![alt text](images/ParentPorts.png 'Assembly ports')

New pullings are created by linking any port from a child system to the white symbol.

It is also possible to link two children inputs to one parent input, by linking one parent port to two children.

![alt text](images/Pulling.png 'Two children with the sane pulling')

### Loops and mathematical problem

Each system's mathematical problem, if it exists, can be viewed by hovering over its sigma symbol.
