Stream or send time-critical scientific data live and for free on the ATProtocol.
Project description
nebra
Stream or send time-critical scientific data live and for free on the ATProtocol, with a simple, fast Python module.
[!WARNING]
This package is in early development, and may have breaking changes in the near future. We do not (yet) recommend using it for production science.
Below is a minimal readme for the basic features of the package; more docs to come later!
Installation
nebra is on PyPI; you can install it with
pip install nebra
How to use
nebra can be used as a CLI (command line interface) tool or directly through Python.
Streaming data
nebra can stream any type of record in real-time. This uses jetstream, a lightweight add-on to data streaming on AT Protocol that allows you to filter by type of data,
After installing nebra into your virtual environment, you can check out its data streaming with a command like
python -m nebra stream --collection=eco.astrosky.transient.* --handle=transient-xposter.astrosky.eco
which will output all transient-type records maintained by The Astrosky Ecosystem and posted by our transient crossposting account, transient-xposter.astrosky.eco, to your console. You can view the kinds of records this will stream with a tool like pdsls.
Alternatively, you can use nebra within Python. The above command can be replicated with
import nebra
nebra.stream(
collections=["eco.astrosky.transient.*"],
handles=["transient-xposter.astrosky.eco"],
)
nebra can stream any type of record on the AT Protocol. For instance, viewing Matadisco open data records in real time is as easy as
nebra.stream(collections=["cx.vmx.matadisco"])
More functionality, including cursor saving, error recovery, and callback functions will be added in due course.
Sending data
Sending data is currently not possible with the CLI. Nevertheless, it's easy!
The main thing to make sure of is that your data conforms to the schema of the data you want to send. All data on ATProtocol obeys a lexicon definition. For instance, The Astrosky Ecosystem reposts NASA General Coordinates Network events on AT Protocol, for which we have a schema definition eco.astrosky.transient.gcn (view docs). Alternatively, publishing a Matadisco record would require conforming to the cx.vmx.matadisco schema (view docs).
Once you have an idea of the schema, you will need an AT Protocol account. The most common kind is just a Bluesky account, which you may already have. Set the following environment variables before running nebra:
NEBRA_HANDLE: your account's handle. E.g.:example.bsky.socialNEBRA_PASSWORD: an app password for your account. You may also use your real password (not recommended!)NEBRA_BASE_URL(optional): the base URL of your account. For accounts hosted on non-Bluesky servers, this will be the server address of your personal data server; for instance, Astrosky accounts would need to set this tohttps://astrosky.social.
Then, post the data using nebra with nebra.send. This function accepts a dictionary as argument and will default to saving your session to a .session file - make sure not to accidentally upload any session to e.g. GitHub. Your dictionary should contain a $type field that has the namespace of the schema that the record will follow.
import nebra
nebra.send(record, reuse_session=True)
As a more complete example, posting a record that conforms with the eco.astrosky.transient.gcn schema could look like
record = dict(
"$type": "eco.astrosky.transient.gcn",
"topic": "gcn.test",
"eventID": 578245324,
"data": "{"someData": "someValue"}",
"createdAt": nebra.get_atproto_utc_time(),
)
nebra.send(record)
or a Matadisco record could be posted with
record = dict(
"$type": "cx.vmx.matadisco",
"resource": "https://cdsarc.cds.unistra.fr/viz-bin/Cat?J/A+A/686/A42",
"publishedAt": nebra.get_atproto_utc_time(),
)
nebra.send(record)
note that in both cases, we used the convenience function nebra.get_atproto_utc_time(), which provides a maximally ATProtocol-compatible timestamp (which is necessary for certain types of data).
More functionality, including better error feedback and validation will be added in due course. In addition, we are planning on adding an async version of the send function to allow for faster bulk item sending, and documentation on how to write and publish your own lexicons.
Contributing
Contributions are highly welcome! You should follow The Astrosky Ecosystem's style guide with your pull request. Opening an issue first for discussion before writing a PR is usually wise.
License
MIT license; see here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nebra-0.1.0.tar.gz.
File metadata
- Download URL: nebra-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0aff1a7be8759c30fbbca8f82795044eb19f3497f694438c57637083f4ed2fc7
|
|
| MD5 |
cd4a112e8cc92cdc9009a9f226696aef
|
|
| BLAKE2b-256 |
e58b1b34bf9cf67d218eb08172013175399480123e918ba29763af12b601a1fc
|
Provenance
The following attestation bundles were made for nebra-0.1.0.tar.gz:
Publisher:
python-publish.yaml on the-astrosky-ecosystem/nebra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nebra-0.1.0.tar.gz -
Subject digest:
0aff1a7be8759c30fbbca8f82795044eb19f3497f694438c57637083f4ed2fc7 - Sigstore transparency entry: 1187316902
- Sigstore integration time:
-
Permalink:
the-astrosky-ecosystem/nebra@acb536dec8a952817988c8028c495dfb03dba53a -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/the-astrosky-ecosystem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yaml@acb536dec8a952817988c8028c495dfb03dba53a -
Trigger Event:
release
-
Statement type:
File details
Details for the file nebra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nebra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f615a9f2e615aebbbfc667873ed692c80cd5e33cbec74a9b50ec1774f5e9b54
|
|
| MD5 |
4413f1691c96db255b111c7ce1230760
|
|
| BLAKE2b-256 |
2f4a196f089b59ae0ad118227157f189ee87b054054f2d84a520157f21170bcd
|
Provenance
The following attestation bundles were made for nebra-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yaml on the-astrosky-ecosystem/nebra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nebra-0.1.0-py3-none-any.whl -
Subject digest:
2f615a9f2e615aebbbfc667873ed692c80cd5e33cbec74a9b50ec1774f5e9b54 - Sigstore transparency entry: 1187316923
- Sigstore integration time:
-
Permalink:
the-astrosky-ecosystem/nebra@acb536dec8a952817988c8028c495dfb03dba53a -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/the-astrosky-ecosystem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yaml@acb536dec8a952817988c8028c495dfb03dba53a -
Trigger Event:
release
-
Statement type: