def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'E_Prescription.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?") execute_from_command_line(sys.argv)
def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mqp_project.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv)
def init_partitioner(self): self.prediction_model_algorithm = None self.partition_algorithm = None if self.PREDICTION_MODEL_ALGORITHM == 'FENNEL' or self.PARTITIONER_ALGORITHM == 'FENNEL': import pyximport pyximport.install() from graph_partitioning import fennel if self.PREDICTION_MODEL_ALGORITHM == 'FENNEL': self.prediction_model_algorithm = fennel.FennelPartitioner( self.prediction_model_alpha) if self.verbose > 0: print( "FENNEL partitioner loaded for generating PREDICTION MODEL." ) if self.PARTITIONER_ALGORITHM == 'FENNEL': self.partition_algorithm = fennel.FennelPartitioner() if self.verbose > 0: print( "FENNEL partitioner loaded for making shelter assignments." ) if self.PREDICTION_MODEL_ALGORITHM == 'SCOTCH': sys.path.insert(0, self.SCOTCH_PYLIB_REL_PATH) # check if the library is present if not os.path.isfile(self.SCOTCH_LIB_PATH): raise ImportError( "Could not locate the SCOTCH library file at: {}".format( self.SCOTCH_LIB_PATH)) from graph_partitioning import scotch_partitioner self.prediction_model_algorithm = scotch_partitioner.ScotchPartitioner( self.SCOTCH_LIB_PATH) if self.verbose > 0: print( "SCOTCH partitioner loaded for generating PREDICTION MODEL." ) if self.prediction_model_algorithm == None: raise NoPartitionerException( "Prediction model partitioner not specified or incorrect. Available partitioners are 'FENNEL' or 'SCOTCH'." ) if self.partition_algorithm == None: raise NoPartitionerException( "Assignment partitioner not specified or incorrect. Available partitioners is 'FENNEL'." )
#!/usr/bin/env python import os import sys from builtins import ImportError if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cvanalysis.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?") from exc execute_from_command_line(sys.argv)
def init_partitioner(self): self.prediction_model_algorithm = None self.partition_algorithm = None if self.PREDICTION_MODEL_ALGORITHM == 'FENNEL' or self.PARTITIONER_ALGORITHM == 'FENNEL': import pyximport pyximport.install() from graph_partitioning import fennel if self.PREDICTION_MODEL_ALGORITHM == 'FENNEL': self.prediction_model_algorithm = fennel.FennelPartitioner( self.prediction_model_alpha, self.FENNEL_FRIEND_OF_A_FRIEND_ENABLED) if self.verbose > 0: print( "FENNEL partitioner loaded for generating PREDICTION MODEL." ) if self.PARTITIONER_ALGORITHM == 'FENNEL': self.partition_algorithm = fennel.FennelPartitioner( FRIEND_OF_FRIEND_ENABLED=self. FENNEL_FRIEND_OF_A_FRIEND_ENABLED) if self.verbose > 0: print( "FENNEL partitioner loaded for making shelter assignments." ) if self.FENNEL_NODE_REORDERING_ENABLED: # compute the node leverage centrality scores for the whole graph self.fennel_centrality_reordered_nodes = utils.leverage_centrality( self.G) if self.PREDICTION_MODEL_ALGORITHM == 'SCOTCH': #sys.path.insert(0, self.SCOTCH_PYLIB_REL_PATH) # check if the library is present if not os.path.isfile(self.SCOTCH_LIB_PATH): raise ImportError( "Could not locate the SCOTCH library file at: {}".format( self.SCOTCH_LIB_PATH)) from graph_partitioning import scotch_partitioner self.prediction_model_algorithm = scotch_partitioner.ScotchPartitioner( self.SCOTCH_LIB_PATH, virtualNodesEnabled=self.use_virtual_nodes) if self.verbose > 0: print( "SCOTCH partitioner loaded for generating PREDICTION MODEL." ) if self.PARTITIONER_ALGORITHM == 'SCOTCH': # use the same prediction_model_algorithm for both batch and prediction modes self.partition_algorithm = self.prediction_model_algorithm if self.verbose > 0: print( "SCOTCH partitioner loaded for making shelter assignments." ) if self.PREDICTION_MODEL_ALGORITHM == 'PATOH': #sys.path.insert(0, self.SCOTCH_PYLIB_REL_PATH) # check if the library is present if not os.path.isfile(self.PATOH_LIB_PATH): raise ImportError( "Could not locate the PaToH library file at: {}".format( self.PATOH_LIB_PATH)) from graph_partitioning import patoh_partitioner isQuiet = False if (self.verbose == 0): isQuiet = True self.prediction_model_algorithm = patoh_partitioner.PatohPartitioner( self.PATOH_LIB_PATH, quiet=isQuiet, partitioningIterations=self.PATOH_ITERATIONS, hyperedgeExpansionMode=self.PATOH_HYPEREDGE_EXPANSION_MODE) if self.verbose > 0: print( "PaToH partitioner loaded for generating PREDICTION MODEL." ) if self.PARTITIONER_ALGORITHM == 'PATOH': # use the same prediction_model_algorithm for both batch and prediction modes self.partition_algorithm = self.prediction_model_algorithm if self.verbose > 0: print( "PaToH partitioner loaded for making shelter assignments." ) # edge expansion happens via hyperedge expansion in PaToH's patoh_data.py script if (self.edge_expansion_enabled): self.edge_expansion_enabled = False self.prediction_model_algorithm.hyperedgeExpansionMode = self.PATOH_HYPEREDGE_EXPANSION_MODE else: self.prediction_model_algorithm.hyperedgeExpansionMode = 'no_expansion' if self.prediction_model_algorithm == None: raise NoPartitionerException( "Prediction model partitioner not specified or incorrect. Available partitioners are 'FENNEL' or 'SCOTCH'." ) if self.partition_algorithm == None: raise NoPartitionerException( "Assignment partitioner not specified or incorrect. Available partitioners is 'FENNEL'." )