Skip to main content

Utilities for developing an MLsploit python module.

Project description

Build Status Code Coverage Updates Python 3 Code style: black

This package contains utilities for developing an MLsploit python module.

Setup

To install this package on your system using pip, run the following command:

$ pip install mlsploit-py

Usage

This package supports automatic loading of MLsploit jobs inside your module.

# your_mlsploit_module.py

from mlsploit import Job

# load input files and user defined options
Job.initialize()

function_name = Job.function_name # the function name the user wants to run
input_file_items = Job.input_file_items # you can load input_file_items[i].path
options = Job.options # can access options.option1, option.option2 for function_name

# ...
# do stuff based on the information above ...
# ...

# when you're done, you can reserve output files
# that will be uploaded to MLsploit
output_file_item = Job.reserve_output_file_item(
    output_file_name='output_file.txt', is_new_file=True)

with open(output_file_item.path, 'w') as f:
    pass # ... write data to your output file here

# you can also add tags to your output file
# as defined in your module schema
output_file_item.add_tag(name='tagname', value='tagvalue')

# you can add several output files in the above manner

# when you're done done, don't forget to commit the output!
Job.commit_output() # mlsploit-py will take care of the rest

You can also use this package to programmatically create your MLsploit module configuration file (mlsploit_module.yaml) instead of editing it manually. This will also validate your MLsploit module for errors. For more information on the configuration file schema, see here.

# make_dummy_module.py

from mlsploit import Module

module = Module.build(
    display_name='Dummy Module',
    tagline='This is a dummy module!',
    doctxt="""Long documentation for this module will go here...""",
    icon_url='https://somedomain.org/icon.jpg')

function = module.build_function(
    name='Test Function',
    doctxt="""Some long ducumentation of Test Function...""",
    creates_new_files=True,
    modifies_input_files=False,
    expected_filetype='txt',
    optional_filetypes=['rtf', 'ans'])
function.add_option(
    name='option1',
    type='str',
    doctxt="""Some long ducumentation of option1...""",
    required=True)
function.add_output_tag(name='tag1', type='str')
function.add_output_tag(name='tag2', type='int')

# you can add several functions and function options in the above manner

# once you're done, the following command will save the mlsploit_module.yaml
# in the same directory as this file
module.save()

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

mlsploit-py-0.1.3.tar.gz (13.6 kB view hashes)

Uploaded Source

Supported by

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