Exemple #1
0
def execute(dataset, infile, outfile='.'):
    os.chdir("struc2vec")
    print('Current directory is', os.getcwd())
    # create and activate the virtual environment
    print('\nRunning in a virtual environment')
    venv_dir = os.path.join(os.getcwd(), 'project', '.venv')
    if not os.path.exists(venv_dir):
        virtualenv.create_environment(venv_dir)
    execfile(os.path.join(venv_dir, "bin", "activate_this.py"), globals())

    # pip install the requirements of struc2vec in the virtual environment
    print('\nInstalling requirements of struc2vec ...\n')
    pip.main(['install', '--prefix', venv_dir, 'figures'])
    pip.main(['install', '--prefix', venv_dir, 'fastdtw'])
    pip.main(['install', '--prefix', venv_dir, 'gensim'])
    pip.main(['install', '--prefix', venv_dir, 'cPickle'])

    path = os.path.join('..', '..', 'graphs', dataset)
    print('\nRunning struc2vec using', dataset, '...\n')
    command = 'python src/main.py ' \
              '--input "' + infile + '" ' \
              '--num-walks 80 ' \
              '--dimensions 128 ' \
              '--walk-length 40 ' \
              '--OPT1 True ' \
              '--OPT2 True ' \
              '--OPT3 True ' \
              '--output "' + outfile + '"'
    run = subprocess.run(command, shell=True)
    print(run)
Exemple #2
0
def execute(dataset, infile, outfile='.'):
    os.chdir("deepwalk")
    print('Current directory is', os.getcwd())
    # create and activate the virtual environment
    print('\nRunning in a virtual environment')
    venv_dir = os.path.join(os.getcwd(), 'project', '.venv')
    if not os.path.exists(venv_dir):
        virtualenv.create_environment(venv_dir)
    execfile(os.path.join(venv_dir, "bin", "activate_this.py"), globals())

    # pip install the requirements of deepwalk in the virtual environment
    print('\nInstalling requirements of deepwalk ...\n')
    pip.main(['install', '--prefix', venv_dir, '-r', 'requirements.txt'])

    # Setup deepwalk
    print('\nSetting up deepwalk ...\n')
    setup = subprocess.run("python setup.py install", shell=True)
    print(setup)

    path = os.path.join('..', '..', 'graphs', dataset)
    print('\nRunning deepwalk using', dataset, '...\n')
    command = 'deepwalk --format edgelist ' \
              '--input "' + infile + '" ' \
              '--max-memory-data-size 0 ' \
              '--number-walks 10 ' \
              '--representation-size 128 ' \
              '--walk-length 40 ' \
              '--workers 1 ' \
              '--output "' + outfile + '"'
    run = subprocess.run(command, shell=True)
    print(run)
Exemple #3
0
def execute(dataset, infile, outfile='.'):
    os.chdir("HARP")
    print('Current directory is', os.getcwd())
    # create and activate the virtual environment
    print('\nRunning in a virtual environment')
    venv_dir = os.path.join(os.getcwd(), 'project', '.venv')
    if not os.path.exists(venv_dir):
        virtualenv.create_environment(venv_dir)
    execfile(os.path.join(venv_dir, "bin", "activate_this.py"), globals())

    magic_graph_dir = os.path.join(os.getcwd(), 'magic-graph')
    if not os.path.exists(magic_graph_dir):
        git.Git(".").clone("git://github.com/phanein/magic-graph")
    os.chdir("magic-graph")
    setup = subprocess.call('"' + os.path.join(venv_dir, 'bin', 'python2.7') +
                            '" setup.py install',
                            shell=True)
    print(setup)
    os.chdir("..")

    print('\nSetting up harp ...\n')

    # pip install the requirements of harp in the virtual environment
    print('\nInstalling requirements of harp ...\n')
    # https://stackoverflow.com/a/17271444/
    # from pip import main as pip
    # pip(['install', '--prefix', venv_dir, '-r', 'requirements.txt'])
    subprocess.call(os.path.join('"' + venv_dir, 'bin', 'pip2.7') +
                    '" install -r requirements.txt',
                    shell=True)
    subprocess.call(os.path.join('"' + venv_dir, 'bin', 'pip2.7') +
                    '" install numpy',
                    shell=True)
    subprocess.call(os.path.join('"' + venv_dir, 'bin', 'pip2.7') +
                    '" install six',
                    shell=True)
    subprocess.call(os.path.join('"' + venv_dir, 'bin', 'pip2.7') +
                    '" install smart_open',
                    shell=True)
    #pip.main(['install', '--prefix', venv_dir, '-r', 'requirements.txt'])

    print('\nRunning HARP using', dataset, '...\n')
    command = '"' + os.path.join(venv_dir, 'bin', 'python2.7') + '" ' + os.path.join('src', 'harp.py') + ' ' \
            '--format edgelist ' \
            '--input "' + infile + '" ' \
            '--model deepwalk ' \
            '--sfdp-path "' + os.path.join(os.getcwd() + 'bin' + 'sfdp_linux') + '" ' \
            '--number-walks 10 ' \
            '--walk-length 40 ' \
            '--workers 1 ' \
            '--output "' + outfile + '" ' \
            '--representation-size 128'
    print(command)
    run = subprocess.call(command, shell=True)
    print(run)
