Exemple #1
0
from __future__ import print_function

import smile as sm
from smile import flags
from semisupervised.data import build_vocab, translate_tokens

flags.DEFINE_string("smi_path",
                    "/smile/nfs/projects/nih_drug/data/logp/logp.smi",
                    "smi data path.")
flags.DEFINE_string(
    "tmp_path", "",
    "Temporary data path. If none, a named temporary file will be used.")
flags.DEFINE_string("vocab_path", "", "Vocabulary data_path.")
flags.DEFINE_string("out_path", "", "Output token path.")
flags.DEFINE_bool(
    "build_vocab", False, "Trigger the action: False for translating only. "
    "If true, the script will build vocabulary and then translating.")

FLAGS = flags.FLAGS


def main(_):
    """Entry function for this script."""
    if FLAGS.build_vocab:
        build_vocab(FLAGS.smi_path, FLAGS.vocab_path, FLAGS.out_path,
                    FLAGS.tmp_path)
    else:
        translate_tokens(FLAGS.smi_path, FLAGS.vocab_path, FLAGS.out_path,
                         FLAGS.tmp_path)

Exemple #2
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import smile as sm
from smile import flags
from smile import logging

flags.DEFINE_string("param", "default_value", "A general flag.")

with flags.Subcommand("echo", dest="action"):
    flags.DEFINE_string("echo_text", "", "The text to be echoed out.")

with flags.Subcommand("echo_bool", dest="action"):
    flags.DEFINE_bool("just_do_it", False, "some help infomation")

FLAGS = flags.FLAGS


def main(_):
    """Print out the FLAGS in the main function."""
    logging.info("param = %s", FLAGS.param)
    if FLAGS.action == "echo":
        logging.warning(FLAGS.echo_text)
    elif FLAGS.action == "echo_bool":
        logging.info("Just do it? %s", "Yes!" if FLAGS.just_do_it else "No :(")


if __name__ == "__main__":
    sm.app.run()
Exemple #3
0
import unittest

from smile import flags

flags.DEFINE_string("string_foo", "default_val", "HelpString")
flags.DEFINE_integer("int_foo", 42, "HelpString")
flags.DEFINE_float("float_foo", 42.0, "HelpString")

flags.DEFINE_boolean("bool_foo", True, "HelpString")
flags.DEFINE_boolean("bool_negation", True, "HelpString")
flags.DEFINE_boolean("bool-dash-negation", True, "HelpString")
flags.DEFINE_boolean("bool_a", False, "HelpString")
flags.DEFINE_boolean("bool_c", False, "HelpString")
flags.DEFINE_boolean("bool_d", True, "HelpString")
flags.DEFINE_bool("bool_e", True, "HelpString")

with flags.Subcommand("dummy_action", dest="action"):
    pass

with flags.Subcommand("move", dest="action"):
    flags.DEFINE_string("move_string", "default", "help")
    flags.DEFINE_bool("move_bool", True, "HelpString")

    with flags.Subcommand("dummy_object", dest="object"):
        pass

    with flags.Subcommand("wa", dest="object"):
        flags.DEFINE_string("move_wa_string", "default_wa", "help")
        flags.DEFINE_bool("move_wa_bool", False, "HelpString")