Giter Site home page Giter Site logo

modelcataloginsertion's Introduction

CAPS Command Line Interface

A repository to discuss, define and implement an approach for easily uploading models

Prerequisites

What things you need to install to run the software and how to install them

Python3

Installing

A step by step series of examples that tell you how to get a development env running

MacOS and Linux Guide for creating virtual environment

Create a python3 virtual environment from the parent directory of this project

python3 -m venv caps-cli-dev

Activate the python3 virtualenv

source caps-cli-dev/bin/activate

Windows Guide for creating virtual environment

Create a python3 virtual environment from the parent directory of this project

py -m venv caps-cli-dev

Activate the python3 virtualenv

.\caps-cli-dev\Scripts\activate

For more info visit this

Building the Project

Now navigate to the project folder (ModelCatalogInsertion)

cd ModelCatalogInsertion

Build the project

python3 setup.py install

Running the Project

Help functionality in the CLI

caps-cli --help

Use this command to configure username and password for the Model Catalog API

caps-cli configure --profile=<NAME_OF_PROFILE>

Use this command to know the details of each CLI function (options, arguments)

caps-cli <initialize, push, validate> --help

Run this command to test the template creation functionality (with 2 inputs, 3 outputs and 1 parameter)

caps-cli initialize -i 2 -o 3 -p 1

Running the above command will generate a yaml outline. By default this will create the outline in the current directory, use -d path/to/location to speciy a location. By default the yaml will be named example_yaml.yaml, user can also use -d fileName.yaml to name the output (note the user must specify .yaml after the name. Otherwise the program does not know if it is a directory or filename). By default this will not override an existing file if they share the same name. use flag -f to force override.

Run this command to transform the input YAML into a postable JSON object

caps-cli push --profile=<NAME_OF_PROFILE> <path_of_yaml_file_from_root_of_the_project>

Run this command to validate the JSON schema obtained by using the above command

caps-cli validate <path_of_json_file_from_root_of_the_project>

Use this command to deactivate the python virtual environment

deactivate

modelcataloginsertion's People

Contributors

cmheidelberg avatar dgarijo avatar dhruvp-8 avatar dhruvrpa avatar maurya-rohit avatar mosoriob avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

cmheidelberg

modelcataloginsertion's Issues

Validate command not working

The validate command could use a more robust documentation. "Validate the JSON obtained after creating one" is a bit vague. What is it validating for? How is it validating? This is ascertainable from the code but a standard user will probably not have access to the source code.

I'm assuming the command is referring to validating the file made from either initialize or push. However, if it it is referring to one of these commands then this should eventually be run automatically after one of those commands is called.

Also despite trying several times I could not get validate to actually run without crashing. This is one of the reasons im pushing for more documentation because I don't know how exactly this command is supposed to be used.

Finally, as I brought up in my notes about push it would be great to have better logging and error handling so the program can crash in a "nice" way if something goes wrong (or user error occurs). I've just copied my earlier examples for helpful types of things for the program to report.

  • "INFO: Converting ModelConfigEample.yaml into JSON"
  • "ERROR: Could not find C:/Users/Admin/ModelCatalogInsertion/test.yaml"
  • "INFO: Generated transformed_json.json"
  • "Success"

CLI should help upload src

This should be similar to WCM: help upload the source code to GitHub and use that link to upload to the model catalog

caps-cpi download

Make download command that generates yaml from modelCatalogue setup.

Command line interface should initialize

The command line should allow something like:
mic (for model-inserction-cli) initialize -i 3 -o 4 -p 10 and generate the template yaml with 3 inputs, 4 outputs and 10 parameters.

caps-cli push

In the readme it states running caps-cli push <path_to_yaml> will generate a transformed_json.json in the root directory (im assuming of the program). However when I ran
caps-cli push examples/ModelConfigExample.yaml
from within the program's root dir it would print out a json to the terminal but no transformed_json.json would be created.

I also tried to cd into the examples directory and ran the command again but this produced the same result.

I also recommend giving log outputs to let the user know what the program is doing. For example telling them things like:

  • "INFO: Converting ModelConfigEample.yaml into JSON"
  • "ERROR: Could not find C:/Users/Admin/ModelCatalogInsertion/test.yaml"
  • "INFO: Generated transformed_json.json"
  • "Success"

This will be especially helpful to new users of the program.

caps-cli initialize only works in ModelCatalogInsertion directory

Unless there is some scope of this project I am missing I would highly recommend doing away with the ModelCatalogInsertion/files directory and just have ModelCatalogInsertion work within the current directory the user is in (similar to how wcm used to work). So, if a user runs caps-cli initialize in their desktop it will just make the initialize_schema.json file there. wcm make-yaml shows an example of this.

If you dont want to use the current directory and instead want a standardized place for files then files should be put a specified location specified from the user's root directory. ie: C:/Users/Admin/.caps-cli. The wcm credentials file is an example of this. It is located in C:/Users/Admin/.wcm. Though there needs to be an error or warning thrown if the file cannot be found

Also since ModelCatalogInsertion will eventually be installed from pip there should be no need for the user to cd into the cloned repo

In case you want the error message for this:

$ caps-cli initialize
WARNING: You are using caps-cli version 0.1.0, however version 0.1.2 is available.
You should consider upgrading via the 'pip install --upgrade caps' command.
Traceback (most recent call last):
  File "C:\users\admin\appdata\local\programs\python\python36\Scripts\caps-cli-script.py", line 11, in <module>
    load_entry_point('caps-cli==0.1.0', 'console_scripts', 'caps-cli')()
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\caps_cli-0.1.0-py3.6.egg\caps\__main__.py", line 58, in initialize
    with open("./files/initialize_schema.json", "r") as fp:
FileNotFoundError: [Errno 2] No such file or directory: './files/initialize_schema.json'

Test insertion for different cases

These cases are necessary:

  • Insert a model configuration (with variables)
  • Insert a model setup (with variables)
  • Insert a model config with no variables.
  • Insert a model setup with no variables.
  • Insert a model config with only execution metadata
  • Edit a model configuration to add a variable.
  • Change the units of a variable.

Make list command

Command will show models pushed to the Model Catalog. For now it can just print put their ID

Python virtual environment setup not working

I was following the steps provided in the caps-cli branch README.md. However, after creating the virtual environment (python -m venv caps-cli-dev) the source caps-cli-dev/bin/activate does not work.

I was still able to build the project and test it outside the virtual environment by skipping those steps.

I wouldn't recommend writing all the code in __main__.py

I've noticed that a lot of the code for each function has been written in the main.py file. I would recommend making a new python file for each command and writing all the code in there. This will really help with readability and scalability as the program grows larger. wcm is a good reference point for this.

Help gets cut off

Problem:
The caps-cli --help returns cut off descriptions for initialization and push commands.

Admin@DESKTOP-K03KE3P MINGW64 ~/Desktop/USC/Internships/ISI/ModelCatalogInsertion (caps-cli)
$ caps-cli --help
Usage: caps-cli [OPTIONS] COMMAND [ARGS]...

Options:
  -v, --verbose
  --help         Show this message and exit.

Commands:
  initialize  Create an empty JSON template to fill the data to be inserted...
  push        Transform the input YAML into a Valid JSON for posting the...
  validate    Validate the JSON obtained after creating one
  version     Show caps-cli version.

FIX:
I think you can use short_help="" in the @cli.command() to give a short overview description of the command so it doesnt get cut off. Then the help="" will show the full help message when the user gets help on the specific command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.