Skip to content

Conversation

@cassova
Copy link
Contributor

@cassova cassova commented Jun 26, 2025

Description

This introduces our new Logger to the Macrocosmos SDK. Logger is the Macrocosmos logging utility used by Macrocosmos subnets for capturing subnet node activity.

Example usage

Here's a simple example of a run method that utlizes the Macrocosmos logger.

import macrocosmos as mc
from loguru import logger

async def run():
    mcl_client = mc.AsyncLoggerClient(app_name="my_app")
    mc_logger = mcl_client.logger

    # Start a new run
    run = await mc_logger.init(
        project="data-universe-validators",
        tags=[f"example"],
        notes=f"Additional notes",
        config={"key": "value"},
        name=f"My Example",
        description=f"This is an example",
    )

    logger.success(f"🚀 Logger initialized successfully with run ID: {run.id}")

    try:
        while True:
            # Do something
            logger.info("Captured log message")

            # Log metrics
            metrics = {"key": "value"}
            await mc_logger.log(metrics)
    except Exception as e:
        logger.error(f"Critical error: {str(e)}")
        raise
    finally:
        logger.info(f"🏁 Finished")
        await mc_logger.finish()  # or use `run.finish()`

Disable Console Capture

All console messages (i.e. log messages) are automatically captured by mc_logger between the init() and finish() calls. This can be disabled by setting the environment variable MACROCOSMOS_CAPTURE_LOGS=false.

cassova added 30 commits June 19, 2025 13:15
d5a1f40 improve proto comments
9f44609 remove run_seq_id from proto
92be4b3 added missing run_seq_id
4395860 update logger proto
8ed6a42 init logger protos
275883f Merge pull request #28 from macrocosm-os/gen_1498_completions_for_deep_research
c6dbf10 Merge remote-tracking branch 'origin/main' into gen_1498_completions_for_deep_research
ff964fa Merge pull request #27 from macrocosm-os/gen_1328_update_completion_attribute
ed69470 GEN-1498 add new new line in apex.proto
7bff37c Merge remote-tracking branch 'origin/main' into gen_1328_update_completion_attribute
90a77eb GEN-1498 adding functionality that returns completions that contain deep researcher metadata
452d651 GEN-1328 removing unnecessary optional on metadata proto type
111b7f7 GEN-1328 allow for any attribute combination to be updated in completions function
453e92e Merge pull request #26 from macrocosm-os/gen_1323_completions_from_search_term
e4cbd1f GEN-1328 adding new line to apex.proto
16e2be2 Merge remote-tracking branch 'origin/main' into gen_1328_update_completion_attribute
bdabb7e Merge remote-tracking branch 'origin/main' into gen_1323_completions_from_search_term
b17b911 GEN-1323 formatting: new line added to apex.proto
fec8463 GEN-1323 adding search over prompt and completion text functionality
b96f234 Merge remote-tracking branch 'origin/main' into gen_1328_update_completion_attribute
c360938 Merge remote-tracking branch 'origin/main' into gen_1323_completions_from_search_term
3532b3f Merge pull request #25 from macrocosm-os/gen_1473_modify_update_chat_attribute
a3df363 Merge remote-tracking branch 'origin/main' into gen_1473_modify_update_chat_attribute
2d7aa97 Merge pull request #24 from macrocosm-os/gen_1330_delete_completions
65632f1 Merge remote-tracking branch 'origin/main' into gen_1330_delete_completions
5585e83 GEN-1328 added initial update completion attribute
f8fd14d (WIP) adding update completion attribute endpoint
99f00a9 GEN-1323 adding the search completions using string and return chat ids functionality
7782099 (WIP) proto update
bddc347 GEN-1473 modifying the UpdateChatAttribute endpoint to return the updated data. Renaming to UpdateChatAttributes
7f4e6f5 GEN-1330 new line formatting
54f458c (WIP) GEN-1330 delete completions added and additional user_id validation implemented
2c40db9 Merge pull request #23 from macrocosm-os/gen_1324_insert_a_chat
0edbf74 Merge remote-tracking branch 'origin/main' into gen_1324_insert_a_chat
edad0d2 GEN-1324 CreateCompletion and CreateChatAndCompletion endpoints. Endpoints return ParsedChat and ParsedCompletion data
3ad7e51 Merge remote-tracking branch 'origin/main' into gen_1324_insert_a_chat
49a4cc0 GEN-1322: Retrieve chat completions schemas (#22)
ea967dd GEN-1322: Add endpoint for retrieving chat completions (#138)
a0cff84 Merge pull request #21 from macrocosm-os/gen-1334_add_const_api_to_gravity_db
b604ed5 Merge remote-tracking branch 'origin/main' into gen-1334_add_const_api_to_gravity_db
406796e hotfix: remove duplicate DatasetBillingCorrection rpc
0e98f7f Merge branch 'main' into gen-1334_add_const_api_to_gravity_db
4f4e95e GEN-1324 new line on apex.proto
2281abc (WIP) GEN-1324 testing add chat and completions
ecd4f4c Add endpoint for retrieving chat completions
93827af Merge pull request #20 from macrocosm-os/gen_1329_delete_chat
5cb32a1 Merge remote-tracking branch 'origin/main' into gen_1329_delete_chat
c6a5223 (WIP) GEN-1324 adding checks on chat type, completion type
988f35b (WIP) GEN-1324 prelimary addition of insert chat functionality
5fd6e0d GEN-1329 delete chat functionality added via DeleteChats
2d46890 (WIP) GEN-1329 initial deletion setup
e3b05a4 Merge branch 'main' into gen-1334_add_const_api_to_gravity_db
d9a8e88 Merge pull request #19 from macrocosm-os/hotfix_user_id_missing_on_crawler
95e7746 Hotfix user_id missing on crawler
336b244 add new sn13 params
a59dbff Merge branch 'main' into gen-1334_add_const_api_to_gravity_db
3f18527 added new sn13 DD criteria
c32aef3 change to timestamp
97dce97 add new criteria

git-subtree-dir: protos
git-subtree-split: d5a1f400b0c190de20a8d1fdc589d31edd4b6e1f
@cassova cassova requested a review from steffencruz as a code owner June 26, 2025 21:38
@cassova cassova merged commit 8a599e5 into main Jun 26, 2025
1 check passed
@cassova cassova deleted the gen-1565_wandb_replacement branch June 26, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants