Core-Py
Example
Prerequisites
Install smcore
pip install smcore
Get the address of a blackboard to talk to
If you don't have an address already (something like bb.myhost.com:8080 or
bb.host.com), you can install the core tool and run your own locally.
go install gitlab.com/hoffman-lab/core@latest
core start server
The default address when running locally is localhost:8080
This is great for debugging and getting started. The core tool also has
other good stuff.
Use an agent to post data
from smcore import agent
from smcore import hardcore
bb_addr = "localhost:8080"
async def main():
bb = hardcore.HTTPTransit(bb_addr)
a = agent.Agent(bb)
for i in range(n_messages):
metadata=b"hello"
data=b"world"
tags = ["upload-test", str(i)]
await a.post(metadata, data, tags)
if __name__=="__main__":
asyncio.run(main())
Use an agent to listen for data
from smcore import agent
from smcore import hardcore
bb_addr = "localhost:8080"
async def main():
bb = hardcore.HTTPTransit(bb_addr)
a = agent.Agent(bb)
# Listen for messages matching the listed tags
in_queue = a.listen_for(["important","segmentation"])
# listening is an active process and must be started.
# although listen_for can be called after start it is
# best practice to make all calls in advance.
#
task = a.start()
while True:
post = await in_queue.get()
await a.reply([post], None, None, ["received!"])
# The started coroutine for listening can be cancelled normally
task.cancel()
if __name__=="__main__":
asyncio.run(main())
(De)serialization
Serialization is the process of converting abstract structures into binary-encodable formats for saving and sharing. Common language allows agents to communicate.
from smcore import serialize, deserialize
data = serialize.file("path/to/file.ext")
deserialize.file(data, "path/to/new/file.ext")
data = serialize.numpy(np.random.random((512,512,1)))
array = deserialize.numpy(data)
The serialize/deserialize modules give you some basics to get started.
These allow you to easily set data and metadata in your posts:
bb = hardcore.HTTPTransit(bb_addr)
post = bb.message_post()
fp_to_upload = "data/for/sharing/file.ext"
post.set_data(serialize.file(fp_to_upload))
post.set_metadata(serialize.dictionary({"path": fp_to_upload}))
You can decode it in other agents using the paired deserialize function:
post = await incoming.get()
finfo = deserialize.dictionary(post.metadata())
deserialize.file(post.data(), finfo["path"])
Motivation
The main core repo is getting a little unwieldy. CI/CD and organization could benefit from giving the python API for Core a little breathing room.
Short term goals
- Get the Python API updated to utilize the hardcore protocol
- Debug the message stoppage issue @mattbrown7 has identified
- Discuss, enumerate, and begin prototyping key tests to validate that the Core API fulfills its contract
Long term goals
- Resilient CI/CD that runs tests in real world conditions
- Shared maintenance of the Python API with other developers
Metadata
Release files for smcore 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| smcore-1.1.2.tar.gz | 17.9 kB | Without provenance | Details for smcore-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smcore-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for smcore-1.1.2-py3-none-any.whl |
Total release size: 39.0 kB
Release files / smcore-1.1.2.tar.gz
| Download URL | smcore-1.1.2.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10be90b866f0d5d31530e77a320af51a7f7f1821597db640f626172b7670fd93
|
|
BLAKE2b-256 checksum How to use checksums |
acb61a8ee8a9d8fd0ea146f1a332617f461b43c7caf131c52479c996d7aeb778
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / smcore-1.1.2-py3-none-any.whl
| Download URL | smcore-1.1.2-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8d31cdd00325ec741f0c48f2f1a9bceb52716d652a32ee8e8b8f61e42849521
|
|
BLAKE2b-256 checksum How to use checksums |
984606d753a9f192cec88144eb5237d4b2a160b1192f70cd61d4020c403e4451
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for smcore 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.