Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
latentvector committed Sep 6, 2024
1 parent 6f03899 commit 4a21591
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 129 deletions.
197 changes: 70 additions & 127 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,97 +12,50 @@ PLEASE REFER TO THE DOCS FOLDER FOR MORE INFO

[DOCS](./commune/docs)

### An Open Anything Network: Connect Anything You Want
Introduction to Commune

Commune is an open-source project that aims to create a network for connecting various developer tools. It's designed to be flexible and unopinionated, allowing developers to use it alongside their existing projects.

</div>
Key Features:
- Module Filesystem
- Subspace blockchain integration
- Flexible key management
- Pythonic CLI

Commune is a protocol that aims to connect all developer tools into one network, fostering a more shareable, reusable, and open economy. It follows an inclusive design philosophy that is based on being maximally unopinionated. This means that developers can leverage Commune as a versatile set of tools alongside their existing projects and have the freedom to incorporate additional tools they find valuable.
To get started, you can install Commune either locally or using Docker.

By embracing an unopinionated approach, Commune acknowledges the diverse needs and preferences of developers. It provides a flexible framework that allows developers to integrate specific tools seamlessly while avoiding imposing rigid structures or constraints. This adaptability enables developers to leverage Commune's capabilities in a manner that best aligns with their individual projects and workflows.

The overarching goal of Commune is to create a collaborative ecosystem where developers can easily share, connect, and extend their tools, ultimately fostering innovation and efficiency within the development community. By providing a network that encourages openness and accessibility, Commune empowers developers to leverage the collective knowledge and resources of the community to enhance their own projects.

# Install

You can install commune locally or run in docker. Commune is a python package and can be built from source for maximal control. We want you to define what you want to do with your code, and commune is here to help you do that.



### Setting Up Commune With Docker

Install Docker: If you don't have Docker installed on your system, download and install it from the official Docker website: [https://www.docker.com/get-started](https://www.docker.com/get-started).

Clone the Commune Repository: Open your terminal or command prompt and clone the Commune repository from GitHub:


Please cd into commune

```
cd commune
```
Start Commune: Once the Docker container is built, start Commune by running the following command:

```bash
make up
# or
docker-compose up -d # or make up
```
To enter the docker container do, and do the following

```bash
make enter
# or
docker exec -it commune bash
```

Then run the following command to sync the network

```bash
c ls
```

### Local Setup (Without Docker)
Installation

Local Installation:
```bash
apt-get install python3.10 python3-pip npm
npm install -g pm2
pip install -r requirements.txt
pip install -e .
```
or
```bash
./start.sh
```

To exit the container

Docker Installation:
```bash
exit
git clone https://github.com/commune-ai/commune.git
cd commune
make build
make start
make enter
```

Sync Commune with the Network: Inside the Docker container, run the following command to sync Commune with the network:

After installation, sync with the network:
```bash
c sync
c ls
```

Congratulations! Commune is now set up and running inside a Docker container.
Congratulations! Commune is now set up and running without Docker

## Note:

This repo is on the cutting edge of experimentation, so there may be some hiccups along the way. If you're primarily interested in using the core features of the protocol (such as intuitive cli) or seeking a more lightweight implementation, consider installing the [Communex](https://github.com/agicommies/communex) package.

# Key Features
Page 3: Module Filesystem

## Module Filesystem

The `module.py` file serves as an anchor, organizing future modules in what we call a module filesystem. The module filesystem is a mix of the commune's core modules with your local modules with respect to your PWD (parent working directory). This allows you to create a module in your local directory and have it be recognized by the commune. For instance if I have a file called `model.py` in my local directory, with the following code:
Commune organizes modules in a filesystem-like structure. You can create local modules that integrate seamlessly with Commune's core modules.

Example:
```python

import commune as c

class Example(c.Module):
def __init__(self):
pass
Expand All @@ -111,96 +64,86 @@ class Example(c.Module):
return x + 1
```

I can call it from the commune cli by running the following command:

You can call this module using:
```bash
c model/predict x=1
```
or
```python
c.call('model/predict', x=1)
```


## Subspace

