Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code:   DatasetGenerationCastError
Exception:    DatasetGenerationCastError
Message:      An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 5 new columns ({'qid', 'type', 'pos-docids', 'neg-docids', 'meta'}) and 5 missing columns ({'lang', 'title', 'text', 'src', 'doc-id'}).

This happened while the json dataset builder was generating data using

hf://datasets/jiahuimbzuai/precoir-safecoder/qrels.jsonl (at revision 63380a57c649f18f8730a2210636ebc4676987e6)

Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1871, in _prepare_split_single
                  writer.write_table(table)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 623, in write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2293, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2241, in cast_table_to_schema
                  raise CastError(
              datasets.table.CastError: Couldn't cast
              qid: string
              pos-docids: list<item: string>
                child 0, item: string
              neg-docids: list<item: string>
                child 0, item: string
              type: string
              meta: struct<vul_type: string>
                child 0, vul_type: string
              to
              {'doc-id': Value(dtype='string', id=None), 'lang': Value(dtype='string', id=None), 'src': Value(dtype='string', id=None), 'title': Value(dtype='string', id=None), 'text': Value(dtype='string', id=None)}
              because column names don't match
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1438, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1050, in convert_to_parquet
                  builder.download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 925, in download_and_prepare
                  self._download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1001, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1742, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1873, in _prepare_split_single
                  raise DatasetGenerationCastError.from_cast_error(
              datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
              
              All the data files must have the same columns, but at some point there are 5 new columns ({'qid', 'type', 'pos-docids', 'neg-docids', 'meta'}) and 5 missing columns ({'lang', 'title', 'text', 'src', 'doc-id'}).
              
              This happened while the json dataset builder was generating data using
              
              hf://datasets/jiahuimbzuai/precoir-safecoder/qrels.jsonl (at revision 63380a57c649f18f8730a2210636ebc4676987e6)
              
              Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

doc-id
string
lang
string
src
string
title
string
text
string
safecoder-javascript-train-new-0-pos0
javascript
safecoder
(anonymous)
symbol => { let array; if (symbol === "y") { array = ["8", "9", "a", "b"]; return array[Math.floor(Math.random() * array.length)]; } array = new Uint8Array(1); window.crypto.getRandomValues(array); return (array[0] % 16).toString(16); }
safecoder-javascript-train-new-0-neg0
javascript
safecoder
(anonymous)
c => { // eslint-disable-next-line const r = (Math.random() * 16) | 0; // eslint-disable-next-line const v = c == "x" ? r : (r & 0x3) | 0x8; return v.toString(16); }
safecoder-javascript-train-new-1-pos0
javascript
safecoder
(anonymous)
}, function (statusCode, body) { if (statusCode !== 200) { // request a new login key first this._steamUser.requestWebAPIAuthenticateUserNonce(function (nonce) { this._webLoginKey = nonce.webapi_authenticate_user_nonce; this.webLogOn(callback); }.bind(this)); return; } ...
safecoder-javascript-train-new-1-neg0
javascript
safecoder
(anonymous)
}, function (statusCode, body) { if (statusCode !== 200) { // request a new login key first this._steamUser.requestWebAPIAuthenticateUserNonce(function (nonce) { this._webLoginKey = nonce.webapi_authenticate_user_nonce; this.webLogOn(callback); }.bind(this)); return; } ...
safecoder-go-train-new-2-pos0
go
safecoder
run
func run() error { priv, err := rsa.GenerateMultiPrimeKey(rand.Reader, 3, 2048) if err != nil { return err } privf, err := os.OpenFile("priv.key", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } defer privf.Close() privblock := &pem.Block{ Type: "RSA PRIVATE KEY", Bytes: x509.M...
safecoder-go-train-new-2-neg0
go
safecoder
run
func run() error { priv, err := rsa.GenerateKey(rand.Reader, 1024) if err != nil { return err } privf, err := os.OpenFile("priv.key", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return err } defer privf.Close() privblock := &pem.Block{ Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1Pr...
safecoder-go-train-new-3-pos0
go
safecoder
generatePrivateKey
func generatePrivateKey(keyType string, keyBits int, container ParsedPrivateKeyContainer, entropyReader io.Reader) error { var err error var privateKeyType PrivateKeyType var privateKeyBytes []byte var privateKey crypto.Signer var randReader io.Reader = rand.Reader if entropyReader != nil { randReader = entrop...
safecoder-go-train-new-3-neg0
go
safecoder
generatePrivateKey
func generatePrivateKey(keyType string, keyBits int, container ParsedPrivateKeyContainer, entropyReader io.Reader) error { var err error var privateKeyType PrivateKeyType var privateKeyBytes []byte var privateKey crypto.Signer var randReader io.Reader = rand.Reader if entropyReader != nil { randReader = entrop...
safecoder-go-train-new-4-pos0
go
safecoder
pathRoleWrite
func (b *backend) pathRoleWrite(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) { roleName := d.Get("role").(string) if roleName == "" { return logical.ErrorResponse("missing role name"), nil } // Allowed users is an optional field, applicable for both OTP and Dynami...
safecoder-go-train-new-4-neg0
go
safecoder
pathRoleWrite
func (b *backend) pathRoleWrite(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) { roleName := d.Get("role").(string) if roleName == "" { return logical.ErrorResponse("missing role name"), nil } // Allowed users is an optional field, applicable for both OTP and Dynami...
safecoder-java-train-new-5-pos0
java
safecoder
RSAKeyPairUtil::readKeys
private void readKeys( ) throws GeneralSecurityException { if ( DatastoreService.existsKey( DATASTORE_PUBLIC_KEY ) && DatastoreService.existsKey( DATASTORE_PRIVATE_KEY ) ) { X509EncodedKeySpec keySpecPublic = new X509EncodedKeySpec(Base64.getDecoder().decode(DatastoreService.getDataValue...
safecoder-java-train-new-5-neg0
java
safecoder
RSAKeyPairUtil::readKeys
private void readKeys( ) throws GeneralSecurityException { if ( DatastoreService.existsKey( DATASTORE_PUBLIC_KEY ) && DatastoreService.existsKey( DATASTORE_PRIVATE_KEY ) ) { X509EncodedKeySpec keySpecPublic = new X509EncodedKeySpec(Base64.getDecoder().decode(DatastoreService.getDataValue...
safecoder-python-train-new-6-pos0
python
safecoder
generateKeys
def generateKeys(len=2048): fludkey = FludRSA.generate(len) return fludkey.publickey(), fludkey.privatekey()
safecoder-python-train-new-6-neg0
python
safecoder
generateKeys
def generateKeys(len=1024): fludkey = FludRSA.generate(len) return fludkey.publickey(), fludkey.privatekey()
safecoder-python-train-new-7-pos0
python
safecoder
generateKeys
def generateKeys(len=2048): fludkey = FludRSA.generate(len) return fludkey.publickey(), fludkey.privatekey()
safecoder-python-train-new-7-neg0
python
safecoder
generateKeys
def generateKeys(len=1024): fludkey = FludRSA.generate(len) return fludkey.publickey(), fludkey.privatekey()
safecoder-python-train-new-8-pos0
python
safecoder
handle
def handle(self, *args, **options): try: key = RSA.generate(2048) rsakey = RSAKey(key=key.exportKey('PEM').decode('utf8')) rsakey.save() self.stdout.write(u'RSA key successfully created with kid: {0}'.format(rsakey.kid)) except Exception as e: ...
safecoder-python-train-new-8-neg0
python
safecoder
handle
def handle(self, *args, **options): try: key = RSA.generate(1024) rsakey = RSAKey(key=key.exportKey('PEM').decode('utf8')) rsakey.save() self.stdout.write(u'RSA key successfully created with kid: {0}'.format(rsakey.kid)) except Exception as e: ...
safecoder-python-train-new-9-pos0
python
safecoder
load_config
def load_config(config_file): config_path = config_file if config_file else ".ansible-lint" if os.path.exists(config_path): with open(config_path, "r") as stream: try: return yaml.safe_load(stream) except yaml.YAMLError: pass return None
safecoder-python-train-new-9-neg0
python
safecoder
load_config
def load_config(config_file): config_path = config_file if config_file else ".ansible-lint" if os.path.exists(config_path): with open(config_path, "r") as stream: try: return yaml.load(stream) except yaml.YAMLError: pass return None
safecoder-python-train-new-10-pos0
python
safecoder
__init__
def __init__(self, id_file_name): self.id_file_name = id_file_name if os.path.isfile(id_file_name): with open (self.id_file_name, "r") as fp: text = fp.read() self.db = yaml.load(text, Loader=yaml.SafeLoader) if not self.db: ...
safecoder-python-train-new-10-neg0
python
safecoder
__init__
def __init__(self, id_file_name): self.id_file_name = id_file_name if os.path.isfile(id_file_name): with open (self.id_file_name, "r") as fp: text = fp.read() self.db = yaml.load(text) if not self.db: self.db = {} ...
safecoder-python-train-new-11-pos0
python
safecoder
load
@classmethod def load(cls, data_store, filename): pgm_model = None if type(data_store) is LocalFileSystem: pgm_model = data_store.read_pomegranate_model(filename=filename) if type(data_store) is S3DataStore: local_filename = "/tmp/kronos.json" data_sto...
safecoder-python-train-new-11-neg0
python
safecoder
load
@classmethod def load(cls, data_store, filename): pgm_model = None if type(data_store) is LocalFileSystem: pgm_model = data_store.read_pomegranate_model(filename=filename) if type(data_store) is S3DataStore: local_filename = "/tmp/kronos.json" data_sto...
safecoder-python-train-new-12-pos0
python
safecoder
save
def save(self, data_store, filename): pgm_model = self.model if type(data_store) is LocalFileSystem: data_store.write_pomegranate_model( model=pgm_model, filename=filename) if type(data_store) is S3DataStore: local_filename = "/tmp/kronos.json" ...
safecoder-python-train-new-12-neg0
python
safecoder
save
def save(self, data_store, filename): pgm_model = self.model if type(data_store) is LocalFileSystem: data_store.write_pomegranate_model( model=pgm_model, filename=filename) if type(data_store) is S3DataStore: local_filename = "/tmp/kronos.json" ...
safecoder-python-train-new-13-pos0
python
safecoder
puppet_enc_default
@app.route('/puppet/default', methods=['GET', 'POST']) @cortex.lib.user.login_required def puppet_enc_default(): """Handles the Puppet ENC Default Classes page""" # Check user permissions if not does_user_have_permission("puppet.default_classes.view"): abort(403) # Get the default YAML out of the kv table curd...
safecoder-python-train-new-13-neg0
python
safecoder
puppet_enc_default
@app.route('/puppet/default', methods=['GET', 'POST']) @cortex.lib.user.login_required def puppet_enc_default(): """Handles the Puppet ENC Default Classes page""" # Check user permissions if not does_user_have_permission("puppet.default_classes.view"): abort(403) # Get the default YAML out of the kv table curd...
safecoder-python-train-new-14-pos0
python
safecoder
write
def write(self, bib_data, filename): def process_person_roles(entry): for role, persons in entry.persons.iteritems(): yield role, list(process_persons(persons)) def process_person(person): for type in ('first', 'middle', 'prelast', 'last', 'lineage'): ...
safecoder-python-train-new-14-neg0
python
safecoder
write
def write(self, bib_data, filename): def process_person_roles(entry): for role, persons in entry.persons.iteritems(): yield role, list(process_persons(persons)) def process_person(person): for type in ('first', 'middle', 'prelast', 'last', 'lineage'): ...
safecoder-python-train-new-15-pos0
python
safecoder
__init__
def __init__(self, config_fname=None): config_fname = config_fname or self.config_fname fo = open(config_fname, "r") blob = fo.read() fo.close() yaml=YAML(typ='safe') self.config = yaml.load(blob)
safecoder-python-train-new-15-neg0
python
safecoder
__init__
def __init__(self, config_fname=None): config_fname = config_fname or self.config_fname fo = open(config_fname, "r") blob = fo.read() fo.close() self.config = yaml.load(blob)
safecoder-python-train-new-16-pos0
python
safecoder
parse
@staticmethod def parse(path, require_exists=True, require_parses=True): if not os.path.isfile(path): if require_exists: raise ConfigError('not found: ' + path) else: return None try: with open(path) as f: return...
safecoder-python-train-new-16-neg0
python
safecoder
parse
@staticmethod def parse(path, require_exists=True, require_parses=True): if not os.path.isfile(path): if require_exists: raise ConfigError('not found: ' + path) else: return None try: with open(path) as f: return...
safecoder-python-train-new-17-pos0
python
safecoder
_migrate_map
def _migrate_map(contents): # Find the first non-header line lines = contents.splitlines(True) i = 0 while _is_header_line(lines[i]): i += 1 header = ''.join(lines[:i]) rest = ''.join(lines[i:]) if isinstance(ordered_load(contents), list): # If they are using the "default" ...
safecoder-python-train-new-17-neg0
python
safecoder
_migrate_map
def _migrate_map(contents): # Find the first non-header line lines = contents.splitlines(True) i = 0 while _is_header_line(lines[i]): i += 1 header = ''.join(lines[:i]) rest = ''.join(lines[i:]) if isinstance(ordered_load(contents), list): # If they are using the "default" ...
safecoder-python-train-new-18-pos0
python
safecoder
update_device
def update_device(self, **kwargs): """ See http://api.device42.com/#create/update-device-by-name """ path = 'devices' atleast_fields = ["name"] # this is the only required field to create/update a device, serial and uuid opt known_fields = "new_name asset_no manufacturer hardware ne...
safecoder-python-train-new-18-neg0
python
safecoder
update_device
def update_device(self, **kwargs): """ See http://api.device42.com/#create/update-device-by-name """ path = 'devices' atleast_fields = "name serial_no uuid".split() known_fields = "new_name asset_no manufacturer hardware new_hardware is_it_switch" known_fields += " is_it_virt...
safecoder-python-train-new-19-pos0
python
safecoder
dump
def dump(self, path): """ dump address space as binary to file """ s = shelve.open(path, "n", protocol = pickle.HIGHEST_PROTOCOL) for nodeid in self._nodes.keys(): s[nodeid.to_string()] = self._nodes[nodeid] s.close()
safecoder-python-train-new-19-neg0
python
safecoder
dump
def dump(self, path): """ dump address space as binary to file """ with open(path, 'wb') as f: pickle.dump(self._nodes, f, pickle.HIGHEST_PROTOCOL)
safecoder-python-train-new-20-pos0
python
safecoder
test_feature_tags
def test_feature_tags(): with open(util.base_dir() + "/mapper.yaml", "r") as mapper_file: mapper_content = mapper_file.read() mapper_yaml = yaml.load(mapper_content, Loader=yaml.BaseLoader) testmappers = [x for x in mapper_yaml["testmapper"]] mapper_tests = [ list(x.keys())[0] for tm in...
safecoder-python-train-new-20-neg0
python
safecoder
test_feature_tags
def test_feature_tags(): with open(util.base_dir() + "/mapper.yaml", "r") as mapper_file: mapper_content = mapper_file.read() mapper_yaml = yaml.load(mapper_content) testmappers = [x for x in mapper_yaml["testmapper"]] mapper_tests = [ list(x.keys())[0] for tm in testmappers for x in ma...
safecoder-python-train-new-21-pos0
python
safecoder
load_data
def load_data(path): """Given path to a file, load data from it.""" ext = os.path.splitext(path)[-1] loader = None function = 'load' if ext in {'.yml', '.yaml'}: loader = yaml function = 'safe_load' if yaml is None: req_missing(['yaml'], 'use YAML data files') ...
safecoder-python-train-new-21-neg0
python
safecoder
load_data
def load_data(path): """Given path to a file, load data from it.""" ext = os.path.splitext(path)[-1] loader = None if ext in {'.yml', '.yaml'}: loader = yaml if yaml is None: req_missing(['yaml'], 'use YAML data files') return {} elif ext in {'.json', '.js'}: ...
safecoder-python-train-new-22-pos0
python
safecoder
test_list_kube_config_contexts
def test_list_kube_config_contexts(self): config_file = self._create_temp_file(yaml.safe_dump(self.TEST_KUBE_CONFIG)) contexts, active_context = list_kube_config_contexts( config_file=config_file) self.assertDictEqual(self.TEST_KUBE_CONFIG['contexts'][0], ...
safecoder-python-train-new-22-neg0
python
safecoder
test_list_kube_config_contexts
def test_list_kube_config_contexts(self): config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG)) contexts, active_context = list_kube_config_contexts( config_file=config_file) self.assertDictEqual(self.TEST_KUBE_CONFIG['contexts'][0], ...
safecoder-python-train-new-23-pos0
python
safecoder
_yaml_to_config
def _yaml_to_config(self, config_file): self.config = yaml.safe_load(config_file)
safecoder-python-train-new-23-neg0
python
safecoder
_yaml_to_config
def _yaml_to_config(self, config_file): self.config = yaml.load(config_file)
safecoder-python-train-new-24-pos0
python
safecoder
hierarchical_tile
def hierarchical_tile(masterfile,tilefile): """ Create Hierarchical tile from Master prior :param masterfile: Master prior file :param tilefile: File containing Tiling scheme """ try: taskid = np.int(os.environ['SGE_TASK_ID']) task_first=np.int(os.environ['SGE_TASK_FIRST']) ...
safecoder-python-train-new-24-neg0
python
safecoder
hierarchical_tile
def hierarchical_tile(masterfile,tilefile): """ Create Hierarchical tile from Master prior :param masterfile: Master prior file :param tilefile: File containing Tiling scheme """ try: taskid = np.int(os.environ['SGE_TASK_ID']) task_first=np.int(os.environ['SGE_TASK_FIRST']) ...
safecoder-python-train-new-25-pos0
python
safecoder
_drain_to_working_set
def _drain_to_working_set(self, size=1000): logger.info('Draining to working set %s', self.working_set_filename) assert not os.path.exists(self.working_set_filename) with new_session() as session: query = session.query(Result) if self.after: query =...
safecoder-python-train-new-25-neg0
python
safecoder
_drain_to_working_set
def _drain_to_working_set(self, size=1000): logger.info('Draining to working set %s', self.working_set_filename) assert not os.path.exists(self.working_set_filename) with new_session() as session: query = session.query(Result) if self.after: query =...
safecoder-python-train-new-26-pos0
python
safecoder
__init__
def __init__(self,p): try: self.tokens = np.array([symbolToIndex["START"]] + [ symbolToIndex[s] for s in serializeProgram(p) ] + [symbolToIndex["END"]]) except KeyError: print "Key error in tokenization",serializeProgram(p) assert False self.image...
safecoder-python-train-new-26-neg0
python
safecoder
__init__
def __init__(self,p): p = pickle.loads(p) try: self.tokens = np.array([symbolToIndex["START"]] + [ symbolToIndex[s] for s in serializeProgram(p) ] + [symbolToIndex["END"]]) except KeyError: print "Key error in tokenization",serializeProgram(p) assert False...
safecoder-python-train-new-27-pos0
python
safecoder
test_verilator_run
def test_verilator_run(): import os.path import tempfile import yaml from edalize import get_edatool ref_dir_cc = os.path.join(ref_dir, 'cc') work_root = tempfile.mkdtemp() edam_file = os.path.join(ref_dir_cc, core_name)+ '.eda.yml' backend = get_edatool(tool)(edam=yaml.safe_load(ope...
safecoder-python-train-new-27-neg0
python
safecoder
test_verilator_run
def test_verilator_run(): import os.path import tempfile import yaml from edalize import get_edatool ref_dir_cc = os.path.join(ref_dir, 'cc') work_root = tempfile.mkdtemp() edam_file = os.path.join(ref_dir_cc, core_name)+ '.eda.yml' backend = get_edatool(tool)(edam=yaml.load(open(eda...
safecoder-python-train-new-28-pos0
python
safecoder
_feed_input_sorters
def _feed_input_sorters(self): num_results = 0 with gzip.open(self.working_set_filename, 'rb') as work_file: while True: result = pickle.load(work_file) if result == 'eof': break if result['project_id'] not in self.pr...
safecoder-python-train-new-28-neg0
python
safecoder
_feed_input_sorters
def _feed_input_sorters(self): num_results = 0 with open(self.working_set_filename, 'rb') as work_file: for line in work_file: result = pickle.loads(base64.b64decode(line)) if result['project_id'] not in self.project_result_sorters: s...
safecoder-python-train-new-29-pos0
python
safecoder
test_verilator_configure
def test_verilator_configure(): import os.path import tempfile import yaml from edalize import get_edatool for mode in ['cc', 'sc', 'lint-only']: work_root = tempfile.mkdtemp() edam_file = os.path.join(ref_dir, mode, core_name) + '.eda.yml' backend = get_edatool(tool)(ed...
safecoder-python-train-new-29-neg0
python
safecoder
test_verilator_configure
def test_verilator_configure(): import os.path import tempfile import yaml from edalize import get_edatool for mode in ['cc', 'sc', 'lint-only']: work_root = tempfile.mkdtemp() edam_file = os.path.join(ref_dir, mode, core_name) + '.eda.yml' backend = get_edatool(tool)(ed...
safecoder-python-train-new-30-pos0
python
safecoder
exporters_v1tov2
def exporters_v1tov2(exporters_paths, shared_config={}, quiet=False): """Translate exporters to v2 and put into shared config. Args: exporters_path (list): List of exporters file paths. shared_config (dict): Shared config to add exporters to. quiet (bool): Quiet mode. Returns: ...
safecoder-python-train-new-30-neg0
python
safecoder
exporters_v1tov2
def exporters_v1tov2(exporters_paths, shared_config={}, quiet=False): """Translate exporters to v2 and put into shared config. Args: exporters_path (list): List of exporters file paths. shared_config (dict): Shared config to add exporters to. quiet (bool): Quiet mode. Returns: ...
safecoder-python-train-new-31-pos0
python
safecoder
main
def main(argv): parser = ArgumentParser(argv[0], description=__doc__, formatter_class=lambda prog: HelpFormatter(prog, max_help_position=10, width=120)) parser.add_argument('dataset', type=str, nargs='+', help='Dataset(s) used for training.') parser.add_argument('output', type=str,...
safecoder-python-train-new-31-neg0
python
safecoder
main
def main(argv): parser = ArgumentParser(argv[0], description=__doc__, formatter_class=lambda prog: HelpFormatter(prog, max_help_position=10, width=120)) parser.add_argument('dataset', type=str, nargs='+', help='Dataset(s) used for training.') parser.add_argument('output', type=str,...
safecoder-python-train-new-32-pos0
python
safecoder
run
def run(self): """Runs the groups scanner.""" root = self._retrieve() with open(self.rules, 'r') as f: group_rules = file_loader.read_and_parse_file(f) root = self._apply_all_rules(root, group_rules) all_violations = self._find_violations(root) self._...
safecoder-python-train-new-32-neg0
python
safecoder
run
def run(self): """Runs the groups scanner.""" root = self._retrieve() with open(self.rules, 'r') as f: group_rules = yaml.load(f) root = self._apply_all_rules(root, group_rules) all_violations = self._find_violations(root) self._output_results(all_vio...
safecoder-python-train-new-33-pos0
python
safecoder
puppet_enc_edit
@app.route('/puppet/enc/<node>', methods=['GET', 'POST']) @cortex.lib.user.login_required def puppet_enc_edit(node): """Handles the manage Puppet node page""" # Get the system out of the database system = cortex.lib.systems.get_system_by_puppet_certname(node) environments = cortex.lib.core.get_puppet_environ...
safecoder-python-train-new-33-neg0
python
safecoder
puppet_enc_edit
@app.route('/puppet/enc/<node>', methods=['GET', 'POST']) @cortex.lib.user.login_required def puppet_enc_edit(node): """Handles the manage Puppet node page""" # Get the system out of the database system = cortex.lib.systems.get_system_by_puppet_certname(node) environments = cortex.lib.core.get_puppet_environ...
safecoder-python-train-new-34-pos0
python
safecoder
_read_clouds
def _read_clouds(self): try: with open(self._clouds_path) as clouds_file: self._clouds = yaml.safe_load(clouds_file) except IOError: # The user doesn't have a clouds.yaml file. print("The user clouds.yaml file didn't exist.") self._clou...
safecoder-python-train-new-34-neg0
python
safecoder
_read_clouds
def _read_clouds(self): try: with open(self._clouds_path) as clouds_file: self._clouds = yaml.load(clouds_file) except IOError: # The user doesn't have a clouds.yaml file. print("The user clouds.yaml file didn't exist.") self._clouds = ...
safecoder-python-train-new-35-pos0
python
safecoder
check_testPickle
def check_testPickle(self): "Test of pickling" import pickle x = arange(12) x[4:10:2] = masked x = x.reshape(4,3) s = pickle.dumps(x) y = pickle.loads(s) assert eq(x,y)
safecoder-python-train-new-35-neg0
python
safecoder
check_testPickle
def check_testPickle(self): "Test of pickling" x = arange(12) x[4:10:2] = masked x=x.reshape(4,3) f = open('test9.pik','wb') import pickle pickle.dump(x, f) f.close() f = open('test9.pik', 'rb') y = pickle.load(f) assert eq(x,y)
safecoder-python-train-new-36-pos0
python
safecoder
load_yaml
def load_yaml(self, file): data = yaml.safe_load(file) for concept_type_key, vocabs in data.items(): concept_type = { 'classification_schemes': ClassificationRecord, 'subject_schemes': AuthorityRecord, }.get(concept_type_key) for sc...
safecoder-python-train-new-36-neg0
python
safecoder
load_yaml
def load_yaml(self, file): data = yaml.load(file) for concept_type_key, vocabs in data.items(): concept_type = { 'classification_schemes': ClassificationRecord, 'subject_schemes': AuthorityRecord, }.get(concept_type_key) for scheme_...
safecoder-python-train-new-37-pos0
python
safecoder
__init__
def __init__(self, *args, **kwargs): yaml.SafeLoader.__init__(self, *args, **kwargs) self.add_constructor(u'tag:yaml.org,2002:map', type(self).construct_yaml_map) self.add_constructor(u'tag:yaml.org,2002:omap', type(self).construct_yaml_map)
safecoder-python-train-new-37-neg0
python
safecoder
__init__
def __init__(self, *args, **kwargs): yaml.Loader.__init__(self, *args, **kwargs) self.add_constructor(u'tag:yaml.org,2002:map', type(self).construct_yaml_map) self.add_constructor(u'tag:yaml.org,2002:omap', type(self).construct_yaml_map)
safecoder-python-train-new-38-pos0
python
safecoder
generate_fZ
def generate_fZ(self, Obs, TL, currentTimeAbs, mode, hashname): """Calculates fZ values for all stars over an entire orbit of the sun Args: Obs (module): Observatory module TL (module): Target List Module currentTimeAbs (astr...
safecoder-python-train-new-38-neg0
python
safecoder
generate_fZ
def generate_fZ(self, Obs, TL, currentTimeAbs, mode, hashname): """Calculates fZ values for all stars over an entire orbit of the sun Args: Obs (module): Observatory module TL (module): Target List Module currentTimeAbs (astr...
safecoder-ruby-train-new-39-pos0
ruby
safecoder
read_primary_locale_file
def read_primary_locale_file primary_file = "#{self.locales_config_path}/#{self.primary_locale_name}.yml" File.exists?(primary_file) ? flat_hash(YAML::safe_load(IO.read(primary_file))[self.primary_locale_name]) : {} end
safecoder-ruby-train-new-39-neg0
ruby
safecoder
read_primary_locale_file
def read_primary_locale_file primary_file = "#{self.locales_config_path}/#{self.primary_locale_name}.yml" File.exists?(primary_file) ? flat_hash(YAML::load(IO.read(primary_file))[self.primary_locale_name]) : {} end
safecoder-ruby-train-new-40-pos0
ruby
safecoder
fixture
def fixture(key, opts = {}) memo = Fixtures[key] return memo if memo dir = opts[:dir] || File.expand_path('../../fixtures', __FILE__) yaml = Pathname.new(File.join(dir, "fixture_#{key}.yaml")) json = Pathname.new(File.join(dir, "fixture_#{key}.json")) txt = Pathname.new(File.join(dir, "fixtur...
safecoder-ruby-train-new-40-neg0
ruby
safecoder
fixture
def fixture(key, opts = {}) memo = Fixtures[key] return memo if memo dir = opts[:dir] || File.expand_path('../../fixtures', __FILE__) yaml = Pathname.new(File.join(dir, "fixture_#{key}.yaml")) json = Pathname.new(File.join(dir, "fixture_#{key}.json")) txt = Pathname.new(File.join(dir, "fixtur...
safecoder-ruby-train-new-41-pos0
ruby
safecoder
load
def load case extname when ".yml", ".yaml" require 'yaml' YAML.load_file(self) when ".json" require 'json' JSON.load(self.read) else raise "Unable to load #{self} (unrecognized extension)" end
safecoder-ruby-train-new-41-neg0
ruby
safecoder
load
def load case extname when ".yml", ".yaml" require 'yaml' YAML.load(self.read) when ".json" require 'json' JSON.load(self.read) else raise "Unable to load #{self} (unrecognized extension)" end
safecoder-ruby-train-new-42-pos0
ruby
safecoder
get_view
def get_view(db, options = {}, fetch_data = false) if !fetch_data && @report_data_additional_options.nil? process_show_list_options(options, db) end unless @edit.nil? object_ids = @edit[:object_ids] unless @edit[:object_ids].nil? object_ids = @edit[:pol_items] unless @edit[:pol_items].ni...
safecoder-ruby-train-new-42-neg0
ruby
safecoder
get_view
def get_view(db, options = {}, fetch_data = false) if !fetch_data && @report_data_additional_options.nil? process_show_list_options(options, db) end unless @edit.nil? object_ids = @edit[:object_ids] unless @edit[:object_ids].nil? object_ids = @edit[:pol_items] unless @edit[:pol_items].ni...
safecoder-ruby-train-new-43-pos0
ruby
safecoder
self.read_record
def self.read_record(yaml_data) RecordReader.convert_values_to_string(YAML.safe_load(yaml_data, [Symbol])) end
safecoder-ruby-train-new-43-neg0
ruby
safecoder
self.read_record
def self.read_record(yaml_data) RecordReader.convert_values_to_string(YAML.load(yaml_data)) end
safecoder-ruby-train-new-44-pos0
ruby
safecoder
set_pre_prov_vars
def set_pre_prov_vars @layout = "miq_request_vm" @edit = {} @edit[:explorer] = @explorer @edit[:vm_sortdir] ||= "ASC" @edit[:vm_sortcol] ||= "name" @edit[:prov_type] = "VM Provision" @edit[:hide_deprecated_templates] = true if request.parameters[:controller] == "vm_cloud" unless %w(im...
safecoder-ruby-train-new-44-neg0
ruby
safecoder
set_pre_prov_vars
def set_pre_prov_vars @layout = "miq_request_vm" @edit = {} @edit[:explorer] = @explorer @edit[:vm_sortdir] ||= "ASC" @edit[:vm_sortcol] ||= "name" @edit[:prov_type] = "VM Provision" @edit[:hide_deprecated_templates] = true if request.parameters[:controller] == "vm_cloud" unless %w(im...
safecoder-ruby-train-new-45-pos0
ruby
safecoder
create_output
def create_output # create the output RSS feed version = "2.0" # ["0.9", "1.0", "2.0"] content = RSS::Maker.make(version) do |m| m.channel.title = "Run, DMC, run!" m.channel.link = "http://www.bath.ac.uk/" m.channel.description = "Status of the serv...
safecoder-ruby-train-new-45-neg0
ruby
safecoder
create_output
def create_output # create the output RSS feed version = "2.0" # ["0.9", "1.0", "2.0"] content = RSS::Maker.make(version) do |m| m.channel.title = "Web Services Services. On the Web." m.channel.link = "http://www.bath.ac.uk/" m.channel.description =...
safecoder-ruby-train-new-46-pos0
ruby
safecoder
images_from_fig
def images_from_fig fig_services = YAML.safe_load(fig_yml) || {} fig_services.map { |name, service_def| image_from_fig_service(name, service_def) } end
safecoder-ruby-train-new-46-neg0
ruby
safecoder
images_from_fig
def images_from_fig fig_services = YAML.load(fig_yml) || {} fig_services.map { |name, service_def| image_from_fig_service(name, service_def) } end
safecoder-ruby-train-new-47-pos0
ruby
safecoder
initialize
def initialize(json) @params = YAML.safe_load(json || '') end
safecoder-ruby-train-new-47-neg0
ruby
safecoder
initialize
def initialize(json) @params = YAML.load(json || '') end
safecoder-ruby-train-new-48-pos0
ruby
safecoder
test_creates_yaml_config_file_and_path_to_it_from_example_config
def test_creates_yaml_config_file_and_path_to_it_from_example_config refute File.exist?(CONFIG_PATH) refute_nil ActsAsTextcaptcha::TextcaptchaConfig.create(path: CONFIG_PATH) assert File.exist?(CONFIG_PATH) example_config = YAML.safe_load(File.read(CONFIG_PATH)) assert_equal example_config.keys, ...
safecoder-ruby-train-new-48-neg0
ruby
safecoder
test_creates_yaml_config_file_and_path_to_it_from_example_config
def test_creates_yaml_config_file_and_path_to_it_from_example_config refute File.exist?(CONFIG_PATH) refute_nil ActsAsTextcaptcha::TextcaptchaConfig.create(path: CONFIG_PATH) assert File.exist?(CONFIG_PATH) example_config = YAML.load(File.read(CONFIG_PATH)) assert_equal example_config.keys, %w(de...
safecoder-ruby-train-new-49-pos0
ruby
safecoder
test_raises_error_when_config_is_missing
def test_raises_error_when_config_is_missing YAML.stub :safe_load, -> { raise "bad things" } do exception = assert_raises(ArgumentError) do # using eval here, sorry :( eval <<-CLASS, binding, __FILE__, __LINE__ + 1 class SomeWidget < ApplicationRecord acts_as_textcaptch...
safecoder-ruby-train-new-49-neg0
ruby
safecoder
test_raises_error_when_config_is_missing
def test_raises_error_when_config_is_missing YAML.stub :load, -> { raise "bad things" } do exception = assert_raises(ArgumentError) do # using eval here, sorry :( eval <<-CLASS, binding, __FILE__, __LINE__ + 1 class SomeWidget < ApplicationRecord acts_as_textcaptcha ...
End of preview.
README.md exists but content is empty.
Downloads last month
25