text stringlengths 0 1.05M | meta dict |
|---|---|
"""
Pydoop command line tool.
"""
import os
import argparse
import importlib
import sys
from pydoop.version import version
SUBMOD_NAMES = [
"script",
"submit",
]
PYDOOP_CONF_FILE = "~/.pydoop/pydoop.conf"
class PatchedArgumentParser(argparse.ArgumentParser):
"""
This is a work-around for a bug i... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/app/main.py",
"copies": "1",
"size": "2734",
"license": "apache-2.0",
"hash": -4871986509449570000,
"line_mean": 30.4252873563,
"line_max": 77,
"alpha_frac": 0.6616678859,
"autogenerated": false,
"ratio": 3.7400820793433653,
"config_test": false,
... |
"""
pydoop.hdfs.file -- HDFS File Objects
-------------------------------------
"""
import os
import io
import codecs
from pydoop.hdfs import common
def _complain_ifclosed(closed):
if closed:
raise ValueError("I/O operation on closed HDFS file object")
class FileIO(object):
"""
Instances of t... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/hdfs/file.py",
"copies": "1",
"size": "11724",
"license": "apache-2.0",
"hash": -395632613422413300,
"line_mean": 28.9081632653,
"line_max": 79,
"alpha_frac": 0.5659331286,
"autogenerated": false,
"ratio": 4.166311300639659,
"config_test": false,
... |
"""
pydoop.hdfs.fs -- File System Handles
-------------------------------------
"""
import os
import socket
import getpass
import re
import operator as ops
import io
import pydoop
from . import common
from .file import FileIO, hdfs_file, local_file, TextIOWrapper
from .core import core_hdfs_fs
# py3 compatibility
f... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/hdfs/fs.py",
"copies": "1",
"size": "20370",
"license": "apache-2.0",
"hash": 7983839182388575000,
"line_mean": 31.5399361022,
"line_max": 78,
"alpha_frac": 0.5580265096,
"autogenerated": false,
"ratio": 4.003537735849057,
"config_test": false,
... |
"""
pydoop.hdfs.path -- Path Name Manipulations
-------------------------------------------
"""
import os
import re
import time
from . import common, fs as hdfs_fs
from pydoop.utils.py3compat import clong
curdir, pardir, sep = '.', '..', '/' # pylint: disable=C0103
class StatResult(object):
"""
Mimics t... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/hdfs/path.py",
"copies": "1",
"size": "15531",
"license": "apache-2.0",
"hash": -1391930022653306000,
"line_mean": 27.3412408759,
"line_max": 78,
"alpha_frac": 0.5794861889,
"autogenerated": false,
"ratio": 3.641500586166471,
"config_test": false,... |
"""
Pydoop Script
=============
A quick and easy to use interface for running simple MapReduce jobs.
Pydoop script is a front-end to pydoop submit that automatically builds
a map-reduce program using functions contained in a user provided
python module.
"""
import os
import warnings
import pydoop
import pydoop.had... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/app/script.py",
"copies": "1",
"size": "6619",
"license": "apache-2.0",
"hash": -6065554906973170000,
"line_mean": 36.1853932584,
"line_max": 78,
"alpha_frac": 0.6319685753,
"autogenerated": false,
"ratio": 3.9492840095465396,
"config_test": false... |
"""
Test suite for top-level functions.
"""
import unittest
import os
import tempfile
import shutil
from imp import reload
import pydoop
class TestPydoop(unittest.TestCase):
def setUp(self):
self.wd = tempfile.mkdtemp(prefix='pydoop_test_')
self.old_vars = {
'HADOOP_HOME': os.geten... | {
"repo_name": "elzaggo/pydoop",
"path": "test/common/test_pydoop.py",
"copies": "1",
"size": "2522",
"license": "apache-2.0",
"hash": 5707897651355104000,
"line_mean": 28.3255813953,
"line_max": 77,
"alpha_frac": 0.6272799366,
"autogenerated": false,
"ratio": 3.4547945205479453,
"config_test": ... |
"""
The hadut module provides access to some functionalities available
via the Hadoop shell.
"""
import logging
import os
import shlex
import subprocess
import pydoop
import pydoop.utils.misc as utils
import pydoop.hadoop_utils as hu
import pydoop.hdfs as hdfs
from .utils.py3compat import basestring
GLOB_CHARS = f... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/hadut.py",
"copies": "1",
"size": "20122",
"license": "apache-2.0",
"hash": 8653168681057727000,
"line_mean": 34.1169284468,
"line_max": 79,
"alpha_frac": 0.6053076235,
"autogenerated": false,
"ratio": 3.724227281140107,
"config_test": true,
"ha... |
"""
The MapReduce API allows to write the components of a MapReduce application.
The basic MapReduce components (:class:`Mapper`, :class:`Reducer`,
:class:`RecordReader`, etc.) are provided as abstract classes that
must be subclassed by the developer, providing implementations for all
methods called by the framework... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/api.py",
"copies": "1",
"size": "13563",
"license": "apache-2.0",
"hash": -8996464195947972000,
"line_mean": 25.9107142857,
"line_max": 79,
"alpha_frac": 0.598318956,
"autogenerated": false,
"ratio": 4.270465994962216,
"config_test": fal... |
"""
This module provides basic, stand-alone Hadoop simulators for
debugging support.
"""
import sys
import threading
import os
import tempfile
import uuid
import logging
from pydoop.utils.py3compat import StringIO, iteritems, socketserver, unicode
logging.basicConfig()
LOGGER = logging.getLogger('simulator')
LOGGER.... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/mapreduce/simulator.py",
"copies": "1",
"size": "32555",
"license": "apache-2.0",
"hash": -4195818772738554400,
"line_mean": 37.0315420561,
"line_max": 79,
"alpha_frac": 0.5768391952,
"autogenerated": false,
"ratio": 3.8913459239780064,
"config_te... |
"""
Traverse an HDFS tree and output disk space usage by block size.
"""
# DOCS_INCLUDE_START
import pydoop.hdfs as hdfs
from common import MB, TEST_ROOT
def usage_by_bs(fs, root):
stats = {}
for info in fs.walk(root):
if info['kind'] == 'directory':
continue
bs = int(info['block_... | {
"repo_name": "elzaggo/pydoop",
"path": "examples/hdfs/treewalk.py",
"copies": "1",
"size": "1283",
"license": "apache-2.0",
"hash": 6108516094734510000,
"line_mean": 28.8372093023,
"line_max": 77,
"alpha_frac": 0.6484801247,
"autogenerated": false,
"ratio": 3.4489247311827955,
"config_test": f... |
"""
Utilities for unit tests.
"""
import sys
import os
import random
import uuid
import tempfile
import pydoop
if sys.version_info[0] == 3:
xrange = range
_HADOOP_HOME = pydoop.hadoop_home()
_HADOOP_CONF_DIR = pydoop.hadoop_conf()
_RANDOM_DATA_SIZE = 32
_DEFAULT_HDFS_HOST = "localhost"
_DEFAULT_HDFS_PORT = 80... | {
"repo_name": "elzaggo/pydoop",
"path": "test/mapreduce/utils.py",
"copies": "1",
"size": "3133",
"license": "apache-2.0",
"hash": -7581459038538479000,
"line_mean": 24.8925619835,
"line_max": 77,
"alpha_frac": 0.5933609959,
"autogenerated": false,
"ratio": 3.190427698574338,
"config_test": fal... |
# pylint: disable=W0212
"""
Test suite for pydoop.hadut
"""
import unittest
import pydoop.hadut as hadut
def pair_set(seq):
return set((seq[i], seq[i + 1]) for i in range(0, len(seq), 2))
class TestHadut(unittest.TestCase):
def assertEqualPairSet(self, seq1, seq2):
return self.assertEqual(pair_... | {
"repo_name": "elzaggo/pydoop",
"path": "test/common/test_hadut.py",
"copies": "1",
"size": "2324",
"license": "apache-2.0",
"hash": 4551729506752887300,
"line_mean": 27.3414634146,
"line_max": 77,
"alpha_frac": 0.5813253012,
"autogenerated": false,
"ratio": 3.432791728212703,
"config_test": tr... |
r"""
This module allows you to connect to an HDFS installation, read and
write files and get information on files, directories and global
filesystem properties.
Configuration
-------------
The hdfs module is built on top of ``libhdfs``, in turn a JNI wrapper
around the Java fs code: therefore, for the module to wor... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/hdfs/__init__.py",
"copies": "1",
"size": "12105",
"license": "apache-2.0",
"hash": 5344001947452250000,
"line_mean": 29.6455696203,
"line_max": 79,
"alpha_frac": 0.5979347377,
"autogenerated": false,
"ratio": 3.5623896409652738,
"config_test": fa... |
"""Serialization routines based on Hadoop's SerialUtils.cc.
Object serialization/deserialization will instead be implemented as follows.
.. code-block:: python
# documentation needs to be rewritten
pass
The idea is to mimick Hadoop writable interface, so that we can then write:
.. code-block:: python
... | {
"repo_name": "elzaggo/pydoop",
"path": "pydoop/utils/serialize.py",
"copies": "1",
"size": "8663",
"license": "apache-2.0",
"hash": 1077673584309019600,
"line_mean": 25.1722054381,
"line_max": 79,
"alpha_frac": 0.6341913887,
"autogenerated": false,
"ratio": 3.55623973727422,
"config_test": fal... |
# DEV NOTE: some of the variables defined here (docstring included)
# are parsed by setup.py, check it before modifying them.
"""
Pydoop: a Python MapReduce and HDFS API for Hadoop
--------------------------------------------------
Pydoop is a Python interface to Hadoop that allows you to write
MapReduce application... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/__init__.py",
"copies": "2",
"size": "4202",
"license": "apache-2.0",
"hash": -7342147141754856000,
"line_mean": 24.1616766467,
"line_max": 77,
"alpha_frac": 0.6449309852,
"autogenerated": false,
"ratio": 3.5700934579439254,
"config_test": false,
... |
# DEV NOTE: this module is used by the setup script, so it MUST be
# importable even if Pydoop has not been installed (yet).
"""
Tools for retrieving Hadoop-related information.
"""
import os
import glob
import re
import platform
import subprocess
import xml.dom.minidom as dom
from xml.parsers.expat import ExpatErro... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/hadoop_utils.py",
"copies": "2",
"size": "5028",
"license": "apache-2.0",
"hash": -6804095316568826000,
"line_mean": 31.862745098,
"line_max": 78,
"alpha_frac": 0.5781622912,
"autogenerated": false,
"ratio": 4.067961165048544,
"config_test": false,... |
from __future__ import division
import unittest
import tempfile
import os
import stat
from pydoop.utils.py3compat import czip
from threading import Thread
import pydoop.hdfs as hdfs
from pydoop.hdfs.common import BUFSIZE
from pydoop.test_utils import UNI_CHR, make_random_data, FSTree
class TestHDFS(unittest.TestCa... | {
"repo_name": "simleo/pydoop",
"path": "test/hdfs/test_hdfs.py",
"copies": "2",
"size": "14127",
"license": "apache-2.0",
"hash": 4491670404353001500,
"line_mean": 34.5843828715,
"line_max": 79,
"alpha_frac": 0.5558151058,
"autogenerated": false,
"ratio": 3.3643724696356276,
"config_test": true... |
import argparse
import pydoop.hdfs as hdfs
def kv_pair(s):
try:
k, v = s.split("=", 1)
except ValueError:
raise argparse.ArgumentTypeError("arg must be in the k=v form")
return k, v
class UpdateMap(argparse.Action):
"""\
Update the destination map with a K=V pair.
>>> parse... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/app/argparse_types.py",
"copies": "2",
"size": "1894",
"license": "apache-2.0",
"hash": -4590788423307373600,
"line_mean": 27.696969697,
"line_max": 79,
"alpha_frac": 0.6356916579,
"autogenerated": false,
"ratio": 3.406474820143885,
"config_test": fa... |
import os
import shutil
import string
import subprocess
import sys
import tempfile
import fnmatch
JPROG = string.Template("""\
public class ${classname} {
public static void main(String[] args) {
System.out.println(System.getProperty("java.home"));
}
}
""")
def get_java_home():
"""\
Try getting JAV... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/utils/jvm.py",
"copies": "2",
"size": "5007",
"license": "apache-2.0",
"hash": -269925630371953180,
"line_mean": 30.29375,
"line_max": 78,
"alpha_frac": 0.6131416018,
"autogenerated": false,
"ratio": 3.5310296191819464,
"config_test": false,
"has... |
import os
import shutil
import struct
import tempfile
import unittest
import pydoop.sercore as sercore
class TestFileSplit(unittest.TestCase):
def setUp(self):
work_dir = tempfile.mkdtemp(prefix="pydoop_")
work_path = os.path.join(work_dir, "foo")
self.filename, self.offset, self.length... | {
"repo_name": "crs4/pydoop",
"path": "test/sercore/test_deser.py",
"copies": "2",
"size": "2004",
"license": "apache-2.0",
"hash": -152047089225451000,
"line_mean": 28.0434782609,
"line_max": 77,
"alpha_frac": 0.6706586826,
"autogenerated": false,
"ratio": 3.623869801084991,
"config_test": true... |
import random
import sys
offices = ['office-%s' % i for i in range(3)]
colors = ['red', 'blue', 'yellow', 'orange', 'maroon', 'green']
names = ['Alyssa', 'John', 'Kathy', 'Ben', 'Karla', 'Ross', 'Violetta']
def create_input(n, stream):
for i in range(n):
stream.write(';'.join([
random.choice... | {
"repo_name": "simleo/pydoop",
"path": "examples/avro/py/create_input.py",
"copies": "2",
"size": "1183",
"license": "apache-2.0",
"hash": -2713609799156479000,
"line_mean": 27.1666666667,
"line_max": 77,
"alpha_frac": 0.652578191,
"autogenerated": false,
"ratio": 3.3512747875354107,
"config_te... |
import string
DRIVER_TEMPLATE = string.Template("""\
import sys
import os
import inspect
sys.path.insert(0, os.getcwd())
import pydoop.mapreduce.api as api # noqa: E402
import pydoop.mapreduce.pipes as pipes # noqa: E402
import ${module} # noqa: E402
class ContextWriter(object):
def __init__(self, context... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/app/script_template.py",
"copies": "2",
"size": "4964",
"license": "apache-2.0",
"hash": 8117345730425251000,
"line_mean": 30.417721519,
"line_max": 77,
"alpha_frac": 0.64544722,
"autogenerated": false,
"ratio": 3.6128093158660843,
"config_test": f... |
import sys
import csv
from operator import itemgetter
LIMIT = 10
def main(argv):
with open(argv[1]) as f:
reader = csv.reader(f, delimiter='\t')
data = [(k, int(v)) for (k, v) in reader]
data.sort(key=itemgetter(1), reverse=True)
for i, t in enumerate(data):
sys.stdou... | {
"repo_name": "simleo/pydoop",
"path": "examples/avro/py/show_kmer_count.py",
"copies": "2",
"size": "1053",
"license": "apache-2.0",
"hash": -7179343022540029000,
"line_mean": 26.7105263158,
"line_max": 77,
"alpha_frac": 0.6628679962,
"autogenerated": false,
"ratio": 3.5816326530612246,
"confi... |
import sys
import csv
import avro.schema
from avro.datafile import DataFileWriter
from avro.io import DatumWriter
parse = avro.schema.Parse if sys.version_info[0] == 3 else avro.schema.parse
FIELDS = ['name', 'office', 'favorite_color']
def main(schema_fn, csv_fn, avro_fn):
with open(schema_fn) as f_in:
... | {
"repo_name": "crs4/pydoop",
"path": "examples/avro/py/write_avro.py",
"copies": "2",
"size": "1525",
"license": "apache-2.0",
"hash": -1360638859785228500,
"line_mean": 28.9019607843,
"line_max": 77,
"alpha_frac": 0.6642622951,
"autogenerated": false,
"ratio": 3.3664459161147904,
"config_test"... |
import sys
import logging
logging.basicConfig(level=logging.INFO)
import pydoop.hadut as hadut
import pydoop.test_support as pts
def get_res(output_dir):
all_data = hadut.collect_output(output_dir)
return pts.parse_mr_output(all_data, vtype=int)
def check(measured_res, expected_res):
res = pts.compar... | {
"repo_name": "simleo/pydoop",
"path": "examples/input_format/check_results.py",
"copies": "2",
"size": "1436",
"license": "apache-2.0",
"hash": 5390800480689787000,
"line_mean": 25.5925925926,
"line_max": 77,
"alpha_frac": 0.7082172702,
"autogenerated": false,
"ratio": 3.4109263657957243,
"con... |
import sys
import os
import argparse
from collections import Counter
import pydoop.hadut as hadut
import pydoop.hdfs as hdfs
import pydoop.test_support as pts
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
DEFAULT_INPUT_DIR = os.path.join(THIS_DIR, os.pardir, "input")
CHECKS = [
"base_histogram",
"cas... | {
"repo_name": "simleo/pydoop",
"path": "examples/pydoop_script/check.py",
"copies": "2",
"size": "4279",
"license": "apache-2.0",
"hash": -2892820518677836000,
"line_mean": 29.7841726619,
"line_max": 79,
"alpha_frac": 0.6274830568,
"autogenerated": false,
"ratio": 3.356078431372549,
"config_tes... |
import sys
import os
import errno
from collections import Counter
from avro.io import DatumReader
from avro.datafile import DataFileReader
from pydoop.utils.py3compat import iteritems
def iter_fnames(path):
try:
contents = os.listdir(path)
except OSError as e:
if e.errno == errno.ENOTDIR:
... | {
"repo_name": "simleo/pydoop",
"path": "examples/avro/py/check_cc.py",
"copies": "2",
"size": "1937",
"license": "apache-2.0",
"hash": 4145267013470921700,
"line_mean": 27.4852941176,
"line_max": 77,
"alpha_frac": 0.6097057305,
"autogenerated": false,
"ratio": 3.668560606060606,
"config_test": ... |
import sys
import os
import errno
from collections import Counter
from pydoop.utils.py3compat import iteritems
def iter_lines(path):
try:
contents = os.listdir(path)
except OSError as e:
if e.errno == errno.ENOTDIR:
contents = [path]
for name in contents:
with open(os... | {
"repo_name": "crs4/pydoop",
"path": "examples/avro/py/check_results.py",
"copies": "2",
"size": "1677",
"license": "apache-2.0",
"hash": -356006200205588160,
"line_mean": 26.4918032787,
"line_max": 77,
"alpha_frac": 0.6231365534,
"autogenerated": false,
"ratio": 3.5756929637526653,
"config_tes... |
import sys
import os
import unittest
import uuid
import shutil
import operator
import array
from ctypes import create_string_buffer
import pydoop.hdfs as hdfs
import pydoop.test_utils as utils
from pydoop.utils.py3compat import _is_py3
class TestCommon(unittest.TestCase):
def __init__(self, target, hdfs_host='... | {
"repo_name": "simleo/pydoop",
"path": "test/hdfs/common_hdfs_tests.py",
"copies": "2",
"size": "23113",
"license": "apache-2.0",
"hash": -228667528602133600,
"line_mean": 36.8901639344,
"line_max": 79,
"alpha_frac": 0.5618915762,
"autogenerated": false,
"ratio": 3.5806351665375677,
"config_tes... |
import sys
import random
import avro.schema
from avro.datafile import DataFileWriter
from avro.io import DatumWriter
if sys.version_info[0] == 3:
xrange = range
parse = avro.schema.Parse
else:
parse = avro.schema.parse
NAME_POOL = ['george', 'john', 'paul', 'ringo']
OFFICE_POOL = ['office-%d' % _ for _ ... | {
"repo_name": "simleo/pydoop",
"path": "examples/avro/py/generate_avro_users.py",
"copies": "2",
"size": "1721",
"license": "apache-2.0",
"hash": -4510838273641661400,
"line_mean": 28.1694915254,
"line_max": 77,
"alpha_frac": 0.6380011621,
"autogenerated": false,
"ratio": 3.435129740518962,
"co... |
import sys
import re
import logging
from collections import Counter
logging.basicConfig(level=logging.INFO)
import pydoop.hdfs as hdfs
import pydoop.test_support as pts
import pydoop.hadut as hadut
def compute_vc(input_dir):
data = []
for path in hdfs.ls(input_dir):
with hdfs.open(path, 'rt') as f:... | {
"repo_name": "crs4/pydoop",
"path": "examples/self_contained/check_results.py",
"copies": "2",
"size": "1707",
"license": "apache-2.0",
"hash": -819072726286611300,
"line_mean": 25.2615384615,
"line_max": 77,
"alpha_frac": 0.6930287053,
"autogenerated": false,
"ratio": 3.3602362204724407,
"con... |
import sys
import unittest
from pydoop.test_utils import get_module
TEST_MODULE_NAMES = [
'test_hadoop_utils',
'test_hadut',
'test_pydoop',
]
def suite(path=None):
suites = []
for module in TEST_MODULE_NAMES:
suites.append(get_module(module, path).suite())
return unittest.TestSuite... | {
"repo_name": "simleo/pydoop",
"path": "test/common/all_tests.py",
"copies": "2",
"size": "1095",
"license": "apache-2.0",
"hash": 2596131526825890000,
"line_mean": 23.3333333333,
"line_max": 77,
"alpha_frac": 0.7105022831,
"autogenerated": false,
"ratio": 3.6258278145695364,
"config_test": tru... |
import sys
from avro.io import DatumReader
from avro.datafile import DataFileReader
def main(fn, out_fn, avro_mode=''):
with open(out_fn, 'w') as fo:
with open(fn, 'rb') as f:
reader = DataFileReader(f, DatumReader())
for r in reader:
if avro_mode.upper() == 'KV':... | {
"repo_name": "crs4/pydoop",
"path": "examples/avro/py/avro_container_dump_results.py",
"copies": "2",
"size": "1109",
"license": "apache-2.0",
"hash": 3710244477270306000,
"line_mean": 28.1842105263,
"line_max": 77,
"alpha_frac": 0.6474301172,
"autogenerated": false,
"ratio": 3.5206349206349206,... |
import unittest
from pydoop.test_utils import get_module
TEST_MODULE_NAMES = [
'test_core',
'test_local_fs',
'test_hdfs_fs',
'test_path',
'test_hdfs',
]
def suite(path=None):
suites = []
for module in TEST_MODULE_NAMES:
suites.append(get_module(module, path).suite())
return ... | {
"repo_name": "crs4/pydoop",
"path": "test/hdfs/all_tests.py",
"copies": "2",
"size": "1105",
"license": "apache-2.0",
"hash": 7472506822709045000,
"line_mean": 25.3095238095,
"line_max": 77,
"alpha_frac": 0.7040723982,
"autogenerated": false,
"ratio": 3.622950819672131,
"config_test": true,
... |
import unittest
from pydoop.test_utils import get_module
TEST_MODULE_NAMES = [
'test_deser',
'test_streams',
]
def suite(path=None):
suites = []
for module in TEST_MODULE_NAMES:
suites.append(get_module(module, path).suite())
return unittest.TestSuite(suites)
if __name__ == '__main__'... | {
"repo_name": "simleo/pydoop",
"path": "test/sercore/all_tests.py",
"copies": "2",
"size": "1051",
"license": "apache-2.0",
"hash": -1240995841053544400,
"line_mean": 25.9487179487,
"line_max": 77,
"alpha_frac": 0.7164605138,
"autogenerated": false,
"ratio": 3.7007042253521125,
"config_test": t... |
import unittest
import getpass
import tempfile
import os
import pydoop.hdfs as hdfs
from common_hdfs_tests import TestCommon, common_tests
class TestConnection(unittest.TestCase):
def runTest(self):
current_user = getpass.getuser()
cwd = os.getcwd()
os.chdir(tempfile.gettempdir())
... | {
"repo_name": "crs4/pydoop",
"path": "test/hdfs/test_local_fs.py",
"copies": "2",
"size": "1580",
"license": "apache-2.0",
"hash": 6195005870046477000,
"line_mean": 25.7796610169,
"line_max": 77,
"alpha_frac": 0.6753164557,
"autogenerated": false,
"ratio": 3.8256658595641646,
"config_test": tru... |
import unittest
import os
import importlib
_TEST_DIRS = (
"app",
"common",
"mapreduce",
"hdfs", # run these last, in case HDFS needs time to be fully up
)
def suite():
suites = []
for dir_ in _TEST_DIRS:
module = importlib.import_module("%s.%s" % (dir_, "all_tests"))
sys.pa... | {
"repo_name": "simleo/pydoop",
"path": "test/all_tests.py",
"copies": "2",
"size": "1270",
"license": "apache-2.0",
"hash": -8999901357210833000,
"line_mean": 26.6086956522,
"line_max": 77,
"alpha_frac": 0.6716535433,
"autogenerated": false,
"ratio": 3.6079545454545454,
"config_test": true,
"... |
import unittest
import shutil
import tempfile
import os
import re
import sys
from io import StringIO, BytesIO
import pydoop.app.main as app
from pydoop.app.submit import PydoopSubmitter
def nop(x=None):
pass
class Args(object):
def __init__(self, **kwargs):
for k, v in kwargs.items():
... | {
"repo_name": "crs4/pydoop",
"path": "test/app/test_submit.py",
"copies": "2",
"size": "9209",
"license": "apache-2.0",
"hash": -4341329343268017000,
"line_mean": 34.1488549618,
"line_max": 79,
"alpha_frac": 0.5796503421,
"autogenerated": false,
"ratio": 3.775727757277573,
"config_test": true,
... |
import unittest
import uuid
from pydoop.hdfs.core import init
hdfs = init()
class TestCore(unittest.TestCase):
def test_default(self):
path = "/tmp/pydoop-test-{}".format(uuid.uuid4().hex)
fs = f = None
try:
fs = hdfs.CoreHdfsFs("default", 0)
f = fs.open_file(pat... | {
"repo_name": "simleo/pydoop",
"path": "test/hdfs/test_core.py",
"copies": "2",
"size": "1326",
"license": "apache-2.0",
"hash": -3836395712919962600,
"line_mean": 25,
"line_max": 77,
"alpha_frac": 0.6327300151,
"autogenerated": false,
"ratio": 3.6935933147632314,
"config_test": true,
"has_no... |
"""
An interface to simplify pydoop jobs submission.
"""
import os
import sys
import glob
import argparse
import logging
import uuid
logging.basicConfig(level=logging.INFO)
import pydoop
import pydoop.hdfs as hdfs
import pydoop.hadut as hadut
import pydoop.utils as utils
import pydoop.utils.conversion_tables as conv... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/app/submit.py",
"copies": "2",
"size": "22221",
"license": "apache-2.0",
"hash": 1417483565918169600,
"line_mean": 38.7513416816,
"line_max": 79,
"alpha_frac": 0.5827370505,
"autogenerated": false,
"ratio": 3.756085192697769,
"config_test": false,
... |
"""
Avro tools.
"""
# DEV NOTE: since Avro is not a requirement, do *not* import this
# module unconditionally anywhere in the main code (importing it in
# the Avro examples is OK, ofc).
import sys
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/avrolib.py",
"copies": "2",
"size": "4518",
"license": "apache-2.0",
"hash": 7682188531332369000,
"line_mean": 28.9205298013,
"line_max": 77,
"alpha_frac": 0.6363435148,
"autogenerated": false,
"ratio": 3.854948805460751,
"config_test": false,
"has... |
"""
Check that resetting the hdfs module after changing
os.environ['HADOOP_CONF_DIR'] works (i.e., Pydoop references the
correct HDFS service).
Note that it does **NOT** work if you've already instantiated an hdfs
handle, and this is NOT due to the caching system.
"""
from __future__ import print_function
import sys... | {
"repo_name": "simleo/pydoop",
"path": "test/hdfs/try_hdfs.py",
"copies": "2",
"size": "1699",
"license": "apache-2.0",
"hash": 4645587323020351000,
"line_mean": 26.8524590164,
"line_max": 77,
"alpha_frac": 0.6739258387,
"autogenerated": false,
"ratio": 3.3912175648702596,
"config_test": false,... |
"""
Common hdfs utilities.
"""
import getpass
import pwd
import grp
import sys
__is_py3 = sys.version_info >= (3, 0)
BUFSIZE = 16384
DEFAULT_PORT = 8020 # org/apache/hadoop/hdfs/server/namenode/NameNode.java
DEFAULT_USER = getpass.getuser()
# Unicode objects are encoded using this encoding:
TEXT_ENCODING = 'utf-... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/hdfs/common.py",
"copies": "2",
"size": "2455",
"license": "apache-2.0",
"hash": -4560350651531517000,
"line_mean": 24.3092783505,
"line_max": 79,
"alpha_frac": 0.6541751527,
"autogenerated": false,
"ratio": 3.563134978229318,
"config_test": false,... |
"""
Convert text to upper or lower case. By default, the program will
switch text to upper case. Set the config property
'caseswitch.case=lower' if you prefer to switch to lower case.
Set --kv-separator to the empty string when running this example.
"""
def mapper(_, record, writer, conf):
if conf['caseswitch... | {
"repo_name": "crs4/pydoop",
"path": "examples/pydoop_script/scripts/caseswitch.py",
"copies": "2",
"size": "1200",
"license": "apache-2.0",
"hash": -3781687625024267300,
"line_mean": 31.4324324324,
"line_max": 77,
"alpha_frac": 0.7025,
"autogenerated": false,
"ratio": 3.883495145631068,
"confi... |
"""
Generate an HDFS tree containing files of different block size.
"""
import sys
import random
import pydoop.hdfs as hdfs
from common import isdir, MB, TEST_ROOT
BS_RANGE = [_ * MB for _ in range(50, 101, 10)]
def treegen(fs, root, depth, span):
if isdir(fs, root) and depth > 0:
for i in range(spa... | {
"repo_name": "crs4/pydoop",
"path": "examples/hdfs/treegen.py",
"copies": "2",
"size": "2029",
"license": "apache-2.0",
"hash": -8551557629420963000,
"line_mean": 26.0533333333,
"line_max": 77,
"alpha_frac": 0.5726959093,
"autogenerated": false,
"ratio": 3.534843205574913,
"config_test": false... |
import sys
from abc import ABCMeta
_is_py3 = sys.version_info[0] == 3
__all__ = [
"ABC",
"basestring",
"bintype",
"cfilter",
"clong",
"cmap",
"configparser",
"czip",
"iteritems",
"parser_read",
"pickle",
"socketserver",
"StringIO",
"unicode",
"xchr",
]
cl... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/utils/py3compat.py",
"copies": "2",
"size": "2187",
"license": "apache-2.0",
"hash": 5537712999526189000,
"line_mean": 20.0288461538,
"line_max": 77,
"alpha_frac": 0.6611796982,
"autogenerated": false,
"ratio": 3.700507614213198,
"config_test": false... |
"""
Miscellaneous utilities for testing.
"""
from __future__ import print_function
import sys
import os
import tempfile
from pydoop.hdfs import default_is_local
from pydoop.utils.py3compat import iteritems
def __inject_pos(code, start=0):
pos = code.find("import", start)
if pos < 0:
return start
... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/test_support.py",
"copies": "2",
"size": "4659",
"license": "apache-2.0",
"hash": 3518941660990114300,
"line_mean": 28.3018867925,
"line_max": 78,
"alpha_frac": 0.5876797596,
"autogenerated": false,
"ratio": 3.4846671652954377,
"config_test": false,
... |
"""
Miscellaneous utilities.
"""
import logging
import time
import uuid
DEFAULT_LOG_LEVEL = "WARNING"
class NullHandler(logging.Handler):
def emit(self, record):
pass
class NullLogger(logging.Logger):
def __init__(self):
logging.Logger.__init__(self, "null")
self.propagate = 0
... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/utils/misc.py",
"copies": "2",
"size": "2420",
"license": "apache-2.0",
"hash": -6253880071184999000,
"line_mean": 26.5,
"line_max": 77,
"alpha_frac": 0.6276859504,
"autogenerated": false,
"ratio": 3.7288135593220337,
"config_test": false,
"has_no_... |
"""
Provides access to some functionalities available via the Hadoop shell.
"""
import os
import shlex
import subprocess
import pydoop.utils.misc as utils
import pydoop.hdfs as hdfs
from .utils.py3compat import basestring
# --- FIXME: perhaps we need a more sophisticated tool for setting args ---
GENERIC_ARGS = fr... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/hadut.py",
"copies": "2",
"size": "8153",
"license": "apache-2.0",
"hash": -5922719740016968000,
"line_mean": 33.4008438819,
"line_max": 77,
"alpha_frac": 0.601128419,
"autogenerated": false,
"ratio": 3.7850510677808726,
"config_test": false,
"ha... |
"""
Pydoop command line tool.
"""
import os
import argparse
import importlib
import sys
from pydoop.version import version
SUBMOD_NAMES = [
"script",
"submit",
]
PYDOOP_CONF_FILE = "~/.pydoop/pydoop.conf"
class PatchedArgumentParser(argparse.ArgumentParser):
"""
This is a work-around for a bug i... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/app/main.py",
"copies": "2",
"size": "2763",
"license": "apache-2.0",
"hash": 2344548072877949000,
"line_mean": 30.0449438202,
"line_max": 77,
"alpha_frac": 0.6587043069,
"autogenerated": false,
"ratio": 3.7439024390243905,
"config_test": false,
... |
"""
pydoop.hdfs.file -- HDFS File Objects
-------------------------------------
"""
import os
import io
import codecs
from pydoop.hdfs import common
def _complain_ifclosed(closed):
if closed:
raise ValueError("I/O operation on closed HDFS file object")
class FileIO(object):
"""
Instances of t... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/hdfs/file.py",
"copies": "2",
"size": "11770",
"license": "apache-2.0",
"hash": 1197058175942078200,
"line_mean": 29.0255102041,
"line_max": 79,
"alpha_frac": 0.566779949,
"autogenerated": false,
"ratio": 4.169323414806943,
"config_test": false,
... |
"""
pydoop.hdfs.fs -- File System Handles
-------------------------------------
"""
import os
import socket
import getpass
import re
import operator as ops
import io
import pydoop
from . import common
from .file import FileIO, hdfs_file, local_file, TextIOWrapper
from .core import core_hdfs_fs
# py3 compatibility
f... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/hdfs/fs.py",
"copies": "2",
"size": "20474",
"license": "apache-2.0",
"hash": -7011987842111746000,
"line_mean": 31.242519685,
"line_max": 79,
"alpha_frac": 0.5568037511,
"autogenerated": false,
"ratio": 4.001172562048075,
"config_test": false,
"... |
"""
pydoop.hdfs.path -- Path Name Manipulations
-------------------------------------------
"""
import os
import re
import time
from . import common, fs as hdfs_fs
from pydoop.utils.py3compat import clong
curdir, pardir, sep = '.', '..', '/' # pylint: disable=C0103
class StatResult(object):
"""
Mimics t... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/hdfs/path.py",
"copies": "2",
"size": "15531",
"license": "apache-2.0",
"hash": 2752434193119374000,
"line_mean": 27.3412408759,
"line_max": 78,
"alpha_frac": 0.5794861889,
"autogenerated": false,
"ratio": 3.641500586166471,
"config_test": false,
"... |
"""\
Pydoop is a Python MapReduce and HDFS API for Hadoop.
Pydoop is built on top of two C/C++ extension modules: a libhdfs wrapper and a
(de)serialization library for types used by the Hadoop Pipes protocol. Since
libhdfs is, in turn, a JNI wrapper for the HDFS Java code, Pydoop needs a JDK
(a JRE is not enough) to ... | {
"repo_name": "crs4/pydoop",
"path": "setup.py",
"copies": "2",
"size": "11899",
"license": "apache-2.0",
"hash": -2694267748474056000,
"line_mean": 31.2466124661,
"line_max": 79,
"alpha_frac": 0.6061853937,
"autogenerated": false,
"ratio": 3.5350564468211525,
"config_test": true,
"has_no_key... |
"""
Pydoop Script
=============
A quick and easy to use interface for running simple MapReduce jobs.
Pydoop script is a front-end to pydoop submit that automatically builds
a map-reduce program using functions contained in a user provided
python module.
"""
import os
import pydoop.utils as utils
import argparse
fr... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/app/script.py",
"copies": "2",
"size": "5865",
"license": "apache-2.0",
"hash": 1155647420279258400,
"line_mean": 35.2037037037,
"line_max": 78,
"alpha_frac": 0.6460358056,
"autogenerated": false,
"ratio": 3.9204545454545454,
"config_test": false,
... |
"""\
Set up communication channels with the MapReduce framework.
If "mapreduce.pipes.command.port" is in the env, this is a "real" Hadoop task:
we have to connect to the given port and use the socket for live communication
with the Java submitter.
If the above env variable is not defined, but "mapreduce.pipes.comman... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/mapreduce/connections.py",
"copies": "2",
"size": "3287",
"license": "apache-2.0",
"hash": 604461018961914800,
"line_mean": 30.3047619048,
"line_max": 78,
"alpha_frac": 0.6769090356,
"autogenerated": false,
"ratio": 3.857981220657277,
"config_test"... |
"""\
This module provides the base abstract classes used to develop MapReduce
application components (:class:`Mapper`, :class:`Reducer`, etc.).
"""
import json
from abc import abstractmethod
from collections import namedtuple
from pydoop.utils.py3compat import ABC
# move to pydoop.properties?
AVRO_IO_MODES = {'k',... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/mapreduce/api.py",
"copies": "2",
"size": "12621",
"license": "apache-2.0",
"hash": -1170168946176179000,
"line_mean": 26.8609271523,
"line_max": 78,
"alpha_frac": 0.6184137549,
"autogenerated": false,
"ratio": 4.389913043478261,
"config_test": false... |
"""
Traverse an HDFS tree and output disk space usage by block size.
"""
# DOCS_INCLUDE_START
import pydoop.hdfs as hdfs
from common import MB, TEST_ROOT
def usage_by_bs(fs, root):
stats = {}
for info in fs.walk(root):
if info['kind'] == 'directory':
continue
bs = int(info['block_... | {
"repo_name": "simleo/pydoop",
"path": "examples/hdfs/treewalk.py",
"copies": "2",
"size": "1283",
"license": "apache-2.0",
"hash": 467597260295880500,
"line_mean": 28.8372093023,
"line_max": 77,
"alpha_frac": 0.6484801247,
"autogenerated": false,
"ratio": 3.4489247311827955,
"config_test": fal... |
"""
Utilities for unit tests.
"""
import sys
import os
import random
import uuid
import tempfile
import imp
import unittest
import shutil
import warnings
import subprocess
import pydoop
import pydoop.utils.jvm as jvm
from pydoop.utils.py3compat import StringIO
JAVA_HOME = jvm.get_java_home()
JAVA = os.path.join(JAV... | {
"repo_name": "simleo/pydoop",
"path": "pydoop/test_utils.py",
"copies": "2",
"size": "5785",
"license": "apache-2.0",
"hash": 7602117628666668000,
"line_mean": 26.4170616114,
"line_max": 78,
"alpha_frac": 0.6100259291,
"autogenerated": false,
"ratio": 3.4149940968122787,
"config_test": true,
... |
r"""
This module allows you to connect to an HDFS installation, read and
write files and get information on files, directories and global
filesystem properties.
Configuration
-------------
The hdfs module is built on top of ``libhdfs``, in turn a JNI wrapper
around the Java fs code: therefore, for the module to wor... | {
"repo_name": "crs4/pydoop",
"path": "pydoop/hdfs/__init__.py",
"copies": "2",
"size": "11423",
"license": "apache-2.0",
"hash": 23453939700345450,
"line_mean": 28.9031413613,
"line_max": 79,
"alpha_frac": 0.5916134115,
"autogenerated": false,
"ratio": 3.536532507739938,
"config_test": false,
... |
import itertools
import operator
import numpy as np
class ArraySlice(object):
def __init__(self, avro_record):
r = avro_record
self.shape = r['shape']
self.offsets = r['offsets']
self.deltas = r['deltas']
self.__check_boundaries()
dtype = np.dtype(r['dtype'].lowe... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/bioimg.py",
"copies": "1",
"size": "4035",
"license": "apache-2.0",
"hash": -1024501633796666000,
"line_mean": 36.0183486239,
"line_max": 78,
"alpha_frac": 0.5762081784,
"autogenerated": false,
"ratio": 3.3765690376569037,
"config_test... |
import logging
LOG_LEVELS = frozenset([
"CRITICAL",
"DEBUG",
"ERROR",
"FATAL",
"INFO",
"NOTSET",
"WARN",
"WARNING",
])
LOG_FORMAT = "%(asctime)s %(levelname)s: [%(name)s] %(message)s"
def get_log_level(s):
try:
return int(s)
except ValueError:
level_name = s.u... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/app/common.py",
"copies": "1",
"size": "1799",
"license": "apache-2.0",
"hash": 7609762676471903000,
"line_mean": 25.4558823529,
"line_max": 77,
"alpha_frac": 0.6575875486,
"autogenerated": false,
"ratio": 3.678936605316973,
"config_te... |
import unittest
import operator
import numpy as np
import pyfeatures.bioimg as bioimg
def make_random_values(dtype, size):
try:
info = np.iinfo(dtype)
except ValueError:
info = np.finfo(dtype)
x = np.random.ranf(size)
return (x - .5) * info.max * 2 # info.max - info.min over... | {
"repo_name": "simleo/pydoop-features",
"path": "test/test_bioimg.py",
"copies": "1",
"size": "5215",
"license": "apache-2.0",
"hash": 765072566128466700,
"line_mean": 35.4685314685,
"line_max": 77,
"alpha_frac": 0.5729626079,
"autogenerated": false,
"ratio": 3.5,
"config_test": true,
"has_no... |
import unittest
import tempfile
import shutil
import os
from contextlib import closing
from itertools import izip
import numpy as np
from libtiff import TIFF
from avro.schema import AvroException
from wndcharm.FeatureVector import FeatureVector
from pyfeatures.feature_calc import gen_tiles, calc_features, to_avro
fr... | {
"repo_name": "simleo/pydoop-features",
"path": "test/test_feature_calc.py",
"copies": "1",
"size": "10356",
"license": "apache-2.0",
"hash": -8874278442220795000,
"line_mean": 37.7865168539,
"line_max": 77,
"alpha_frac": 0.4987446891,
"autogenerated": false,
"ratio": 2.9138998311761397,
"confi... |
import unittest
import tempfile
import shutil
import os
import pyfeatures.pyavroc_emu as pyavroc_emu
import pyfeatures.schema as schema
from pyfeatures.feature_names import FEATURE_NAMES
class Base(unittest.TestCase):
def setUp(self):
name = "img_0"
img_path = "/bar/spam/img_0.tif"
seri... | {
"repo_name": "simleo/pydoop-features",
"path": "test/test_pyavroc_emu.py",
"copies": "1",
"size": "3467",
"license": "apache-2.0",
"hash": 2219310531928198700,
"line_mean": 28.8879310345,
"line_max": 77,
"alpha_frac": 0.5863859244,
"autogenerated": false,
"ratio": 3.7319698600645856,
"config_t... |
"""
Distributed image feature calculation with wnd-charm.
"""
import pydoop.mapreduce.api as api
import pydoop.mapreduce.pipes as pp
from pydoop.avrolib import AvroContext
from pyfeatures.bioimg import BioImgPlane
from pyfeatures.feature_calc import calc_features, to_avro
class Mapper(api.Mapper):
def map(self... | {
"repo_name": "simleo/pydoop-features",
"path": "scripts/features.py",
"copies": "1",
"size": "1380",
"license": "apache-2.0",
"hash": 4338766848873135600,
"line_mean": 29.6666666667,
"line_max": 77,
"alpha_frac": 0.7086956522,
"autogenerated": false,
"ratio": 3.4158415841584158,
"config_test":... |
"""\
Dump the contents of an Avro container to a different format.
WARNING: the 'pickle' and 'json' formats read the whole Avro container
into memory in order to dump it as a single list, so they're **not**
suitable for very large files.
"""
import cPickle
import json
import os
import pprint
import shelve
import war... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/app/dump.py",
"copies": "1",
"size": "3709",
"license": "apache-2.0",
"hash": 2858359969695353300,
"line_mean": 31.252173913,
"line_max": 77,
"alpha_frac": 0.634402804,
"autogenerated": false,
"ratio": 3.6185365853658538,
"config_test"... |
"""\
Generate tiles according to the given parameters and output a
visual representation of the resulting coverage.
"""
import numpy as np
from pyfeatures.feature_calc import gen_tiles
IMG_ALPHA = 0.2
TILE_ALPHA = 0.3
MAX_SMALL_SIZE = 32
def add_parser(subparsers):
parser = subparsers.add_parser("tiles", des... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/app/tiles.py",
"copies": "1",
"size": "2925",
"license": "apache-2.0",
"hash": -756179541054250400,
"line_mean": 36.987012987,
"line_max": 78,
"alpha_frac": 0.6393162393,
"autogenerated": false,
"ratio": 3.3314350797266514,
"config_tes... |
"""\
Integrate bioimage analysis with Bio-Formats and Hadoop.
"""
import os
import glob
import shutil
import subprocess as sp
from distutils.command.build import build as BaseBuild
from distutils.errors import DistutilsSetupError
from distutils.core import setup
NAME = "pyfeatures"
DESCRIPTION = __doc__
URL = "http... | {
"repo_name": "simleo/pydoop-features",
"path": "setup.py",
"copies": "1",
"size": "2996",
"license": "apache-2.0",
"hash": -5107414219300989000,
"line_mean": 28.0873786408,
"line_max": 77,
"alpha_frac": 0.6361815754,
"autogenerated": false,
"ratio": 3.4877764842840513,
"config_test": false,
... |
"""
Minimal distributed CP example.
"""
import logging
import logging.config
logging.root.setLevel(logging.INFO)
if len(logging.root.handlers) == 0:
logging.root.addHandler(logging.StreamHandler())
import os
import uuid
import csv
import matplotlib
matplotlib.use('Agg')
import Image
import cellprofiler.prefere... | {
"repo_name": "simleo/pydoop-features",
"path": "scripts/cell_profiler_example.py",
"copies": "1",
"size": "4041",
"license": "apache-2.0",
"hash": -7684940046606131000,
"line_mean": 30.3255813953,
"line_max": 77,
"alpha_frac": 0.6295471418,
"autogenerated": false,
"ratio": 3.37876254180602,
"c... |
"""\
Non-distributed feature calculation with WND-CHARM.
Read image planes from an Avro container created with the serialize
script (which runs it.crs4.features.ImageToAvro.java), compute feature
vectors with WND-CHARM and store them to an output Avro container.
"""
import sys
import os
import warnings
import errno
... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/app/calc.py",
"copies": "1",
"size": "4951",
"license": "apache-2.0",
"hash": 5965546316260683000,
"line_mean": 40.2583333333,
"line_max": 79,
"alpha_frac": 0.5968491214,
"autogenerated": false,
"ratio": 3.8770555990602977,
"config_tes... |
"""\
Plot feature values across a given dimension.
Reads feature data from Avro containers output by 'pyfeatures calc'.
The '-f' option expects the name of a feature sub-vector, e.g.,
'haralick_textures'.
"""
import os
import sys
import errno
import cPickle
import shelve
import warnings
from contextlib import closi... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/app/plot.py",
"copies": "1",
"size": "5035",
"license": "apache-2.0",
"hash": -7505693100025757000,
"line_mean": 33.4863013699,
"line_max": 79,
"alpha_frac": 0.5733862959,
"autogenerated": false,
"ratio": 3.5160614525139664,
"config_te... |
"""\
Pyfeatures command line tool.
"""
import sys
import argparse
import importlib
from .common import get_log_level, get_logger
VERSION = "NOT_TAGGED_YET"
SUBMOD_NAMES = [
"calc",
"deserialize",
"dump",
"plot",
"serialize",
"summarize",
"tiles",
]
def log_level(s):
try:
r... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/app/main.py",
"copies": "1",
"size": "2024",
"license": "apache-2.0",
"hash": 2180953261147803400,
"line_mean": 26.7260273973,
"line_max": 77,
"alpha_frac": 0.6709486166,
"autogenerated": false,
"ratio": 3.706959706959707,
"config_test... |
"""
Quick and dirty script for converting CP results back to csv.
"""
import sys
import os
MR_OUT_DIR = sys.argv[1]
TAGS = 'IMAGE', 'CELLS', 'CYTOPLASM', 'NUCLEI'
OUTFS = dict((t, open('%s.csv' % t.title(), 'w')) for t in TAGS)
HEADER_WRITTEN = dict.fromkeys(TAGS, False)
def ser(row):
return ','.join(row) + '... | {
"repo_name": "simleo/pydoop-features",
"path": "scripts/cp_dicts_to_csv.py",
"copies": "1",
"size": "2139",
"license": "apache-2.0",
"hash": 3676541122738315300,
"line_mean": 30.4558823529,
"line_max": 77,
"alpha_frac": 0.5698924731,
"autogenerated": false,
"ratio": 3.4724025974025974,
"config... |
"""\
Serialize image data to BioImgPlane records.
All args are passed to it.crs4.features.ImageToAvro.
"""
import subprocess as sp
from pyfeatures import JAR_PATH
def run(logger, args, extra_argv=None):
if extra_argv is None:
extra_argv = []
java = ["java", "-cp", JAR_PATH]
if args.java_d:
... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/app/serialize.py",
"copies": "1",
"size": "1672",
"license": "apache-2.0",
"hash": 1865481579428984800,
"line_mean": 27.8275862069,
"line_max": 77,
"alpha_frac": 0.6668660287,
"autogenerated": false,
"ratio": 3.650655021834061,
"config... |
import logging
import os
import subprocess
import sys
import urlparse
import pydoop
import pydoop.hdfs as phdfs
EnvLogLevel = 'HADOOP_GALAXY_LOG_LEVEL'
def config_logging(log_level='INFO'):
if isinstance(log_level, basestring):
level = getattr(logging, log_level.upper())
elif log_level:
leve... | {
"repo_name": "crs4/hadoop-galaxy",
"path": "hadoop_galaxy/utils.py",
"copies": "1",
"size": "4680",
"license": "bsd-3-clause",
"hash": -3251099909396396500,
"line_mean": 33.9253731343,
"line_max": 133,
"alpha_frac": 0.6074786325,
"autogenerated": false,
"ratio": 3.820408163265306,
"config_test... |
import os
import urlparse
class Pathset(object):
"""
A collection of paths, with an associated data type.
"""
Unknown = "Unknown"
def __init__(self, *pathlist):
"""
Create a pathset. If paths are provided in pathset,
they will be sanitized and inserted into the new pathset.
"""
self.p... | {
"repo_name": "crs4/hadoop-galaxy",
"path": "hadoop_galaxy/pathset.py",
"copies": "1",
"size": "4175",
"license": "bsd-3-clause",
"hash": 704945230436558100,
"line_mean": 27.7931034483,
"line_max": 147,
"alpha_frac": 0.6299401198,
"autogenerated": false,
"ratio": 3.5806174957118353,
"config_tes... |
"""
Quick hack to compare .npy img plane dumps.
Expected file name structure: <PREFIX>-z<Z_INDEX>-c<C_INDEX>-t<T_INDEX>.npy
where indices are 0-padded to 4 digits, e.g., foo-z0022-c0001-t0000.npy
"""
import sys
import os
import glob
import re
import numpy as np
FN_PATTERN = re.compile(r'^[^-]+-z(\d+)-c(\d+)-t(\d+... | {
"repo_name": "simleo/pydoop-features",
"path": "scripts/check_planes.py",
"copies": "1",
"size": "2077",
"license": "apache-2.0",
"hash": -3788778541638539300,
"line_mean": 29.1014492754,
"line_max": 78,
"alpha_frac": 0.618199326,
"autogenerated": false,
"ratio": 3.0907738095238093,
"config_te... |
from cStringIO import StringIO
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter, BinaryDecoder, BinaryEncoder
import avro.schema
class AvroFileReader(DataFileReader):
def __init__(self, f, types=False):
if types:
raise RuntimeError('types... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/pyavroc_emu.py",
"copies": "1",
"size": "1947",
"license": "apache-2.0",
"hash": -6343933135021932000,
"line_mean": 28.5,
"line_max": 77,
"alpha_frac": 0.7000513611,
"autogenerated": false,
"ratio": 3.802734375,
"config_test": false,
... |
from itertools import izip
from wndcharm.FeatureVector import FeatureVector
from wndcharm.PyImageMatrix import PyImageMatrix
from pyfeatures.feature_names import FEATURE_NAMES
def get_image_matrix(img_array):
if len(img_array.shape) != 2:
raise ValueError("array must be two-dimensional")
image_matr... | {
"repo_name": "simleo/pydoop-features",
"path": "pyfeatures/feature_calc.py",
"copies": "1",
"size": "3106",
"license": "apache-2.0",
"hash": -3565595664343892500,
"line_mean": 33.5111111111,
"line_max": 77,
"alpha_frac": 0.6410173857,
"autogenerated": false,
"ratio": 3.3651137594799567,
"confi... |
# --- begin customization ---
# flake8: NOQA
# --- end customization ---
# -*- coding: utf-8 -*-
#
# cloudify-bigip-plugin documentation build configuration file, created by
# sphinx-quickstart on Wed Dec 3 19:29:14 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note tha... | {
"repo_name": "cloudify-examples/cloudify-bigip-plugin",
"path": "docs/conf.py",
"copies": "2",
"size": "10326",
"license": "apache-2.0",
"hash": -2380588169587346000,
"line_mean": 31.3699059561,
"line_max": 81,
"alpha_frac": 0.6987216734,
"autogenerated": false,
"ratio": 3.7590098289042593,
"c... |
# Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
# Properties, Inc., EML Research, gGmbH, University of Heidelberg,
# and The University of Manchester.
# All rights reserved.
#!/usr/bin/env python
import sys
import pdb
from xml.dom.ext.reader import Sax2
from xml.dom.ext import Print
def create... | {
"repo_name": "jonasfoe/COPASI",
"path": "copasi/sbml/unittests/scripts/compareSBMLFiles.py",
"copies": "2",
"size": "30929",
"license": "artistic-2.0",
"hash": -2640515148382417000,
"line_mean": 39.9655629139,
"line_max": 323,
"alpha_frac": 0.6370720036,
"autogenerated": false,
"ratio": 3.820753... |
# -- begin date --
#
# {{ formatDate [date] }} formats a date object into a readable string, e.g.
# "7 Jun 2016".
def format_date(ctx, date):
mo = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][date.tm_mon - 1]
return str(date.tm_mday) + " " + mo + " " + str(dat... | {
"repo_name": "qema/nanosite",
"path": "packages/blog/meta/macros.py",
"copies": "1",
"size": "2058",
"license": "mit",
"hash": -854553621915749900,
"line_mean": 33.8813559322,
"line_max": 78,
"alpha_frac": 0.545675413,
"autogenerated": false,
"ratio": 3.2822966507177034,
"config_test": false,
... |
# begin example
from layeredconfig import LayeredConfig, PyFile, Defaults
from datetime import date, datetime
conf = LayeredConfig(Defaults({'home': '/tmp/myapp',
'name': 'MyApp',
'dostuff': False,
'times': 4,
... | {
"repo_name": "staffanm/layeredconfig",
"path": "docs/examples/pyfile-example.py",
"copies": "1",
"size": "1104",
"license": "bsd-3-clause",
"hash": 8291149038645866000,
"line_mean": 37.0689655172,
"line_max": 80,
"alpha_frac": 0.4855072464,
"autogenerated": false,
"ratio": 4.181818181818182,
"... |
# BEGIN GENERATED CONTENT (do not edit below this line)
# This content is generated by ./gengl.py.
# Wrapper for http://oss.sgi.com/projects/ogl-sample/ABI/glxext.h
from OpenGL import platform, constant
from ctypes import *
c_void = None
# H (/usr/include/GL/glx.h:26)
# ARB_get_proc_address (/usr/include/GL/glx.h:32... | {
"repo_name": "Universal-Model-Converter/UMC3.0a",
"path": "data/Python/x86/Lib/site-packages/OpenGL/raw/_GLX_ARB.py",
"copies": "2",
"size": "36809",
"license": "mit",
"hash": 677988006509023600,
"line_mean": 47.0535248042,
"line_max": 182,
"alpha_frac": 0.707082507,
"autogenerated": false,
"rat... |
#Begin Hash Cracker.py
import hashlib, sys
m = hashlib.md5()
hash = ""
hash_file = raw_input("What is the file name in which the hash resides? ")
wordlist = raw_input("What is your wordlist? (Enter the file name) ")
try:
hashdocument = open(hash_file,"r")
except IOError:
print "Invalid file."
raw_input()
sys.ex... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/502296_MD5_Hash_CrackerSolver/recipe-502296.py",
"copies": "1",
"size": "1066",
"license": "mit",
"hash": 2820168669414431000,
"line_mean": 25,
"line_max": 190,
"alpha_frac": 0.7091932458,
"autogenerated": false,
"ratio": 3.063218390804597... |
#BEGIN_HEADER
#END_HEADER
class fbaModelServices:
'''
Module Name:
fbaModelServices
Module Description:
=head1 fbaModelServices
=head2 SYNOPSIS
The FBA Model Services include support related to the reconstruction, curation,
reconciliation, and analysis of metabolic models. This includes command... | {
"repo_name": "samseaver/KBaseFBAModeling",
"path": "lib/fbaModelServicesImpl.py",
"copies": "3",
"size": "50183",
"license": "mit",
"hash": 2418752225375398400,
"line_mean": 37.3955623565,
"line_max": 101,
"alpha_frac": 0.6091704362,
"autogenerated": false,
"ratio": 4.711576377804901,
"config_... |
#BEGIN_HEADER
#END_HEADER
class ranjansample:
'''
Module Name:
ranjansample
Module Description:
A KBase module: ranjansample
'''
######## WARNING FOR GEVENT USERS #######
# Since asynchronous IO can lead to methods - even the same method -
# interrupting each other, you must be *... | {
"repo_name": "pranjan77/ranjansample",
"path": "lib/ranjansample/ranjansampleImpl.py",
"copies": "1",
"size": "1449",
"license": "mit",
"hash": 2921195305090191000,
"line_mean": 28.5714285714,
"line_max": 90,
"alpha_frac": 0.5907522429,
"autogenerated": false,
"ratio": 4.28698224852071,
"confi... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class arkincount:
'''
Module Name:
arkincount
Module Description:
'''
######## WARNING FOR GEVENT USERS #######
# Since asynchronous IO can lead to methods - even the same method -
#... | {
"repo_name": "aparkin/arkincount",
"path": "lib/arkincount/arkincountImpl.py",
"copies": "1",
"size": "1631",
"license": "mit",
"hash": -2456258496205151000,
"line_mean": 33.7021276596,
"line_max": 95,
"alpha_frac": 0.6118945432,
"autogenerated": false,
"ratio": 4.314814814814815,
"config_test... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class bc_count_contigs:
'''
Module Name:
bc_count_contigs
Module Description:
A KBase module: bc_count_contigs
This sample module contains one small method - count_contigs.
'''
######## WARNING ... | {
"repo_name": "bobcottingham/bc_count_contigs",
"path": "lib/bc_count_contigs/bc_count_contigsImpl.py",
"copies": "1",
"size": "1845",
"license": "mit",
"hash": 3766908888353368600,
"line_mean": 34.4807692308,
"line_max": 95,
"alpha_frac": 0.6243902439,
"autogenerated": false,
"ratio": 4.10913140... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class CompareGeneContent:
'''
Module Name:
CompareGeneContent
Module Description:
A KBase module: CompareGeneContent
This sample module contains one small method - count_contigs.
'''
######## WA... | {
"repo_name": "mdejongh/CompareGeneContent",
"path": "lib/CompareGeneContent/CompareGeneContentImpl.py",
"copies": "2",
"size": "2344",
"license": "mit",
"hash": 4487080386622947300,
"line_mean": 39.4137931034,
"line_max": 147,
"alpha_frac": 0.6173208191,
"autogenerated": false,
"ratio": 4.170818... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class ContigCount:
'''
Module Name:
ContigCount
Module Description:
A KBase module: ContigCount
This sample module contains one small method - count_contigs.
'''
######## WARNING FOR GEVENT USER... | {
"repo_name": "levinas/kb_sdk_ContigCount",
"path": "lib/ContigCount/ContigCountImpl.py",
"copies": "1",
"size": "1703",
"license": "mit",
"hash": 1850353024999541000,
"line_mean": 33.7551020408,
"line_max": 95,
"alpha_frac": 0.6277157957,
"autogenerated": false,
"ratio": 4.236318407960199,
"co... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class contig_test:
'''
Module Name:
contig_test
Module Description:
'''
######## WARNING FOR GEVENT USERS #######
# Since asynchronous IO can lead to methods - even the same method -
... | {
"repo_name": "psdehal/contig_test",
"path": "lib/contig_test/contig_testImpl.py",
"copies": "1",
"size": "1633",
"license": "mit",
"hash": 3650086182567217700,
"line_mean": 33.7446808511,
"line_max": 95,
"alpha_frac": 0.6111451317,
"autogenerated": false,
"ratio": 4.2973684210526315,
"config_t... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class feature_sequence:
'''
Module Name:
feature_sequence
Module Description:
A KBase module: feature_sequence
This sample module contains one small method - count_contigs.
'''
######## WARNING ... | {
"repo_name": "psnovichkov/kbase_feature_sequnece",
"path": "lib/feature_sequence/feature_sequenceImpl.py",
"copies": "1",
"size": "5640",
"license": "mit",
"hash": 4074132232037837000,
"line_mean": 37.6301369863,
"line_max": 131,
"alpha_frac": 0.5476950355,
"autogenerated": false,
"ratio": 4.447... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class ff_count_contigs:
'''
Module Name:
ff_count_contigs
Module Description:
A KBase module: ff_count_contigs
This sample module contains one small method - count_contigs.
'''
######## WARNING ... | {
"repo_name": "levinas/kb_sdk_ff_count_contigs",
"path": "lib/ff_count_contigs/ff_count_contigsImpl.py",
"copies": "1",
"size": "1845",
"license": "mit",
"hash": 674029120116439900,
"line_mean": 34.4807692308,
"line_max": 95,
"alpha_frac": 0.6243902439,
"autogenerated": false,
"ratio": 4.10913140... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class filter_contigs:
'''
Module Name:
filter_contigs
Module Description:
A KBase module: filter_contigs
This sample module contains one small method - count_contigs.
'''
######## WARNING FOR GE... | {
"repo_name": "psdehal/filter_contigs",
"path": "lib/filter_contigs/filter_contigsImpl.py",
"copies": "1",
"size": "2246",
"license": "mit",
"hash": -4308186883928897000,
"line_mean": 34.6507936508,
"line_max": 95,
"alpha_frac": 0.6211041852,
"autogenerated": false,
"ratio": 4.278095238095238,
... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class MsneddonContigFilter:
'''
Module Name:
MsneddonContigFilter
Module Description:
A KBase module: MsneddonContigFilter
This sample module contains one small method - count_contigs.
'''
#####... | {
"repo_name": "msneddon/ContigFilterTest",
"path": "lib/MsneddonContigFilter/MsneddonContigFilterImpl.py",
"copies": "2",
"size": "3488",
"license": "mit",
"hash": 8290180813449503000,
"line_mean": 32.8640776699,
"line_max": 89,
"alpha_frac": 0.5412844037,
"autogenerated": false,
"ratio": 4.26405... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class nlh_test_psd_count_contigs:
'''
Module Name:
nlh_test_psd_count_contigs
Module Description:
A KBase module: nlh_test_psd_count_contigs
This sample module contains one small method - count_contigs.
... | {
"repo_name": "nlharris/nlh_test_psd_count_contigs",
"path": "lib/nlh_test_psd_count_contigs/nlh_test_psd_count_contigsImpl.py",
"copies": "1",
"size": "1875",
"license": "mit",
"hash": -966935812143380200,
"line_mean": 35.0576923077,
"line_max": 95,
"alpha_frac": 0.6272,
"autogenerated": false,
... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class paramvirdemo:
'''
Module Name:
paramvirdemo
Module Description:
A KBase module: paramvirdemo
This sample module contains one small method - count_contigs.
'''
######## WARNING FOR GEVENT U... | {
"repo_name": "pranjan77/paramvirdemo",
"path": "lib/paramvirdemo/paramvirdemoImpl.py",
"copies": "1",
"size": "1706",
"license": "mit",
"hash": -5899910990922385000,
"line_mean": 33.8163265306,
"line_max": 95,
"alpha_frac": 0.6283704572,
"autogenerated": false,
"ratio": 4.243781094527363,
"con... |
#BEGIN_HEADER
from biokbase.workspace.client import Workspace as workspaceService
#END_HEADER
class pavel_sdk_test_python:
'''
Module Name:
pavel_sdk_test_python
Module Description:
A KBase module: pavel_sdk_test_python
This sample module contains one small method - count_contigs.
'''
##... | {
"repo_name": "psnovichkov/pavel_sdk_test_python",
"path": "lib/pavel_sdk_test_python/pavel_sdk_test_pythonImpl.py",
"copies": "1",
"size": "2341",
"license": "mit",
"hash": -5375919513105853000,
"line_mean": 35.578125,
"line_max": 137,
"alpha_frac": 0.618111918,
"autogenerated": false,
"ratio": ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.