Exemple #4
0
    def _read_file_as_dict(self):
        """Load the config file into self.config, with recursive loading."""

        def get_config():
            """Unnecessary now, but a deprecation warning is more trouble than it's worth."""
            return self.config

        namespace = dict(
            c=self.config, load_subconfig=self.load_subconfig, get_config=get_config, __file__=self.full_filename
        )
        fs_encoding = sys.getfilesystemencoding() or "ascii"
        conf_filename = self.full_filename.encode(fs_encoding)
        py3compat.execfile(conf_filename, namespace)
Exemple #5
0
    def _read_file_as_dict(self):
        """Load the config file into self.config, with recursive loading."""
        def get_config():
            """Unnecessary now, but a deprecation warning is more trouble than it's worth."""
            return self.config

        namespace = dict(
            c=self.config,
            load_subconfig=self.load_subconfig,
            get_config=get_config,
            __file__=self.full_filename,
        )
        conf_filename = self.full_filename
        py3compat.execfile(conf_filename, namespace)
Exemple #6
0
    def _read_file_as_dict(self):
        """Load the config file into self.config, with recursive loading."""
        def get_config():
            """Unnecessary now, but a deprecation warning is more trouble than it's worth."""
            return self.config

        namespace = dict(
            c=self.config,
            load_subconfig=self.load_subconfig,
            get_config=get_config,
            __file__=self.full_filename,
        )
        # encode filename to bytes only on py2 on non-Windows:
        if PY3 or sys.platform.startswith('win'):
            conf_filename = self.full_filename
        else:
            fs_encoding = sys.getfilesystemencoding() or 'ascii'
            conf_filename = self.full_filename.encode(fs_encoding)
        py3compat.execfile(conf_filename, namespace)
Exemple #7
0
    def _read_file_as_dict(self):
        """Load the config file into self.config, with recursive loading."""
        def get_config():
            """Unnecessary now, but a deprecation warning is more trouble than it's worth."""
            return self.config

        namespace = dict(
            c=self.config,
            load_subconfig=self.load_subconfig,
            get_config=get_config,
            __file__=self.full_filename,
        )
        # encode filename to bytes only on py2 on non-Windows:
        if PY3 or sys.platform.startswith('win'):
            conf_filename = self.full_filename
        else:
            fs_encoding = sys.getfilesystemencoding() or 'ascii'
            conf_filename = self.full_filename.encode(fs_encoding)
        py3compat.execfile(conf_filename, namespace)
Exemple #8
0
def execute(dataset, infile, outfile='.'):
    os.chdir("node2vec")
    print('Current directory is', os.getcwd())
    # create and activate the virtual environment
    print('\nRunning in a virtual environment')
    venv_dir = os.path.join(os.getcwd(), 'project', '.venv')
    if not os.path.exists(venv_dir):
        virtualenv.create_environment(venv_dir)
    execfile(os.path.join(venv_dir, "bin", "activate_this.py"), globals())

    # pip install the requirements of deepwalk in the virtual environment
    print('\nInstalling requirements of deepwalk ...\n')
    pip.main(['install', '--prefix', venv_dir, '-r', 'requirements.txt'])

    path = os.path.join('..', '..', 'graphs', dataset)
    print('\nRunning node2vec using', dataset, '...\n')
    command = 'python ' + os.path.join('src', 'main.py') + ' ' \
              '--input "' + infile + '" ' \
              '--output "' + outfile + '" ' \
              '--num-walks 10 ' \
              '--walk-length 40 ' \
              '--undirected'
    run = subprocess.run(command, shell=True)
    print(run)
Exemple #9
0
from ipython_genutils.py3compat import execfile


class C(object):
    @staticmethod
    def f():
        print('runoob')


C.f()  # 静态方法无需实例化
cobj = C()
cobj.f()
ss = all(['a', 0, 'c', 'd'])
print(ss)

seq = ['one', 'two', 'three', 'four', 'five']
for i, element in enumerate(seq):
    print(i, element)

print(ord('A'))

dict = {'runoob': 'runoob.com', 'google': 'google.com'}

print(str(dict))

execfile('hello.py')