Skip to main content

The martian python library allows developers to easily access the martian api.

Project description

Martian Node.js Library

The martian python library allows developers to easily access the martian api.

This package should only be used server-side. Using this package client-side would expose your secret key.

Installation

pip install martian_api

Usage

Martian allows you to easily access AI models and to log the outputs from AI models.

Logging values:

from martian_api import log_to_martian

inputs = ["The", "inputs", "to", "your", "function"]
outputs = "Your outputs"
logToMartian(
  {"api_key": YOUR_MARTIAN_API_KEY},
  inputs,
  outputs,
  {"martian_name": "your_function"}
)

Logging a function:

from martian_api import with_martian

@with_martian({"api_key": YOUR_MARTIAN_API_KEY})
def your_function(args){
  // your function definition
}

Note that with_martian expects a pure function. So, when defining a function in a class which uses the with_martian decorator, only the arguments passed into the function are stored.

from martian_api import with_martian

class Example():
    def __init__(self):
        self.y = 1
        
    # This function does not use variables from self, so with_martian can be used
    @with_martian({"api_key": YOUR_MARTIAN_API_KEY})
    def pure_function(self, x):
        return x + 1
        
    # This function does use variables from self, so with_martian cannot be used
    def impure_function(self, x):
        result = x + y
        log_to_martian(
            {"api_key": YOUR_MARTIAN_API_KEY},
            [x, y],
            result
            {"martian_name": "impure_function"}
        )
        return result

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

martian_api-1.0.4.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

martian_api-1.0.4-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file martian_api-1.0.4.tar.gz.

File metadata

  • Download URL: martian_api-1.0.4.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for martian_api-1.0.4.tar.gz
Algorithm Hash digest
SHA256 9eb3405d0391c24b5cacc0655d81a12610e569e311d1d53989bb6275769bb0dd
MD5 7d23285ae100eb9c78d958e4fb702d4f
BLAKE2b-256 66005e8046e93663157c3c8ec5af6643544b56cb9ea41131f4382452d4f89009

See more details on using hashes here.

File details

Details for the file martian_api-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: martian_api-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for martian_api-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7b169020c26ffb981b69922d0fab4c864bd1b83ff772804b8adb292fd9926b72
MD5 a9d127b3b462d8b86f64de793d309293
BLAKE2b-256 bf28fc076eea351508cafe714a2665608a4bd93a996e5ed44231d7f8a7517dc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page