![Example](https://drive.google.com/uc?export=view&id=1ZqCK-rBKF2p8KFr5DvuFcJaPXdMcISlT)

Subspace is a blockchain that Commune uses for several purposes:
Page 4: Subspace Integration

- **DNS for Python**: Decentralized Name Service for deployed objects.
- **Evaluating Performance through Voting**: Stake-weighted voting system for users to evaluate each other instead of self-reported networks. This provides users with
Commune uses the Subspace blockchain for:
- Decentralized Name Service (DNS) for deployed objects
- Stake-weighted voting system for performance evaluation

## Register On The Chain

To register a module, do the following

```python
c register {module_path} name={module_name (OPTIONAL)}
To register a module on the blockchain:
```bash
c register my_module_path name=my_module tag=1
```

The module path is specified
Page 5: Key Management

Yo, listen up! I'm about to drop some updated knowledge on how to create a dope module and register it on the blockchain. Here's the revised step-by-step guide:
Commune uses sr25519 keys for signing, encryption, and verification.

1. **Create Your Module**: Start by creating your own module in Python. It can be anything you want - a model, a service, or some sick functionality. Make sure your module is ready to rock and roll.

2. **Import Commune**: Import the Commune library into your Python code. You'll need it to create and register your module.

```python
import commune as c
To add a new key:
```bash
c add_key alice
```

3. **Define Your Module Class**: Create a class that represents your module. Make sure it inherits from `c.Module`.
To list keys:
```bash
c keys
```

To sign a message:
```python
class MyDopeModule(c.Module):
def __init__(self):
super().__init__()
# Your module initialization code goes here

def some_cool_function(self):
# Your module's cool functionality goes here
return "I'm bringing the heat!"
key = c.get_key("alice")
signature = key.sign("hello world")
```

4. **Register Your Module**: Now it's time to register your module on the blockchain. You have the option to specify a custom name and tag for your module. If you don't provide a custom name, the module will default to the module path. The tag is optional and can be used for versioning or categorization purposes.
Page 6: Pythonic CLI

To register your module with a custom name and tag, run the following command:
Commune provides a Pythonic CLI for easy interaction:

```bash
c register my_module_path name=my_module tag=1
c {module_name}/{function_name} *args **kwargs
```

Replace `my_module_path` with the actual path to your module file (without the class name), `my_module` with the desired name for your module, and `1` with the desired tag. This will register your module on the blockchain with the specified name and tag.

If you prefer to use the default module path as the name, simply omit the `name` parameter:

Example:
```bash
c register my_module_path tag=1
c ls ./
```

# Developement FAQ
This is equivalent to:
```python
import commune as c
c.ls('./')
```

- Where can i find futher documentation? This repository folder, [Doc](https://github.com/commune-ai/commune/tree/main/docs).
- Can I install on Windows? Yes, [Guide](https://github.com/OmnipotentLabs/communeaisetup).
- Can I contribute? Absolutely! We are open to all contributions. Please feel free to submit a pull request.
Page 7: Serving Modules

To serve a module:
```bash
c serve model.openai::tag
```

## Testing
To call a served module:
```python
c.call("model.openai::tag/forward", "sup")
```

To run the commune tests, do the following
Page 8: Testing

To run tests:
```bash
pytest commune/tests # or c test or make tests
```

The test is only one file, but it calls the test function for the core modules. This is because commune is a network of modules, and the core modules are the most important.

pytest commune/tests
```

## License :: MIT, but really IDGAF (I Don't Give A F*ck, its open source, why do we need a )
Page 9: Contributing

This project is licensed under both MIT but primarely under its own liscense (IDGAF). Do what you want with the code, dont pull up on me with some legal shit for building fam.
Contributions to Commune are welcome. Please submit pull requests on the GitHub repository.

Page 10: License

Commune is licensed under MIT, but with a "Do What You Want" philosophy. The project encourages open-source usage without strict legal restrictions.

This documentation provides a high-level overview of Commune. For more detailed information on specific features, please refer to the individual module documentation or the project's GitHub repository.
Loading

0 comments on commit 4a21591

Please sign in to comment.