argos-arpa 0.3.4

A pulsar data archive for the ARGOS project (https://argos-telescope.eu/).
![logo](logo_cnbg.png)
# `arpa` - a package for pulsar science in ARGOS
[![GitHub license](https://img.shields.io/badge/license-MIT-blue)](#license)
[![Crates.io Version](https://img.shields.io/crates/v/argos-arpa)](https://crates.io/crates/argos-arpa)
[![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com/SGullin/arpa)
[![docs](https://img.shields.io/docsrs/argos-arpa?logo=rust&style)](https://docs.rs/argos-arpa/latest/)

*This is still under development.*

Keeps track of TOAs and related things. This is mostly based off of [TOASTER](https://github.com/plazar/TOASTER) by Patrick Lazarus.

Most informations are split into data and metadata, e.g. `toa` and `toa_meta`. Parfiles and raw files are kept as files somewhere, and so only metadata is put in the DB.

## Setup
Add the library as such:
```
cargo add argos-arpa
```
Alternatively, fork either this repo or the [GUI](#gui).

To get started, you need to have a folder of `sql` files creating the tables you reference in the rust code, and a config `.toml` file. Both of their paths need to be given to `Archivist`'s constructor.

### SQL
This crate uses PostgreSQL, which means that you need to have such a DB to connect to if you want to use `arpa`. For testing on MacOS, there is e.g. https://postgresapp.com.

## Usage
### Running the pipeline
There is a `Pipeline` struct that you'll want to use. It is expected to change internally, but the interface should remain very similar. 

First, you create a `PipelineSettings` object, e.g.:
```rust
let settings = PipelineSettings::from_file("pipeline.toml")
.unwrap_or_else(|_| PipelineSettings::default());
```
Then you create a `Pipeline` object with your input data and settings, and call `run` with an `Archivist` and a status callback function.
```rust
let mut pipeline = Pipeline::setup(
    raw_file, 
    template,
    ephemeride, 
    settings,
);
pipeline.run(
    &mut archivist, 
    |status: Status| log::info!("{status}"),
).await?;
```

### Debugging
`arpa` makes frequent use of the [`log` crate]https://crates.io/crates/log, and so it is suggested to use [`env_logger`]https://crates.io/crates/env_logger or similar to debug.
`sqlx` does so too, so be vary of the sheer amount of `debug` level logs you may face (e.g. one per query) if you're not selectively setting the level.

### New tables
If you fork this and want to add more tables, the [derive macro](https://github.com/SGullin/arpa-item-macro) might come in handy. The only necessities is that 
 1) the struct contains a field `id: i32`; and
 2) you add a new entry in the `Table` enum. 

In the future, support will be added for custom tables without forking.

## GUI
There is a GUI application being developed for internal use, publicly available at https://github.com/SGullin/arpa-gui.

# License
`argos-arpa` is distributed under the terms of the [MIT License](LICENSE-MIT).

The ARGOS logo belongs to the ARGOS Consortium.