From 88caad213c40c5f4643b3dfb76cb50d5fcf1d0c9 Mon Sep 17 00:00:00 2001 From: Matthew D Date: Thu, 9 Feb 2017 17:27:50 -0600 Subject: [PATCH] Switch farg_flags to farg.flags to fix bug in batch mode --- .gitignore | 1 + data/pyseqsee_app_template/batch_ui.py_tmpl | 2 +- data/pyseqsee_app_template/controller.py_tmpl | 2 +- data/pyseqsee_app_template/run_{application_name}.py_tmpl | 2 +- docs/howto/flags.rst | 6 +++--- docs/new_app/add_input_flags.rst | 2 +- docs/new_app/update_workspace.rst | 2 +- farg/apps/bongard/batch_ui.py | 2 +- farg/apps/bongard/controller.py | 2 +- farg/apps/bongard/run_bongard.py | 2 +- farg/apps/seqsee/batch_ui.py | 2 +- farg/apps/seqsee/controller.py | 2 +- farg/apps/seqsee/relation.py | 2 +- farg/apps/seqsee/run_seqsee.py | 2 +- farg/apps/seqsee/subspaces/are_we_done.py | 2 +- farg/apps/seqsee/subspaces/get_mapping.py | 2 +- farg/core/controller.py | 2 +- farg/core/ltm/manager.py | 6 ++---- farg/core/main.py | 2 +- farg/core/run_mode/batch.py | 2 +- farg/core/run_mode/non_interactive.py | 2 +- farg/core/run_mode/single.py | 2 +- farg/core/run_mode/sxs.py | 2 +- farg/core/ui/batch_ui.py | 2 +- farg/core/ui/gui/__init__.py | 2 +- farg/core/ui/gui/central_pane.py | 2 +- farg_flags.py => farg/flags.py | 0 27 files changed, 29 insertions(+), 30 deletions(-) rename farg_flags.py => farg/flags.py (100%) diff --git a/.gitignore b/.gitignore index 8e7eb04..7283deb 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ seqsee.main *~ build *.egg-info +.vscode/ diff --git a/data/pyseqsee_app_template/batch_ui.py_tmpl b/data/pyseqsee_app_template/batch_ui.py_tmpl index 2011341..cca0a29 100644 --- a/data/pyseqsee_app_template/batch_ui.py_tmpl +++ b/data/pyseqsee_app_template/batch_ui.py_tmpl @@ -13,7 +13,7 @@ order to automatically answer questions such as the one above.). from farg.core.ui.batch_ui import BatchUI # If you need access to flags, you need: -# import farg_flags +# import farg.flags as farg_flags # # The flag --foo is available at farg_flags.FargFlags.foo class {application_class}BatchUI(BatchUI): diff --git a/data/pyseqsee_app_template/controller.py_tmpl b/data/pyseqsee_app_template/controller.py_tmpl index 9309df8..3c7d440 100644 --- a/data/pyseqsee_app_template/controller.py_tmpl +++ b/data/pyseqsee_app_template/controller.py_tmpl @@ -4,7 +4,7 @@ from farg.core.ltm.manager import LTMManager import sys # If you need access to flags, you need: -# import farg_flags +# import farg.flags as farg_flags # # The flag --foo is available at farg_flags.FargFlags.foo kLTMName = '{application_name}.main' diff --git a/data/pyseqsee_app_template/run_{application_name}.py_tmpl b/data/pyseqsee_app_template/run_{application_name}.py_tmpl index 7c21431..e131923 100644 --- a/data/pyseqsee_app_template/run_{application_name}.py_tmpl +++ b/data/pyseqsee_app_template/run_{application_name}.py_tmpl @@ -7,7 +7,7 @@ from farg.apps.{application_name}.read_input_spec import {application_class}Read from farg.apps.{application_name}.stopping_conditions import {application_class}StoppingConditions from farg.core.main import Main import sys -import farg_flags +import farg.flags as farg_flags {application_name}_parser = argparse.ArgumentParser(parents=[farg_flags.core_parser]) # Flags for specifying the input and, for use in testing, expected output. diff --git a/docs/howto/flags.rst b/docs/howto/flags.rst index dde8aac..a82d290 100644 --- a/docs/howto/flags.rst +++ b/docs/howto/flags.rst @@ -11,7 +11,7 @@ Where the flags are defined Core flags are defined in 'farg_flags.py', which defines the flags parser called 'core_parser'. The entry point for each app extends this. Currently, in Seqsee (run_seqsee.py), we see:: - import farg_flags + import farg.flags as farg_flags seqsee_parser = argparse.ArgumentParser(parents=[farg_flags.core_parser]) seqsee_parser.add_argument('--sequence', type=int, nargs='*') @@ -39,7 +39,7 @@ The entry point of apps To summerize, here are the relevant bits of the Seqsee app's entry point:: import argparse - import farg_flags + import farg.flags as farg_flags from farg.core.main import Main seqsee_parser = argparse.ArgumentParser(parents=[farg_flags.core_parser]) @@ -64,7 +64,7 @@ Where the flags get stored Flags, after processing, end up both in Main.flags and farg_flags.FargFlags. Other modules will use this latter route for accessing. A module may say:: - import farg_flags + import farg.flags as farg_flags if farg_flags.FargFlags.use_stored_ltm: Do something diff --git a/docs/new_app/add_input_flags.rst b/docs/new_app/add_input_flags.rst index 0b3a771..e5b214a 100644 --- a/docs/new_app/add_input_flags.rst +++ b/docs/new_app/add_input_flags.rst @@ -46,7 +46,7 @@ Accessing flags from other files These flags will be needed in other parts of the app. In any file needing them, add the following lines:: - import farg_flags + import farg.flags as farg_flags # later... farg_flags.FargFlags.left \ No newline at end of file diff --git a/docs/new_app/update_workspace.rst b/docs/new_app/update_workspace.rst index c8547ea..5c0e7de 100644 --- a/docs/new_app/update_workspace.rst +++ b/docs/new_app/update_workspace.rst @@ -51,7 +51,7 @@ This is how the BongardController class currently looks:: We will make a couple of changes for now. First, we will make the flags accessible from this file:: - import farg_flags + import farg.flags as farg_flags And we will update the workspace with the relevant inputs:: diff --git a/farg/apps/bongard/batch_ui.py b/farg/apps/bongard/batch_ui.py index 922027a..7999550 100644 --- a/farg/apps/bongard/batch_ui.py +++ b/farg/apps/bongard/batch_ui.py @@ -13,7 +13,7 @@ from farg.core.ui.batch_ui import BatchUI # If you need access to flags, you need: -# import farg_flags +# import farg.flags as farg_flags # # The flag --foo is available at farg_flags.FargFlags.foo class BongardBatchUI(BatchUI): diff --git a/farg/apps/bongard/controller.py b/farg/apps/bongard/controller.py index 9b03dd6..ad0116d 100644 --- a/farg/apps/bongard/controller.py +++ b/farg/apps/bongard/controller.py @@ -5,7 +5,7 @@ from farg.core.ltm.manager import LTMManager import sys -import farg_flags +import farg.flags as farg_flags kLTMName = 'bongard.main' diff --git a/farg/apps/bongard/run_bongard.py b/farg/apps/bongard/run_bongard.py index de90a7e..2bf18cf 100644 --- a/farg/apps/bongard/run_bongard.py +++ b/farg/apps/bongard/run_bongard.py @@ -7,7 +7,7 @@ from farg.apps.bongard.stopping_conditions import BongardStoppingConditions from farg.core.main import Main import sys -import farg_flags +import farg.flags as farg_flags bongard_parser = argparse.ArgumentParser(parents=[farg_flags.core_parser]) # Flags for specifying the input and, for use in testing, expected output. diff --git a/farg/apps/seqsee/batch_ui.py b/farg/apps/seqsee/batch_ui.py index ac1199a..1ae747b 100644 --- a/farg/apps/seqsee/batch_ui.py +++ b/farg/apps/seqsee/batch_ui.py @@ -15,7 +15,7 @@ from farg.core.exceptions import SuccessfulCompletion from farg.core.ui.batch_ui import BatchUI import sys -import farg_flags +import farg.flags as farg_flags def HasAsPrefix(longer_list, shorter_list): return longer_list[:len(shorter_list)] == shorter_list diff --git a/farg/apps/seqsee/controller.py b/farg/apps/seqsee/controller.py index 70cc882..6e25e1c 100644 --- a/farg/apps/seqsee/controller.py +++ b/farg/apps/seqsee/controller.py @@ -20,7 +20,7 @@ import logging import sys -import farg_flags +import farg.flags as farg_flags kLTMName = 'seqsee.main' diff --git a/farg/apps/seqsee/relation.py b/farg/apps/seqsee/relation.py index 87b6a4b..b234b56 100644 --- a/farg/apps/seqsee/relation.py +++ b/farg/apps/seqsee/relation.py @@ -15,7 +15,7 @@ from farg.core.util import SelectWeightedByActivation from farg.core.codelet import Codelet from farg.core.focusable_mixin import FocusableMixin -import farg_flags +import farg.flags as farg_flags from farg.core.history import History, ObjectType """A relation is a specific instance of a mapping.""" diff --git a/farg/apps/seqsee/run_seqsee.py b/farg/apps/seqsee/run_seqsee.py index 1ed2a35..ecabad6 100755 --- a/farg/apps/seqsee/run_seqsee.py +++ b/farg/apps/seqsee/run_seqsee.py @@ -19,7 +19,7 @@ from farg.apps.seqsee.read_input_spec import SeqseeReadInputSpec from farg.apps.seqsee.stopping_conditions import SeqseeStoppingConditions from farg.core.main import Main -import farg_flags +import farg.flags as farg_flags import sys seqsee_parser = argparse.ArgumentParser(parents=[farg_flags.core_parser]) diff --git a/farg/apps/seqsee/subspaces/are_we_done.py b/farg/apps/seqsee/subspaces/are_we_done.py index 30050bc..44ba477 100644 --- a/farg/apps/seqsee/subspaces/are_we_done.py +++ b/farg/apps/seqsee/subspaces/are_we_done.py @@ -11,7 +11,7 @@ # You should have received a copy of the GNU General Public License along with this # program. If not, see from farg.core.subspace import Subspace, QuickReconnResults -import farg_flags +import farg.flags as farg_flags class SubspaceAreWeDone(Subspace): """Checks if we should stop because we have found or explained the answer. diff --git a/farg/apps/seqsee/subspaces/get_mapping.py b/farg/apps/seqsee/subspaces/get_mapping.py index 0325910..9bd953c 100644 --- a/farg/apps/seqsee/subspaces/get_mapping.py +++ b/farg/apps/seqsee/subspaces/get_mapping.py @@ -23,7 +23,7 @@ from farg.apps.seqsee.sobject import SGroup import sys -import farg_flags +import farg.flags as farg_flags # TODO(#53 --- Dec 29, 2011): Needs big fat documentation. diff --git a/farg/core/controller.py b/farg/core/controller.py index 7303d17..2089a52 100644 --- a/farg/core/controller.py +++ b/farg/core/controller.py @@ -23,7 +23,7 @@ from farg.core.stream import Stream from farg.core.util import Toss -import farg_flags +import farg.flags as farg_flags class Controller: """Purely mechanical (read "dumb") loop to control entire app or individual subspaces. diff --git a/farg/core/ltm/manager.py b/farg/core/ltm/manager.py index e9f2fc8..42b17dc 100644 --- a/farg/core/ltm/manager.py +++ b/farg/core/ltm/manager.py @@ -14,12 +14,10 @@ """Manages the set of LTMs.""" import logging - -from farg.core.ltm.graph import LTMGraph import os.path -import sys -import farg_flags +from farg.core.ltm.graph import LTMGraph +import farg.flags as farg_flags kLogger = logging.getLogger("LTM") diff --git a/farg/core/main.py b/farg/core/main.py index bb7aac5..0d7e896 100644 --- a/farg/core/main.py +++ b/farg/core/main.py @@ -23,7 +23,7 @@ import logging.config import os.path import sys -import farg_flags +import farg.flags as farg_flags class Main: """The Base class for the Main class of an application. diff --git a/farg/core/run_mode/batch.py b/farg/core/run_mode/batch.py index f95f9fb..b78646d 100644 --- a/farg/core/run_mode/batch.py +++ b/farg/core/run_mode/batch.py @@ -12,7 +12,7 @@ # program. If not, see from collections import defaultdict -import farg_flags +import farg.flags as farg_flags from farg.core.run_mode.non_interactive import RunModeNonInteractive, RunMultipleTimes, MultipleRunGUI from farg.core.run_stats import RunStats import os.path diff --git a/farg/core/run_mode/non_interactive.py b/farg/core/run_mode/non_interactive.py index eacff21..74d1a58 100644 --- a/farg/core/run_mode/non_interactive.py +++ b/farg/core/run_mode/non_interactive.py @@ -28,7 +28,7 @@ import subprocess import sys import threading -import farg_flags +import farg.flags as farg_flags class RunMultipleTimes(threading.Thread, metaclass=ABCMeta): """Class to run the application several times on a set of inputs. diff --git a/farg/core/run_mode/single.py b/farg/core/run_mode/single.py index a725d26..c7e8b21 100644 --- a/farg/core/run_mode/single.py +++ b/farg/core/run_mode/single.py @@ -15,7 +15,7 @@ from farg.core.run_mode.non_interactive import RunModeNonInteractive from io import StringIO import sys -import farg_flags +import farg.flags as farg_flags class RunModeSingle(RunModeNonInteractive): diff --git a/farg/core/run_mode/sxs.py b/farg/core/run_mode/sxs.py index aed07b5..17b2897 100644 --- a/farg/core/run_mode/sxs.py +++ b/farg/core/run_mode/sxs.py @@ -14,7 +14,7 @@ from farg.core.run_mode.non_interactive import (RunModeNonInteractive, RunMultipleTimes, MultipleRunGUI) import sys -import farg_flags +import farg.flags as farg_flags class SxSRunMultipleTimes(RunMultipleTimes): """Multiple-runner specialized for SxS.""" diff --git a/farg/core/ui/batch_ui.py b/farg/core/ui/batch_ui.py index 9d3a512..a1fbbe7 100644 --- a/farg/core/ui/batch_ui.py +++ b/farg/core/ui/batch_ui.py @@ -12,7 +12,7 @@ # program. If not, see from farg.core.ltm.manager import LTMManager -import farg_flags +import farg.flags as farg_flags class BatchUI: def __init__(self, *, controller_class, stopping_condition_fn=None): diff --git a/farg/core/ui/gui/__init__.py b/farg/core/ui/gui/__init__.py index ddefe14..e96d2f2 100644 --- a/farg/core/ui/gui/__init__.py +++ b/farg/core/ui/gui/__init__.py @@ -22,7 +22,7 @@ from tkinter.messagebox import askyesno, showinfo import logging import threading -import farg_flags +import farg.flags as farg_flags class RunForNSteps(threading.Thread): """Runs controller for up to n steps. diff --git a/farg/core/ui/gui/central_pane.py b/farg/core/ui/gui/central_pane.py index c84bb9b..347e49b 100644 --- a/farg/core/ui/gui/central_pane.py +++ b/farg/core/ui/gui/central_pane.py @@ -17,7 +17,7 @@ Each view is an instance of a subclass of :py:class:`~farg.core.ui.gui.views.viewport.ViewPort`. """ -import farg_flags +import farg.flags as farg_flags import sys from tkinter import ALL, Canvas, Menu diff --git a/farg_flags.py b/farg/flags.py similarity index 100% rename from farg_flags.py rename to farg/flags.py