repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
casastorta/python-sar | sar/parser.py | Parser.get_sar_info | def get_sar_info(self):
"""
Returns parsed sar info
:return: ``Dictionary``-style list of SAR data
"""
try:
test = self._sarinfo["CPU"]
del test
except KeyError:
file_parsed = self.load_file()
if file_parsed:
... | python | def get_sar_info(self):
"""
Returns parsed sar info
:return: ``Dictionary``-style list of SAR data
"""
try:
test = self._sarinfo["CPU"]
del test
except KeyError:
file_parsed = self.load_file()
if file_parsed:
... | Returns parsed sar info
:return: ``Dictionary``-style list of SAR data | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L75-L97 |
casastorta/python-sar | sar/parser.py | Parser._split_file | def _split_file(self, data=''):
"""
Splits SAR output or SAR output file (in ASCII format) in order to
extract info we need for it, in the format we want.
:param data: Input data instead of file
:type data: str.
:return: ``List``-style of SAR file sections sep... | python | def _split_file(self, data=''):
"""
Splits SAR output or SAR output file (in ASCII format) in order to
extract info we need for it, in the format we want.
:param data: Input data instead of file
:type data: str.
:return: ``List``-style of SAR file sections sep... | Splits SAR output or SAR output file (in ASCII format) in order to
extract info we need for it, in the format we want.
:param data: Input data instead of file
:type data: str.
:return: ``List``-style of SAR file sections separated by
the type of info they cont... | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L99-L214 |
casastorta/python-sar | sar/parser.py | Parser._parse_file | def _parse_file(self, sar_parts):
"""
Parses splitted file to get proper information from split parts.
:param sar_parts: Array of SAR file parts
:return: ``Dictionary``-style info (but still non-parsed) \
from SAR file, split into sections we want to check
... | python | def _parse_file(self, sar_parts):
"""
Parses splitted file to get proper information from split parts.
:param sar_parts: Array of SAR file parts
:return: ``Dictionary``-style info (but still non-parsed) \
from SAR file, split into sections we want to check
... | Parses splitted file to get proper information from split parts.
:param sar_parts: Array of SAR file parts
:return: ``Dictionary``-style info (but still non-parsed) \
from SAR file, split into sections we want to check | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L216-L272 |
casastorta/python-sar | sar/parser.py | Parser.__find_column | def __find_column(self, column_names, part_first_line):
"""
Finds the column for the column_name in sar type definition,
and returns its index.
:param column_names: Names of the column we look for (regex) put in
the list
:param part_first_line: First line ... | python | def __find_column(self, column_names, part_first_line):
"""
Finds the column for the column_name in sar type definition,
and returns its index.
:param column_names: Names of the column we look for (regex) put in
the list
:param part_first_line: First line ... | Finds the column for the column_name in sar type definition,
and returns its index.
:param column_names: Names of the column we look for (regex) put in
the list
:param part_first_line: First line of the SAR part
:return: ``Dictionary`` of names => position, No... | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L274-L308 |
casastorta/python-sar | sar/parser.py | Parser.__split_info | def __split_info(self, info_part, patternsname, patterns):
"""
Splits info from SAR parts into logical stuff :-)
:param info_part: Part of SAR output we want to split into usable data
:param patternsname: ???
:param patterns: ???
:return: ``List``-style info from SAR file... | python | def __split_info(self, info_part, patternsname, patterns):
"""
Splits info from SAR parts into logical stuff :-)
:param info_part: Part of SAR output we want to split into usable data
:param patternsname: ???
:param patterns: ???
:return: ``List``-style info from SAR file... | Splits info from SAR parts into logical stuff :-)
:param info_part: Part of SAR output we want to split into usable data
:param patternsname: ???
:param patterns: ???
:return: ``List``-style info from SAR files, now finally \
completely parsed into meaningful data for further... | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L310-L403 |
casastorta/python-sar | sar/parser.py | Parser.__get_filedate | def __get_filedate(self):
"""
Parses (extracts) date of SAR data, from the SAR output file itself.
:return: ISO-style (YYYY-MM-DD) date from SAR file
"""
if os.access(self.__filename, os.R_OK):
# Read first line of the file
try:
sar_f... | python | def __get_filedate(self):
"""
Parses (extracts) date of SAR data, from the SAR output file itself.
:return: ISO-style (YYYY-MM-DD) date from SAR file
"""
if os.access(self.__filename, os.R_OK):
# Read first line of the file
try:
sar_f... | Parses (extracts) date of SAR data, from the SAR output file itself.
:return: ISO-style (YYYY-MM-DD) date from SAR file | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/sar/parser.py#L405-L445 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | _next_state | def _next_state(index, event_time, transition_set, population_view):
"""Moves a population between different states using information from a `TransitionSet`.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
... | python | def _next_state(index, event_time, transition_set, population_view):
"""Moves a population between different states using information from a `TransitionSet`.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
... | Moves a population between different states using information from a `TransitionSet`.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
When this transition is occurring.
transition_set : TransitionSet
... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L8-L41 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | _groupby_new_state | def _groupby_new_state(index, outputs, decisions):
"""Groups the simulants in the index by their new output state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
outputs : iterable
A list of possible output states.
decisions : `pa... | python | def _groupby_new_state(index, outputs, decisions):
"""Groups the simulants in the index by their new output state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
outputs : iterable
A list of possible output states.
decisions : `pa... | Groups the simulants in the index by their new output state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
outputs : iterable
A list of possible output states.
decisions : `pandas.Series`
A series containing the name of the n... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L44-L69 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | State.next_state | def next_state(self, index, event_time, population_view):
"""Moves a population between different states using information this state's `transition_set`.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pand... | python | def next_state(self, index, event_time, population_view):
"""Moves a population between different states using information this state's `transition_set`.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pand... | Moves a population between different states using information this state's `transition_set`.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
When this transition is occurring.
p... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L176-L188 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | State.transition_effect | def transition_effect(self, index, event_time, population_view):
"""Updates the simulation state and triggers any side-effects associated with entering this state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_t... | python | def transition_effect(self, index, event_time, population_view):
"""Updates the simulation state and triggers any side-effects associated with entering this state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_t... | Updates the simulation state and triggers any side-effects associated with entering this state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
The time at which this transition occurs.... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L190-L203 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | State.add_transition | def add_transition(self, output,
probability_func=lambda index: np.ones(len(index), dtype=float),
triggered=Trigger.NOT_TRIGGERED):
"""Builds a transition from this state to the given state.
output : State
The end state after the transition.
... | python | def add_transition(self, output,
probability_func=lambda index: np.ones(len(index), dtype=float),
triggered=Trigger.NOT_TRIGGERED):
"""Builds a transition from this state to the given state.
output : State
The end state after the transition.
... | Builds a transition from this state to the given state.
output : State
The end state after the transition. | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L208-L218 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | TransitionSet.setup | def setup(self, builder):
"""Performs this component's simulation setup and return sub-components.
Parameters
----------
builder : `engine.Builder`
Interface to several simulation tools including access to common random
number generation, in particular.
... | python | def setup(self, builder):
"""Performs this component's simulation setup and return sub-components.
Parameters
----------
builder : `engine.Builder`
Interface to several simulation tools including access to common random
number generation, in particular.
... | Performs this component's simulation setup and return sub-components.
Parameters
----------
builder : `engine.Builder`
Interface to several simulation tools including access to common random
number generation, in particular.
Returns
-------
itera... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L264-L279 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | TransitionSet.choose_new_state | def choose_new_state(self, index):
"""Chooses a new state for each simulant in the index.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
Returns
-------
outputs : list
The possible end stat... | python | def choose_new_state(self, index):
"""Chooses a new state for each simulant in the index.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
Returns
-------
outputs : list
The possible end stat... | Chooses a new state for each simulant in the index.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
Returns
-------
outputs : list
The possible end states of this set of transitions.
decisio... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L281-L300 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | TransitionSet._normalize_probabilities | def _normalize_probabilities(self, outputs, probabilities):
"""Normalize probabilities to sum to 1 and add a null transition if desired.
Parameters
----------
outputs : iterable
List of possible end states corresponding to this containers transitions.
probabilities :... | python | def _normalize_probabilities(self, outputs, probabilities):
"""Normalize probabilities to sum to 1 and add a null transition if desired.
Parameters
----------
outputs : iterable
List of possible end states corresponding to this containers transitions.
probabilities :... | Normalize probabilities to sum to 1 and add a null transition if desired.
Parameters
----------
outputs : iterable
List of possible end states corresponding to this containers transitions.
probabilities : iterable of iterables
A set of probability weights whose c... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L302-L331 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | Machine.setup | def setup(self, builder):
"""Performs this component's simulation setup and return sub-components.
Parameters
----------
builder : `engine.Builder`
Interface to several simulation tools including access to common random
number generation, in particular.
... | python | def setup(self, builder):
"""Performs this component's simulation setup and return sub-components.
Parameters
----------
builder : `engine.Builder`
Interface to several simulation tools including access to common random
number generation, in particular.
... | Performs this component's simulation setup and return sub-components.
Parameters
----------
builder : `engine.Builder`
Interface to several simulation tools including access to common random
number generation, in particular.
Returns
-------
itera... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L377-L392 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | Machine.transition | def transition(self, index, event_time):
"""Finds the population in each state and moves them to the next state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
The time at whic... | python | def transition(self, index, event_time):
"""Finds the population in each state and moves them to the next state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
The time at whic... | Finds the population in each state and moves them to the next state.
Parameters
----------
index : iterable of ints
An iterable of integer labels for the simulants.
event_time : pandas.Timestamp
The time at which this transition occurs. | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L399-L411 |
ihmeuw/vivarium | src/vivarium/framework/state_machine.py | Machine.to_dot | def to_dot(self):
"""Produces a ball and stick graph of this state machine.
Returns
-------
`graphviz.Digraph`
A ball and stick visualization of this state machine.
"""
from graphviz import Digraph
dot = Digraph(format='png')
for state in self... | python | def to_dot(self):
"""Produces a ball and stick graph of this state machine.
Returns
-------
`graphviz.Digraph`
A ball and stick visualization of this state machine.
"""
from graphviz import Digraph
dot = Digraph(format='png')
for state in self... | Produces a ball and stick graph of this state machine.
Returns
-------
`graphviz.Digraph`
A ball and stick visualization of this state machine. | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/state_machine.py#L418-L435 |
casastorta/python-sar | demo.py | main | def main():
from sar import parser
sysstat_dir = '/var/log/sa'
single_file = ('%s/%s' % (sysstat_dir, 'sar21'))
# Single SAR file parsing
insar = parser.Parser(single_file)
print(("SAR file date: %s" % (insar.get_filedate())))
print("Content:\n")
pprint.pprint(insar.get_sar_info())
... | python | def main():
from sar import parser
sysstat_dir = '/var/log/sa'
single_file = ('%s/%s' % (sysstat_dir, 'sar21'))
# Single SAR file parsing
insar = parser.Parser(single_file)
print(("SAR file date: %s" % (insar.get_filedate())))
print("Content:\n")
pprint.pprint(insar.get_sar_info())
... | from sar import multiparser
multi_file = ('./%s' % ('sarcombined'))
inmulti = multiparser.Multiparser(multi_file)
inmulti.load_file()
print("Content:\n")
pprint.pprint(inmulti.get_sar_info()) | https://github.com/casastorta/python-sar/blob/e6d8bb86524102d677f37e985302fad34e3297c1/demo.py#L11-L35 |
ihmeuw/vivarium | src/vivarium/framework/components/manager.py | ComponentManager.setup_components | def setup_components(self, builder, configuration):
"""Apply component level configuration defaults to the global config and run setup methods on the components
registering and setting up any child components generated in the process.
Parameters
----------
builder:
I... | python | def setup_components(self, builder, configuration):
"""Apply component level configuration defaults to the global config and run setup methods on the components
registering and setting up any child components generated in the process.
Parameters
----------
builder:
I... | Apply component level configuration defaults to the global config and run setup methods on the components
registering and setting up any child components generated in the process.
Parameters
----------
builder:
Interface to several simulation tools.
configuration:
... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/components/manager.py#L57-L69 |
datosgobar/pydatajson | pydatajson/search.py | get_datasets | def get_datasets(catalog, filter_in=None, filter_out=None, meta_field=None,
exclude_meta_fields=None, only_time_series=False):
"""Devuelve una lista de datasets del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representación externa/interna de un
... | python | def get_datasets(catalog, filter_in=None, filter_out=None, meta_field=None,
exclude_meta_fields=None, only_time_series=False):
"""Devuelve una lista de datasets del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representación externa/interna de un
... | Devuelve una lista de datasets del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representación externa/interna de un
catálogo. Una representación _externa_ es un path local o una
URL remota a un archivo con la metadata de un catálogo, en
for... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/search.py#L27-L98 |
datosgobar/pydatajson | pydatajson/search.py | get_distributions | def get_distributions(catalog, filter_in=None, filter_out=None,
meta_field=None, exclude_meta_fields=None,
only_time_series=False):
"""Devuelve lista de distribuciones del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representaci... | python | def get_distributions(catalog, filter_in=None, filter_out=None,
meta_field=None, exclude_meta_fields=None,
only_time_series=False):
"""Devuelve lista de distribuciones del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representaci... | Devuelve lista de distribuciones del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representación externa/interna de un
catálogo. Una representación _externa_ es un path local o una
URL remota a un archivo con la metadata de un catálogo, en
f... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/search.py#L101-L180 |
datosgobar/pydatajson | pydatajson/search.py | get_fields | def get_fields(catalog, filter_in=None, filter_out=None, meta_field=None,
only_time_series=False, distribution_identifier=None):
"""Devuelve lista de campos del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representación externa/interna de un
cat... | python | def get_fields(catalog, filter_in=None, filter_out=None, meta_field=None,
only_time_series=False, distribution_identifier=None):
"""Devuelve lista de campos del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representación externa/interna de un
cat... | Devuelve lista de campos del catálogo o de uno de sus metadatos.
Args:
catalog (dict, str or DataJson): Representación externa/interna de un
catálogo. Una representación _externa_ es un path local o una
URL remota a un archivo con la metadata de un catálogo, en
formato J... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/search.py#L183-L258 |
datosgobar/pydatajson | pydatajson/search.py | get_dataset | def get_dataset(catalog, identifier=None, title=None):
"""Devuelve un Dataset del catálogo."""
msg = "Se requiere un 'identifier' o 'title' para buscar el dataset."
assert identifier or title, msg
catalog = read_catalog_obj(catalog)
# búsqueda optimizada por identificador
if identifier:
... | python | def get_dataset(catalog, identifier=None, title=None):
"""Devuelve un Dataset del catálogo."""
msg = "Se requiere un 'identifier' o 'title' para buscar el dataset."
assert identifier or title, msg
catalog = read_catalog_obj(catalog)
# búsqueda optimizada por identificador
if identifier:
... | Devuelve un Dataset del catálogo. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/search.py#L308-L340 |
datosgobar/pydatajson | pydatajson/search.py | get_distribution | def get_distribution(catalog, identifier=None, title=None,
dataset_identifier=None):
"""Devuelve una Distribution del catálogo."""
msg = "Se requiere un 'identifier' o 'title' para buscar el distribution."
assert identifier or title, msg
catalog = read_catalog_obj(catalog)
# 1... | python | def get_distribution(catalog, identifier=None, title=None,
dataset_identifier=None):
"""Devuelve una Distribution del catálogo."""
msg = "Se requiere un 'identifier' o 'title' para buscar el distribution."
assert identifier or title, msg
catalog = read_catalog_obj(catalog)
# 1... | Devuelve una Distribution del catálogo. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/search.py#L354-L403 |
datosgobar/pydatajson | pydatajson/search.py | get_field | def get_field(catalog, identifier=None, title=None,
distribution_identifier=None):
"""Devuelve un Field del catálogo."""
msg = "Se requiere un 'id' o 'title' para buscar el field."
assert identifier or title, msg
# 1. BUSCA los fields en el catálogo
# búsqueda optimizada por identifi... | python | def get_field(catalog, identifier=None, title=None,
distribution_identifier=None):
"""Devuelve un Field del catálogo."""
msg = "Se requiere un 'id' o 'title' para buscar el field."
assert identifier or title, msg
# 1. BUSCA los fields en el catálogo
# búsqueda optimizada por identifi... | Devuelve un Field del catálogo. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/search.py#L447-L492 |
datosgobar/pydatajson | pydatajson/search.py | get_catalog_metadata | def get_catalog_metadata(catalog, exclude_meta_fields=None):
"""Devuelve sólo la metadata de nivel catálogo."""
exclude_meta_fields = exclude_meta_fields or []
catalog_dict_copy = catalog.copy()
del catalog_dict_copy["dataset"]
for excluded_meta_field in exclude_meta_fields:
catalog_dict_co... | python | def get_catalog_metadata(catalog, exclude_meta_fields=None):
"""Devuelve sólo la metadata de nivel catálogo."""
exclude_meta_fields = exclude_meta_fields or []
catalog_dict_copy = catalog.copy()
del catalog_dict_copy["dataset"]
for excluded_meta_field in exclude_meta_fields:
catalog_dict_co... | Devuelve sólo la metadata de nivel catálogo. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/search.py#L526-L535 |
datosgobar/pydatajson | pydatajson/documentation.py | dataset_to_markdown | def dataset_to_markdown(dataset):
"""Genera texto en markdown a partir de los metadatos de una `dataset`.
Args:
dataset (dict): Diccionario con metadatos de una `dataset`.
Returns:
str: Texto que describe una `dataset`.
"""
text_template = """
# {title}
{description}
## Recursos ... | python | def dataset_to_markdown(dataset):
"""Genera texto en markdown a partir de los metadatos de una `dataset`.
Args:
dataset (dict): Diccionario con metadatos de una `dataset`.
Returns:
str: Texto que describe una `dataset`.
"""
text_template = """
# {title}
{description}
## Recursos ... | Genera texto en markdown a partir de los metadatos de una `dataset`.
Args:
dataset (dict): Diccionario con metadatos de una `dataset`.
Returns:
str: Texto que describe una `dataset`. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/documentation.py#L15-L46 |
datosgobar/pydatajson | pydatajson/documentation.py | distribution_to_markdown | def distribution_to_markdown(distribution):
"""Genera texto en markdown a partir de los metadatos de una
`distribution`.
Args:
distribution (dict): Diccionario con metadatos de una
`distribution`.
Returns:
str: Texto que describe una `distribution`.
"""
text_template = ... | python | def distribution_to_markdown(distribution):
"""Genera texto en markdown a partir de los metadatos de una
`distribution`.
Args:
distribution (dict): Diccionario con metadatos de una
`distribution`.
Returns:
str: Texto que describe una `distribution`.
"""
text_template = ... | Genera texto en markdown a partir de los metadatos de una
`distribution`.
Args:
distribution (dict): Diccionario con metadatos de una
`distribution`.
Returns:
str: Texto que describe una `distribution`. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/documentation.py#L49-L82 |
datosgobar/pydatajson | pydatajson/documentation.py | field_to_markdown | def field_to_markdown(field):
"""Genera texto en markdown a partir de los metadatos de un `field`.
Args:
field (dict): Diccionario con metadatos de un `field`.
Returns:
str: Texto que describe un `field`.
"""
if "title" in field:
field_title = "**{}**".format(field["title"]... | python | def field_to_markdown(field):
"""Genera texto en markdown a partir de los metadatos de un `field`.
Args:
field (dict): Diccionario con metadatos de un `field`.
Returns:
str: Texto que describe un `field`.
"""
if "title" in field:
field_title = "**{}**".format(field["title"]... | Genera texto en markdown a partir de los metadatos de un `field`.
Args:
field (dict): Diccionario con metadatos de un `field`.
Returns:
str: Texto que describe un `field`. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/documentation.py#L85-L107 |
ihmeuw/vivarium | src/vivarium/interface/utilities.py | log_progress | def log_progress(sequence, every=None, size=None, name='Items'):
"""Taken from https://github.com/alexanderkuk/log-progress"""
from ipywidgets import IntProgress, HTML, VBox
from IPython.display import display
is_iterator = False
if size is None:
try:
size = len(sequence)
... | python | def log_progress(sequence, every=None, size=None, name='Items'):
"""Taken from https://github.com/alexanderkuk/log-progress"""
from ipywidgets import IntProgress, HTML, VBox
from IPython.display import display
is_iterator = False
if size is None:
try:
size = len(sequence)
... | Taken from https://github.com/alexanderkuk/log-progress | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/interface/utilities.py#L21-L76 |
datosgobar/pydatajson | pydatajson/core.py | main | def main():
"""Permite ejecutar el módulo por línea de comandos.
Valida un path o url a un archivo data.json devolviendo True/False si es
válido y luego el resultado completo.
Example:
python pydatajson.py http://181.209.63.71/data.json
python pydatajson.py ~/github/pydatajson/tests/sa... | python | def main():
"""Permite ejecutar el módulo por línea de comandos.
Valida un path o url a un archivo data.json devolviendo True/False si es
válido y luego el resultado completo.
Example:
python pydatajson.py http://181.209.63.71/data.json
python pydatajson.py ~/github/pydatajson/tests/sa... | Permite ejecutar el módulo por línea de comandos.
Valida un path o url a un archivo data.json devolviendo True/False si es
válido y luego el resultado completo.
Example:
python pydatajson.py http://181.209.63.71/data.json
python pydatajson.py ~/github/pydatajson/tests/samples/full_data.jso... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L1093-L1116 |
datosgobar/pydatajson | pydatajson/core.py | DataJson._build_index | def _build_index(self):
"""Itera todos los datasets, distribucioens y fields indexandolos."""
datasets_index = {}
distributions_index = {}
fields_index = {}
# recorre todos los datasets
for dataset_index, dataset in enumerate(self.datasets):
if "identifier" ... | python | def _build_index(self):
"""Itera todos los datasets, distribucioens y fields indexandolos."""
datasets_index = {}
distributions_index = {}
fields_index = {}
# recorre todos los datasets
for dataset_index, dataset in enumerate(self.datasets):
if "identifier" ... | Itera todos los datasets, distribucioens y fields indexandolos. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L153-L189 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.is_valid_catalog | def is_valid_catalog(self, catalog=None):
"""Valida que un archivo `data.json` cumpla con el schema definido.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
... | python | def is_valid_catalog(self, catalog=None):
"""Valida que un archivo `data.json` cumpla con el schema definido.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
... | Valida que un archivo `data.json` cumpla con el schema definido.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
catalog (str o dict): Catálogo (dict, JSON... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L231-L246 |
datosgobar/pydatajson | pydatajson/core.py | DataJson._update_validation_response | def _update_validation_response(error, response):
"""Actualiza la respuesta por default acorde a un error de
validación."""
new_response = response.copy()
# El status del catálogo entero será ERROR
new_response["status"] = "ERROR"
# Adapto la información del ValidationE... | python | def _update_validation_response(error, response):
"""Actualiza la respuesta por default acorde a un error de
validación."""
new_response = response.copy()
# El status del catálogo entero será ERROR
new_response["status"] = "ERROR"
# Adapto la información del ValidationE... | Actualiza la respuesta por default acorde a un error de
validación. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L249-L283 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.validate_catalog | def validate_catalog(self, catalog=None, only_errors=False, fmt="dict",
export_path=None):
"""Analiza un data.json registrando los errores que encuentra.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales... | python | def validate_catalog(self, catalog=None, only_errors=False, fmt="dict",
export_path=None):
"""Analiza un data.json registrando los errores que encuentra.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales... | Analiza un data.json registrando los errores que encuentra.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
catalog (str o dict): Catálogo (dict, JSON o XL... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L285-L338 |
datosgobar/pydatajson | pydatajson/core.py | DataJson._dataset_report_helper | def _dataset_report_helper(cls, dataset, catalog_homepage=None):
"""Toma un dict con la metadata de un dataset, y devuelve un dict coni
los valores que dataset_report() usa para reportar sobre él.
Args:
dataset (dict): Diccionario con la metadata de un dataset.
Returns:
... | python | def _dataset_report_helper(cls, dataset, catalog_homepage=None):
"""Toma un dict con la metadata de un dataset, y devuelve un dict coni
los valores que dataset_report() usa para reportar sobre él.
Args:
dataset (dict): Diccionario con la metadata de un dataset.
Returns:
... | Toma un dict con la metadata de un dataset, y devuelve un dict coni
los valores que dataset_report() usa para reportar sobre él.
Args:
dataset (dict): Diccionario con la metadata de un dataset.
Returns:
dict: Diccionario con los campos a nivel dataset que requiere
... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L355-L415 |
datosgobar/pydatajson | pydatajson/core.py | DataJson._catalog_report_helper | def _catalog_report_helper(catalog, catalog_validation, url, catalog_id,
catalog_org):
"""Toma un dict con la metadata de un catálogo, y devuelve un dict con
los valores que catalog_report() usa para reportar sobre él.
Args:
catalog (dict): Diccionario... | python | def _catalog_report_helper(catalog, catalog_validation, url, catalog_id,
catalog_org):
"""Toma un dict con la metadata de un catálogo, y devuelve un dict con
los valores que catalog_report() usa para reportar sobre él.
Args:
catalog (dict): Diccionario... | Toma un dict con la metadata de un catálogo, y devuelve un dict con
los valores que catalog_report() usa para reportar sobre él.
Args:
catalog (dict): Diccionario con la metadata de un catálogo.
validation (dict): Resultado, únicamente a nivel catálogo, de la
val... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L423-L446 |
datosgobar/pydatajson | pydatajson/core.py | DataJson._dataset_report | def _dataset_report(
self, dataset, dataset_validation, dataset_index,
catalog_fields, harvest='none', report=None, catalog_homepage=None
):
""" Genera una línea del `catalog_report`, correspondiente a un dataset
de los que conforman el catálogo analizado."""
# hace ... | python | def _dataset_report(
self, dataset, dataset_validation, dataset_index,
catalog_fields, harvest='none', report=None, catalog_homepage=None
):
""" Genera una línea del `catalog_report`, correspondiente a un dataset
de los que conforman el catálogo analizado."""
# hace ... | Genera una línea del `catalog_report`, correspondiente a un dataset
de los que conforman el catálogo analizado. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L448-L499 |
datosgobar/pydatajson | pydatajson/core.py | DataJson._dataset_qa | def _dataset_qa(self, dataset):
"""Chequea si el dataset tiene una calidad mínima para cosechar."""
# 1. VALIDACIONES
# chequea que haya por lo menos algún formato de datos reconocido
has_data_format = helpers.dataset_has_data_distributions(dataset)
# chequea que algunos campos... | python | def _dataset_qa(self, dataset):
"""Chequea si el dataset tiene una calidad mínima para cosechar."""
# 1. VALIDACIONES
# chequea que haya por lo menos algún formato de datos reconocido
has_data_format = helpers.dataset_has_data_distributions(dataset)
# chequea que algunos campos... | Chequea si el dataset tiene una calidad mínima para cosechar. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L501-L542 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.catalog_report | def catalog_report(self, catalog, harvest='none', report=None,
catalog_id=None, catalog_homepage=None,
catalog_org=None):
"""Genera un reporte sobre los datasets de un único catálogo.
Args:
catalog (dict, str o unicode): Representación externa (... | python | def catalog_report(self, catalog, harvest='none', report=None,
catalog_id=None, catalog_homepage=None,
catalog_org=None):
"""Genera un reporte sobre los datasets de un único catálogo.
Args:
catalog (dict, str o unicode): Representación externa (... | Genera un reporte sobre los datasets de un único catálogo.
Args:
catalog (dict, str o unicode): Representación externa (path/URL) o
interna (dict) de un catálogo.
harvest (str): Criterio de cosecha ('all', 'none',
'valid', 'report' o 'good').
Ret... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L544-L586 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.generate_datasets_report | def generate_datasets_report(
self, catalogs, harvest='valid', report=None,
export_path=None, catalog_ids=None, catalog_homepages=None,
catalog_orgs=None
):
"""Genera un reporte sobre las condiciones de la metadata de los
datasets contenidos en uno o varios catálo... | python | def generate_datasets_report(
self, catalogs, harvest='valid', report=None,
export_path=None, catalog_ids=None, catalog_homepages=None,
catalog_orgs=None
):
"""Genera un reporte sobre las condiciones de la metadata de los
datasets contenidos en uno o varios catálo... | Genera un reporte sobre las condiciones de la metadata de los
datasets contenidos en uno o varios catálogos.
Args:
catalogs (str, dict o list): Uno (str o dict) o varios (list de
strs y/o dicts) catálogos.
harvest (str): Criterio a utilizar para determinar el val... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L588-L690 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.generate_harvester_config | def generate_harvester_config(self, catalogs=None, harvest='valid',
report=None, export_path=None):
"""Genera un archivo de configuración del harvester a partir de un
reporte, o de un conjunto de catálogos y un criterio de cosecha
(`harvest`).
Args:
... | python | def generate_harvester_config(self, catalogs=None, harvest='valid',
report=None, export_path=None):
"""Genera un archivo de configuración del harvester a partir de un
reporte, o de un conjunto de catálogos y un criterio de cosecha
(`harvest`).
Args:
... | Genera un archivo de configuración del harvester a partir de un
reporte, o de un conjunto de catálogos y un criterio de cosecha
(`harvest`).
Args:
catalogs (str, dict o list): Uno (str o dict) o varios (list de
strs y/o dicts) catálogos.
harvest (str): Cr... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L692-L769 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.generate_harvestable_catalogs | def generate_harvestable_catalogs(self, catalogs, harvest='all',
report=None, export_path=None):
"""Filtra los catálogos provistos según el criterio determinado en
`harvest`.
Args:
catalogs (str, dict o list): Uno (str o dict) o varios (list de
... | python | def generate_harvestable_catalogs(self, catalogs, harvest='all',
report=None, export_path=None):
"""Filtra los catálogos provistos según el criterio determinado en
`harvest`.
Args:
catalogs (str, dict o list): Uno (str o dict) o varios (list de
... | Filtra los catálogos provistos según el criterio determinado en
`harvest`.
Args:
catalogs (str, dict o list): Uno (str o dict) o varios (list de
strs y/o dicts) catálogos.
harvest (str): Criterio para determinar qué datasets conservar de
cada catá... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L771-L845 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.generate_datasets_summary | def generate_datasets_summary(self, catalog, export_path=None):
"""Genera un informe sobre los datasets presentes en un catálogo,
indicando para cada uno:
- Índice en la lista catalog["dataset"]
- Título
- Identificador
- Cantidad de distribuciones
... | python | def generate_datasets_summary(self, catalog, export_path=None):
"""Genera un informe sobre los datasets presentes en un catálogo,
indicando para cada uno:
- Índice en la lista catalog["dataset"]
- Título
- Identificador
- Cantidad de distribuciones
... | Genera un informe sobre los datasets presentes en un catálogo,
indicando para cada uno:
- Índice en la lista catalog["dataset"]
- Título
- Identificador
- Cantidad de distribuciones
- Estado de sus metadatos ["OK"|"ERROR"]
Es utilizada por la ... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L847-L899 |
datosgobar/pydatajson | pydatajson/core.py | DataJson._extract_datasets_to_harvest | def _extract_datasets_to_harvest(cls, report):
"""Extrae de un reporte los datos necesarios para reconocer qué
datasets marcar para cosecha en cualquier generador.
Args:
report (str o list): Reporte (lista de dicts) o path a uno.
Returns:
list: Lista de tuplas c... | python | def _extract_datasets_to_harvest(cls, report):
"""Extrae de un reporte los datos necesarios para reconocer qué
datasets marcar para cosecha en cualquier generador.
Args:
report (str o list): Reporte (lista de dicts) o path a uno.
Returns:
list: Lista de tuplas c... | Extrae de un reporte los datos necesarios para reconocer qué
datasets marcar para cosecha en cualquier generador.
Args:
report (str o list): Reporte (lista de dicts) o path a uno.
Returns:
list: Lista de tuplas con los títulos de catálogo y dataset de cada
r... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L902-L945 |
datosgobar/pydatajson | pydatajson/core.py | DataJson.generate_dataset_documentation | def generate_dataset_documentation(self, dataset_identifier,
export_path=None, catalog=None):
"""Genera texto en markdown a partir de los metadatos de una `dataset`.
Args:
dataset_identifier (str): Identificador único de un dataset.
export_... | python | def generate_dataset_documentation(self, dataset_identifier,
export_path=None, catalog=None):
"""Genera texto en markdown a partir de los metadatos de una `dataset`.
Args:
dataset_identifier (str): Identificador único de un dataset.
export_... | Genera texto en markdown a partir de los metadatos de una `dataset`.
Args:
dataset_identifier (str): Identificador único de un dataset.
export_path (str): Path donde exportar el texto generado. Si se
especifica, el método no devolverá nada.
catalog (dict, str... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/core.py#L1035-L1059 |
ihmeuw/vivarium | src/vivarium/framework/utilities.py | import_by_path | def import_by_path(path: str) -> Callable:
"""Import a class or function given it's absolute path.
Parameters
----------
path:
Path to object to import
"""
module_path, _, class_name = path.rpartition('.')
return getattr(import_module(module_path), class_name) | python | def import_by_path(path: str) -> Callable:
"""Import a class or function given it's absolute path.
Parameters
----------
path:
Path to object to import
"""
module_path, _, class_name = path.rpartition('.')
return getattr(import_module(module_path), class_name) | Import a class or function given it's absolute path.
Parameters
----------
path:
Path to object to import | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/utilities.py#L38-L48 |
datosgobar/pydatajson | pydatajson/readers.py | read_catalog | def read_catalog(catalog, default_values=None, catalog_format=None):
"""Toma una representación cualquiera de un catálogo, y devuelve su
representación interna (un diccionario de Python con su metadata.)
Si recibe una representación _interna_ (un diccionario), lo devuelve
intacto. Si recibe una represe... | python | def read_catalog(catalog, default_values=None, catalog_format=None):
"""Toma una representación cualquiera de un catálogo, y devuelve su
representación interna (un diccionario de Python con su metadata.)
Si recibe una representación _interna_ (un diccionario), lo devuelve
intacto. Si recibe una represe... | Toma una representación cualquiera de un catálogo, y devuelve su
representación interna (un diccionario de Python con su metadata.)
Si recibe una representación _interna_ (un diccionario), lo devuelve
intacto. Si recibe una representación _externa_ (path/URL a un archivo
JSON/XLSX), devuelve su represe... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L55-L107 |
datosgobar/pydatajson | pydatajson/readers.py | _apply_default_values | def _apply_default_values(catalog, default_values):
"""Aplica valores default a los campos de un catálogo.
Si el campo está vacío, aplica el default. Si tiene un valor, deja el valor
que estaba. Sólo soporta defaults para las siguientes clases:
catalog
dataset
distribution
f... | python | def _apply_default_values(catalog, default_values):
"""Aplica valores default a los campos de un catálogo.
Si el campo está vacío, aplica el default. Si tiene un valor, deja el valor
que estaba. Sólo soporta defaults para las siguientes clases:
catalog
dataset
distribution
f... | Aplica valores default a los campos de un catálogo.
Si el campo está vacío, aplica el default. Si tiene un valor, deja el valor
que estaba. Sólo soporta defaults para las siguientes clases:
catalog
dataset
distribution
field
Args:
catalog (dict): Un catálogo.
... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L110-L159 |
datosgobar/pydatajson | pydatajson/readers.py | _set_default_value | def _set_default_value(dict_obj, keys, value):
"""Setea valor en diccionario anidado, siguiendo lista de keys.
Args:
dict_obj (dict): Un diccionario anidado.
keys (list): Una lista de keys para navegar el diccionario.
value (any): Un valor para reemplazar.
"""
variable = dict_ob... | python | def _set_default_value(dict_obj, keys, value):
"""Setea valor en diccionario anidado, siguiendo lista de keys.
Args:
dict_obj (dict): Un diccionario anidado.
keys (list): Una lista de keys para navegar el diccionario.
value (any): Un valor para reemplazar.
"""
variable = dict_ob... | Setea valor en diccionario anidado, siguiendo lista de keys.
Args:
dict_obj (dict): Un diccionario anidado.
keys (list): Una lista de keys para navegar el diccionario.
value (any): Un valor para reemplazar. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L162-L182 |
datosgobar/pydatajson | pydatajson/readers.py | read_json | def read_json(json_path_or_url):
"""Toma el path a un JSON y devuelve el diccionario que representa.
Se asume que el parámetro es una URL si comienza con 'http' o 'https', o
un path local de lo contrario.
Args:
json_path_or_url (str): Path local o URL remota a un archivo de texto
p... | python | def read_json(json_path_or_url):
"""Toma el path a un JSON y devuelve el diccionario que representa.
Se asume que el parámetro es una URL si comienza con 'http' o 'https', o
un path local de lo contrario.
Args:
json_path_or_url (str): Path local o URL remota a un archivo de texto
p... | Toma el path a un JSON y devuelve el diccionario que representa.
Se asume que el parámetro es una URL si comienza con 'http' o 'https', o
un path local de lo contrario.
Args:
json_path_or_url (str): Path local o URL remota a un archivo de texto
plano en formato JSON.
Returns:
... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L185-L218 |
datosgobar/pydatajson | pydatajson/readers.py | read_xlsx_catalog | def read_xlsx_catalog(xlsx_path_or_url, logger=None):
"""Toma el path a un catálogo en formato XLSX y devuelve el diccionario
que representa.
Se asume que el parámetro es una URL si comienza con 'http' o 'https', o
un path local de lo contrario.
Args:
xlsx_path_or_url (str): Path local o U... | python | def read_xlsx_catalog(xlsx_path_or_url, logger=None):
"""Toma el path a un catálogo en formato XLSX y devuelve el diccionario
que representa.
Se asume que el parámetro es una URL si comienza con 'http' o 'https', o
un path local de lo contrario.
Args:
xlsx_path_or_url (str): Path local o U... | Toma el path a un catálogo en formato XLSX y devuelve el diccionario
que representa.
Se asume que el parámetro es una URL si comienza con 'http' o 'https', o
un path local de lo contrario.
Args:
xlsx_path_or_url (str): Path local o URL remota a un libro XLSX de
formato específico p... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L221-L259 |
datosgobar/pydatajson | pydatajson/readers.py | _make_publisher | def _make_publisher(catalog_or_dataset):
"""De estar presentes las claves necesarias, genera el diccionario
"publisher" a nivel catálogo o dataset."""
level = catalog_or_dataset
keys = [k for k in ["publisher_name", "publisher_mbox"] if k in level]
if keys:
level["publisher"] = {
... | python | def _make_publisher(catalog_or_dataset):
"""De estar presentes las claves necesarias, genera el diccionario
"publisher" a nivel catálogo o dataset."""
level = catalog_or_dataset
keys = [k for k in ["publisher_name", "publisher_mbox"] if k in level]
if keys:
level["publisher"] = {
... | De estar presentes las claves necesarias, genera el diccionario
"publisher" a nivel catálogo o dataset. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L262-L271 |
datosgobar/pydatajson | pydatajson/readers.py | _make_contact_point | def _make_contact_point(dataset):
"""De estar presentes las claves necesarias, genera el diccionario
"contactPoint" de un dataset."""
keys = [k for k in ["contactPoint_fn", "contactPoint_hasEmail"]
if k in dataset]
if keys:
dataset["contactPoint"] = {
key.replace("contact... | python | def _make_contact_point(dataset):
"""De estar presentes las claves necesarias, genera el diccionario
"contactPoint" de un dataset."""
keys = [k for k in ["contactPoint_fn", "contactPoint_hasEmail"]
if k in dataset]
if keys:
dataset["contactPoint"] = {
key.replace("contact... | De estar presentes las claves necesarias, genera el diccionario
"contactPoint" de un dataset. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L274-L283 |
datosgobar/pydatajson | pydatajson/readers.py | _get_dataset_index | def _get_dataset_index(catalog, dataset_identifier, dataset_title,
logger=None):
"""Devuelve el índice de un dataset en el catálogo en función de su
identificador"""
logger = logger or pydj_logger
matching_datasets = []
for idx, dataset in enumerate(catalog["catalog_dataset"]... | python | def _get_dataset_index(catalog, dataset_identifier, dataset_title,
logger=None):
"""Devuelve el índice de un dataset en el catálogo en función de su
identificador"""
logger = logger or pydj_logger
matching_datasets = []
for idx, dataset in enumerate(catalog["catalog_dataset"]... | Devuelve el índice de un dataset en el catálogo en función de su
identificador | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L286-L318 |
datosgobar/pydatajson | pydatajson/readers.py | _get_distribution_indexes | def _get_distribution_indexes(catalog, dataset_identifier, dataset_title,
distribution_identifier, distribution_title,
logger=None):
"""Devuelve el índice de una distribución en su dataset en función de su
título, junto con el índice de su dataset padr... | python | def _get_distribution_indexes(catalog, dataset_identifier, dataset_title,
distribution_identifier, distribution_title,
logger=None):
"""Devuelve el índice de una distribución en su dataset en función de su
título, junto con el índice de su dataset padr... | Devuelve el índice de una distribución en su dataset en función de su
título, junto con el índice de su dataset padre en el catálogo, en
función de su identificador | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L321-L366 |
datosgobar/pydatajson | pydatajson/readers.py | read_local_xlsx_catalog | def read_local_xlsx_catalog(xlsx_path, logger=None):
"""Genera un diccionario de metadatos de catálogo a partir de un XLSX bien
formado.
Args:
xlsx_path (str): Path a un archivo XLSX "template" para describir la
metadata de un catálogo.
Returns:
dict: Diccionario con los me... | python | def read_local_xlsx_catalog(xlsx_path, logger=None):
"""Genera un diccionario de metadatos de catálogo a partir de un XLSX bien
formado.
Args:
xlsx_path (str): Path a un archivo XLSX "template" para describir la
metadata de un catálogo.
Returns:
dict: Diccionario con los me... | Genera un diccionario de metadatos de catálogo a partir de un XLSX bien
formado.
Args:
xlsx_path (str): Path a un archivo XLSX "template" para describir la
metadata de un catálogo.
Returns:
dict: Diccionario con los metadatos de un catálogo. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L369-L517 |
datosgobar/pydatajson | pydatajson/readers.py | read_table | def read_table(path):
"""Lee un archivo tabular (CSV o XLSX) a una lista de diccionarios.
La extensión del archivo debe ser ".csv" o ".xlsx". En función de
ella se decidirá el método a usar para leerlo.
Si recibe una lista, comprueba que todos sus diccionarios tengan las
mismas claves y de ser así... | python | def read_table(path):
"""Lee un archivo tabular (CSV o XLSX) a una lista de diccionarios.
La extensión del archivo debe ser ".csv" o ".xlsx". En función de
ella se decidirá el método a usar para leerlo.
Si recibe una lista, comprueba que todos sus diccionarios tengan las
mismas claves y de ser así... | Lee un archivo tabular (CSV o XLSX) a una lista de diccionarios.
La extensión del archivo debe ser ".csv" o ".xlsx". En función de
ella se decidirá el método a usar para leerlo.
Si recibe una lista, comprueba que todos sus diccionarios tengan las
mismas claves y de ser así, la devuelve intacta. Levant... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L540-L577 |
datosgobar/pydatajson | pydatajson/readers.py | _read_csv_table | def _read_csv_table(path):
"""Lee un CSV a una lista de diccionarios."""
with open(path, 'rb') as csvfile:
reader = csv.DictReader(csvfile)
table = list(reader)
return table | python | def _read_csv_table(path):
"""Lee un CSV a una lista de diccionarios."""
with open(path, 'rb') as csvfile:
reader = csv.DictReader(csvfile)
table = list(reader)
return table | Lee un CSV a una lista de diccionarios. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L580-L585 |
datosgobar/pydatajson | pydatajson/readers.py | _read_xlsx_table | def _read_xlsx_table(path):
"""Lee la hoja activa de un archivo XLSX a una lista de diccionarios."""
workbook = pyxl.load_workbook(path)
worksheet = workbook.active
table = helpers.sheet_to_table(worksheet)
return table | python | def _read_xlsx_table(path):
"""Lee la hoja activa de un archivo XLSX a una lista de diccionarios."""
workbook = pyxl.load_workbook(path)
worksheet = workbook.active
table = helpers.sheet_to_table(worksheet)
return table | Lee la hoja activa de un archivo XLSX a una lista de diccionarios. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/readers.py#L588-L594 |
ihmeuw/vivarium | src/vivarium/framework/configuration.py | validate_model_specification_file | def validate_model_specification_file(file_path: str) -> str:
"""Ensures the provided file is a yaml file"""
if not os.path.isfile(file_path):
raise ConfigurationError('If you provide a model specification file, it must be a file. '
f'You provided {file_path}')
exte... | python | def validate_model_specification_file(file_path: str) -> str:
"""Ensures the provided file is a yaml file"""
if not os.path.isfile(file_path):
raise ConfigurationError('If you provide a model specification file, it must be a file. '
f'You provided {file_path}')
exte... | Ensures the provided file is a yaml file | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/framework/configuration.py#L25-L36 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigNode.get_value_with_source | def get_value_with_source(self, layer=None):
"""Returns a tuple of the value's source and the value at the specified
layer. If no layer is specified then the outer layer is used.
Parameters
----------
layer : str
Name of the layer to use. If None then the outermost w... | python | def get_value_with_source(self, layer=None):
"""Returns a tuple of the value's source and the value at the specified
layer. If no layer is specified then the outer layer is used.
Parameters
----------
layer : str
Name of the layer to use. If None then the outermost w... | Returns a tuple of the value's source and the value at the specified
layer. If no layer is specified then the outer layer is used.
Parameters
----------
layer : str
Name of the layer to use. If None then the outermost where the value
exists will be used.
... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L52-L73 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigNode.metadata | def metadata(self):
"""Returns all values and associated metadata for this node as a dict.
The value which would be selected if the node's value was requested
is indicated by the `default` flag.
"""
result = []
for layer in self._layers:
if layer in self._valu... | python | def metadata(self):
"""Returns all values and associated metadata for this node as a dict.
The value which would be selected if the node's value was requested
is indicated by the `default` flag.
"""
result = []
for layer in self._layers:
if layer in self._valu... | Returns all values and associated metadata for this node as a dict.
The value which would be selected if the node's value was requested
is indicated by the `default` flag. | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L105-L119 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigNode.set_value | def set_value(self, value, layer=None, source=None):
"""Set a value for a particular layer with optional metadata about source.
Parameters
----------
value : str
Data to store in the node.
layer : str
Name of the layer to use. If None then the outermost w... | python | def set_value(self, value, layer=None, source=None):
"""Set a value for a particular layer with optional metadata about source.
Parameters
----------
value : str
Data to store in the node.
layer : str
Name of the layer to use. If None then the outermost w... | Set a value for a particular layer with optional metadata about source.
Parameters
----------
value : str
Data to store in the node.
layer : str
Name of the layer to use. If None then the outermost where the value
exists will be used.
source :... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L121-L146 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigNode.drop_layer | def drop_layer(self, layer):
"""Removes the named layer and the value associated with it from the node.
Parameters
----------
layer : str
Name of the layer to drop.
Raises
------
TypeError
If the node is frozen
KeyError
... | python | def drop_layer(self, layer):
"""Removes the named layer and the value associated with it from the node.
Parameters
----------
layer : str
Name of the layer to drop.
Raises
------
TypeError
If the node is frozen
KeyError
... | Removes the named layer and the value associated with it from the node.
Parameters
----------
layer : str
Name of the layer to drop.
Raises
------
TypeError
If the node is frozen
KeyError
If the named layer does not exist | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L148-L166 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigNode.reset_layer | def reset_layer(self, layer):
"""Removes any value and metadata associated with the named layer.
Parameters
----------
layer : str
Name of the layer to reset.
Raises
------
TypeError
If the node is frozen
KeyError
If t... | python | def reset_layer(self, layer):
"""Removes any value and metadata associated with the named layer.
Parameters
----------
layer : str
Name of the layer to reset.
Raises
------
TypeError
If the node is frozen
KeyError
If t... | Removes any value and metadata associated with the named layer.
Parameters
----------
layer : str
Name of the layer to reset.
Raises
------
TypeError
If the node is frozen
KeyError
If the named layer does not exist | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L168-L186 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree.freeze | def freeze(self):
"""Causes the ConfigTree to become read only.
This is useful for loading and then freezing configurations that should not be modified at runtime.
"""
self.__dict__['_frozen'] = True
for child in self._children.values():
child.freeze() | python | def freeze(self):
"""Causes the ConfigTree to become read only.
This is useful for loading and then freezing configurations that should not be modified at runtime.
"""
self.__dict__['_frozen'] = True
for child in self._children.values():
child.freeze() | Causes the ConfigTree to become read only.
This is useful for loading and then freezing configurations that should not be modified at runtime. | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L222-L229 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree.get_from_layer | def get_from_layer(self, name, layer=None):
"""Get a configuration value from the named layer.
Parameters
----------
name : str
The name of the value to retrieve
layer: str
The name of the layer to retrieve the value from. If it is not supplied
... | python | def get_from_layer(self, name, layer=None):
"""Get a configuration value from the named layer.
Parameters
----------
name : str
The name of the value to retrieve
layer: str
The name of the layer to retrieve the value from. If it is not supplied
... | Get a configuration value from the named layer.
Parameters
----------
name : str
The name of the value to retrieve
layer: str
The name of the layer to retrieve the value from. If it is not supplied
then the outermost layer in which the key is defined ... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L273-L292 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree._set_with_metadata | def _set_with_metadata(self, name, value, layer=None, source=None):
"""Set a value in the named layer with the given source.
Parameters
----------
name : str
The name of the value
value
The value to store
layer : str, optional
The name... | python | def _set_with_metadata(self, name, value, layer=None, source=None):
"""Set a value in the named layer with the given source.
Parameters
----------
name : str
The name of the value
value
The value to store
layer : str, optional
The name... | Set a value in the named layer with the given source.
Parameters
----------
name : str
The name of the value
value
The value to store
layer : str, optional
The name of the layer to store the value in. If none is supplied
then the v... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L294-L326 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree.update | def update(self, data: Union[Mapping, str, bytes], layer: str=None, source: str=None):
"""Adds additional data into the ConfigTree.
Parameters
----------
data :
source data
layer :
layer to load data into. If none is supplied the outermost one is used
... | python | def update(self, data: Union[Mapping, str, bytes], layer: str=None, source: str=None):
"""Adds additional data into the ConfigTree.
Parameters
----------
data :
source data
layer :
layer to load data into. If none is supplied the outermost one is used
... | Adds additional data into the ConfigTree.
Parameters
----------
data :
source data
layer :
layer to load data into. If none is supplied the outermost one is used
source :
Source to attribute the values to
See Also
--------
... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L328-L363 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree._read_dict | def _read_dict(self, data_dict, layer=None, source=None):
"""Load a dictionary into the ConfigTree. If the dict contains nested dicts
then the values will be added recursively. See module docstring for example code.
Parameters
----------
data_dict : dict
source data
... | python | def _read_dict(self, data_dict, layer=None, source=None):
"""Load a dictionary into the ConfigTree. If the dict contains nested dicts
then the values will be added recursively. See module docstring for example code.
Parameters
----------
data_dict : dict
source data
... | Load a dictionary into the ConfigTree. If the dict contains nested dicts
then the values will be added recursively. See module docstring for example code.
Parameters
----------
data_dict : dict
source data
layer : str
layer to load data into. If none is s... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L365-L379 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree._loads | def _loads(self, data_string, layer=None, source=None):
"""Load data from a yaml formatted string.
Parameters
----------
data_string : str
yaml formatted string. The root element of the document should be
an associative array
layer : str
layer... | python | def _loads(self, data_string, layer=None, source=None):
"""Load data from a yaml formatted string.
Parameters
----------
data_string : str
yaml formatted string. The root element of the document should be
an associative array
layer : str
layer... | Load data from a yaml formatted string.
Parameters
----------
data_string : str
yaml formatted string. The root element of the document should be
an associative array
layer : str
layer to load data into. If none is supplied the outermost one is used
... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L381-L395 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree._load | def _load(self, f, layer=None, source=None):
"""Load data from a yaml formatted file.
Parameters
----------
f : str or file like object
If f is a string then it is interpreted as a path to the file to load
If it is a file like object then data is read directly fr... | python | def _load(self, f, layer=None, source=None):
"""Load data from a yaml formatted file.
Parameters
----------
f : str or file like object
If f is a string then it is interpreted as a path to the file to load
If it is a file like object then data is read directly fr... | Load data from a yaml formatted file.
Parameters
----------
f : str or file like object
If f is a string then it is interpreted as a path to the file to load
If it is a file like object then data is read directly from it.
layer : str
layer to load dat... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L397-L414 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree.metadata | def metadata(self, name):
"""Return value and metadata associated with the named value
Parameters
----------
name : str
name to retrieve. If the name contains '.'s it will be retrieved recursively
Raises
------
KeyError
if name is not def... | python | def metadata(self, name):
"""Return value and metadata associated with the named value
Parameters
----------
name : str
name to retrieve. If the name contains '.'s it will be retrieved recursively
Raises
------
KeyError
if name is not def... | Return value and metadata associated with the named value
Parameters
----------
name : str
name to retrieve. If the name contains '.'s it will be retrieved recursively
Raises
------
KeyError
if name is not defined in the ConfigTree | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L425-L445 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree.reset_layer | def reset_layer(self, layer, preserve_keys=()):
"""Removes any value and metadata associated with the named layer.
Parameters
----------
layer : str
Name of the layer to reset.
preserve_keys : list or tuple
A list of keys to skip while removing data
... | python | def reset_layer(self, layer, preserve_keys=()):
"""Removes any value and metadata associated with the named layer.
Parameters
----------
layer : str
Name of the layer to reset.
preserve_keys : list or tuple
A list of keys to skip while removing data
... | Removes any value and metadata associated with the named layer.
Parameters
----------
layer : str
Name of the layer to reset.
preserve_keys : list or tuple
A list of keys to skip while removing data
Raises
------
TypeError
If ... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L447-L464 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree.drop_layer | def drop_layer(self, layer):
"""Removes the named layer and the value associated with it from the node.
Parameters
----------
layer : str
Name of the layer to drop.
Raises
------
TypeError
If the node is frozen
KeyError
... | python | def drop_layer(self, layer):
"""Removes the named layer and the value associated with it from the node.
Parameters
----------
layer : str
Name of the layer to drop.
Raises
------
TypeError
If the node is frozen
KeyError
... | Removes the named layer and the value associated with it from the node.
Parameters
----------
layer : str
Name of the layer to drop.
Raises
------
TypeError
If the node is frozen
KeyError
If the named layer does not exist | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L481-L500 |
ihmeuw/vivarium | src/vivarium/config_tree.py | ConfigTree.unused_keys | def unused_keys(self):
"""Lists all keys which are present in the ConfigTree but which have not been accessed."""
unused = set()
for k, c in self._children.items():
if isinstance(c, ConfigNode):
if not c.has_been_accessed():
unused.add(k)
... | python | def unused_keys(self):
"""Lists all keys which are present in the ConfigTree but which have not been accessed."""
unused = set()
for k, c in self._children.items():
if isinstance(c, ConfigNode):
if not c.has_been_accessed():
unused.add(k)
... | Lists all keys which are present in the ConfigTree but which have not been accessed. | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/config_tree.py#L502-L512 |
datosgobar/pydatajson | pydatajson/validation.py | create_validator | def create_validator(schema_filename=None, schema_dir=None):
"""Crea el validador necesario para inicializar un objeto DataJson.
Para poder resolver referencias inter-esquemas, un Validador requiere
que se especifique un RefResolver (Resolvedor de Referencias) con el
directorio base (absoluto) y el arc... | python | def create_validator(schema_filename=None, schema_dir=None):
"""Crea el validador necesario para inicializar un objeto DataJson.
Para poder resolver referencias inter-esquemas, un Validador requiere
que se especifique un RefResolver (Resolvedor de Referencias) con el
directorio base (absoluto) y el arc... | Crea el validador necesario para inicializar un objeto DataJson.
Para poder resolver referencias inter-esquemas, un Validador requiere
que se especifique un RefResolver (Resolvedor de Referencias) con el
directorio base (absoluto) y el archivo desde el que se referencia el
directorio.
Para poder v... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/validation.py#L40-L81 |
datosgobar/pydatajson | pydatajson/validation.py | is_valid_catalog | def is_valid_catalog(catalog, validator=None):
"""Valida que un archivo `data.json` cumpla con el schema definido.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
catalog ... | python | def is_valid_catalog(catalog, validator=None):
"""Valida que un archivo `data.json` cumpla con el schema definido.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
catalog ... | Valida que un archivo `data.json` cumpla con el schema definido.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
catalog (str o dict): Catálogo (dict, JSON o XLSX) a ser valid... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/validation.py#L84-L107 |
datosgobar/pydatajson | pydatajson/validation.py | validate_catalog | def validate_catalog(catalog, only_errors=False, fmt="dict",
export_path=None, validator=None):
"""Analiza un data.json registrando los errores que encuentra.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la ... | python | def validate_catalog(catalog, only_errors=False, fmt="dict",
export_path=None, validator=None):
"""Analiza un data.json registrando los errores que encuentra.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la ... | Analiza un data.json registrando los errores que encuentra.
Chequea que el data.json tiene todos los campos obligatorios y que
tanto los campos obligatorios como los opcionales siguen la estructura
definida en el schema.
Args:
catalog (str o dict): Catálogo (dict, JSON o XLSX) a ser validado.
... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/validation.py#L110-L267 |
datosgobar/pydatajson | pydatajson/validation.py | iter_custom_errors | def iter_custom_errors(catalog):
"""Realiza validaciones sin usar el jsonschema.
En esta función se agregan bloques de código en python que realizan
validaciones complicadas o imposibles de especificar usando jsonschema.
"""
try:
# chequea que no se repiten los ids de la taxonomía específi... | python | def iter_custom_errors(catalog):
"""Realiza validaciones sin usar el jsonschema.
En esta función se agregan bloques de código en python que realizan
validaciones complicadas o imposibles de especificar usando jsonschema.
"""
try:
# chequea que no se repiten los ids de la taxonomía específi... | Realiza validaciones sin usar el jsonschema.
En esta función se agregan bloques de código en python que realizan
validaciones complicadas o imposibles de especificar usando jsonschema. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/validation.py#L270-L322 |
datosgobar/pydatajson | pydatajson/validation.py | _catalog_validation_to_list | def _catalog_validation_to_list(response):
"""Formatea la validación de un catálogo a dos listas de errores.
Una lista de errores para "catalog" y otra para "dataset".
"""
# crea una lista de dicts para volcarse en una tabla (catalog)
rows_catalog = []
validation_result = {
"catalog_t... | python | def _catalog_validation_to_list(response):
"""Formatea la validación de un catálogo a dos listas de errores.
Una lista de errores para "catalog" y otra para "dataset".
"""
# crea una lista de dicts para volcarse en una tabla (catalog)
rows_catalog = []
validation_result = {
"catalog_t... | Formatea la validación de un catálogo a dos listas de errores.
Una lista de errores para "catalog" y otra para "dataset". | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/validation.py#L366-L419 |
datosgobar/pydatajson | pydatajson/validation.py | format_matches_extension | def format_matches_extension(distribution, attribute):
"""Chequea si una extensión podría corresponder a un formato dado."""
if attribute in distribution and "format" in distribution:
if "/" in distribution['format']:
possible_format_extensions = mimetypes.guess_all_extensions(
... | python | def format_matches_extension(distribution, attribute):
"""Chequea si una extensión podría corresponder a un formato dado."""
if attribute in distribution and "format" in distribution:
if "/" in distribution['format']:
possible_format_extensions = mimetypes.guess_all_extensions(
... | Chequea si una extensión podría corresponder a un formato dado. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/validation.py#L422-L445 |
datosgobar/pydatajson | pydatajson/validation.py | main | def main(catalog):
"""Permite validar un catálogo por línea de comandos.
Args:
catalog (str): Path local o URL a un catálogo.
"""
res = validate_catalog(catalog, only_errors=True, fmt="list",
export_path=None, validator=None)
print("")
print("=== Errores a niv... | python | def main(catalog):
"""Permite validar un catálogo por línea de comandos.
Args:
catalog (str): Path local o URL a un catálogo.
"""
res = validate_catalog(catalog, only_errors=True, fmt="list",
export_path=None, validator=None)
print("")
print("=== Errores a niv... | Permite validar un catálogo por línea de comandos.
Args:
catalog (str): Path local o URL a un catálogo. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/validation.py#L448-L462 |
datosgobar/pydatajson | pydatajson/federation.py | push_dataset_to_ckan | def push_dataset_to_ckan(catalog, owner_org, dataset_origin_identifier,
portal_url, apikey, catalog_id=None,
demote_superThemes=True, demote_themes=True,
download_strategy=None, generate_new_access_url=None):
"""Escribe la metadata de un dat... | python | def push_dataset_to_ckan(catalog, owner_org, dataset_origin_identifier,
portal_url, apikey, catalog_id=None,
demote_superThemes=True, demote_themes=True,
download_strategy=None, generate_new_access_url=None):
"""Escribe la metadata de un dat... | Escribe la metadata de un dataset en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de origen que contiene el dataset.
owner_org (str): La organización a la cual pertence el dataset.
dataset_origin_identifier (str): El id del dataset que se va a
... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L18-L83 |
datosgobar/pydatajson | pydatajson/federation.py | resources_update | def resources_update(portal_url, apikey, distributions,
resource_files, generate_new_access_url=None,
catalog_id=None):
"""Sube archivos locales a sus distribuciones correspondientes en el portal
pasado por parámetro.
Args:
portal_url (str)... | python | def resources_update(portal_url, apikey, distributions,
resource_files, generate_new_access_url=None,
catalog_id=None):
"""Sube archivos locales a sus distribuciones correspondientes en el portal
pasado por parámetro.
Args:
portal_url (str)... | Sube archivos locales a sus distribuciones correspondientes en el portal
pasado por parámetro.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan crear o actualizar el dat... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L86-L135 |
datosgobar/pydatajson | pydatajson/federation.py | remove_datasets_from_ckan | def remove_datasets_from_ckan(portal_url, apikey, filter_in=None,
filter_out=None, only_time_series=False,
organization=None):
"""Borra un dataset en el portal pasado por parámetro.
Args:
portal_url (str): La URL del portal CKA... | python | def remove_datasets_from_ckan(portal_url, apikey, filter_in=None,
filter_out=None, only_time_series=False,
organization=None):
"""Borra un dataset en el portal pasado por parámetro.
Args:
portal_url (str): La URL del portal CKA... | Borra un dataset en el portal pasado por parámetro.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan borrar el dataset.
filter_in(dict): Diccionario de filtra... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L163-L213 |
datosgobar/pydatajson | pydatajson/federation.py | push_theme_to_ckan | def push_theme_to_ckan(catalog, portal_url, apikey,
identifier=None, label=None):
"""Escribe la metadata de un theme en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de origen que contiene el
theme.
porta... | python | def push_theme_to_ckan(catalog, portal_url, apikey,
identifier=None, label=None):
"""Escribe la metadata de un theme en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de origen que contiene el
theme.
porta... | Escribe la metadata de un theme en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de origen que contiene el
theme.
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los pe... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L216-L236 |
datosgobar/pydatajson | pydatajson/federation.py | restore_dataset_to_ckan | def restore_dataset_to_ckan(catalog, owner_org, dataset_origin_identifier,
portal_url, apikey, download_strategy=None,
generate_new_access_url=None):
"""Restaura la metadata de un dataset en el portal pasado por parámetro.
Args:
catalog (D... | python | def restore_dataset_to_ckan(catalog, owner_org, dataset_origin_identifier,
portal_url, apikey, download_strategy=None,
generate_new_access_url=None):
"""Restaura la metadata de un dataset en el portal pasado por parámetro.
Args:
catalog (D... | Restaura la metadata de un dataset en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de origen que contiene el dataset.
owner_org (str): La organización a la cual pertence el dataset.
dataset_origin_identifier (str): El id del dataset que se va a
... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L239-L267 |
datosgobar/pydatajson | pydatajson/federation.py | harvest_dataset_to_ckan | def harvest_dataset_to_ckan(catalog, owner_org, dataset_origin_identifier,
portal_url, apikey, catalog_id,
download_strategy=None):
"""Federa la metadata de un dataset en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálog... | python | def harvest_dataset_to_ckan(catalog, owner_org, dataset_origin_identifier,
portal_url, apikey, catalog_id,
download_strategy=None):
"""Federa la metadata de un dataset en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálog... | Federa la metadata de un dataset en el portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de origen que contiene el dataset.
owner_org (str): La organización a la cual pertence el dataset.
dataset_origin_identifier (str): El id del dataset que se va a
... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L270-L294 |
datosgobar/pydatajson | pydatajson/federation.py | harvest_catalog_to_ckan | def harvest_catalog_to_ckan(catalog, portal_url, apikey, catalog_id,
dataset_list=None, owner_org=None,
download_strategy=None):
"""Federa los datasets de un catálogo al portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de... | python | def harvest_catalog_to_ckan(catalog, portal_url, apikey, catalog_id,
dataset_list=None, owner_org=None,
download_strategy=None):
"""Federa los datasets de un catálogo al portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de... | Federa los datasets de un catálogo al portal pasado por parámetro.
Args:
catalog (DataJson): El catálogo de origen que se federa.
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan crear... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L297-L344 |
datosgobar/pydatajson | pydatajson/federation.py | push_new_themes | def push_new_themes(catalog, portal_url, apikey):
"""Toma un catálogo y escribe los temas de la taxonomía que no están
presentes.
Args:
catalog (DataJson): El catálogo de origen que contiene la
taxonomía.
portal_url (str): La URL del portal CKAN de destino.
... | python | def push_new_themes(catalog, portal_url, apikey):
"""Toma un catálogo y escribe los temas de la taxonomía que no están
presentes.
Args:
catalog (DataJson): El catálogo de origen que contiene la
taxonomía.
portal_url (str): La URL del portal CKAN de destino.
... | Toma un catálogo y escribe los temas de la taxonomía que no están
presentes.
Args:
catalog (DataJson): El catálogo de origen que contiene la
taxonomía.
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los perm... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L347-L369 |
datosgobar/pydatajson | pydatajson/federation.py | get_organization_from_ckan | def get_organization_from_ckan(portal_url, org_id):
"""Toma la url de un portal y un id, y devuelve la organización a buscar.
Args:
portal_url (str): La URL del portal CKAN de origen.
org_id (str): El id de la organización a buscar.
Returns:
d... | python | def get_organization_from_ckan(portal_url, org_id):
"""Toma la url de un portal y un id, y devuelve la organización a buscar.
Args:
portal_url (str): La URL del portal CKAN de origen.
org_id (str): El id de la organización a buscar.
Returns:
d... | Toma la url de un portal y un id, y devuelve la organización a buscar.
Args:
portal_url (str): La URL del portal CKAN de origen.
org_id (str): El id de la organización a buscar.
Returns:
dict: Diccionario con la información de la organización. | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L386-L397 |
datosgobar/pydatajson | pydatajson/federation.py | push_organization_tree_to_ckan | def push_organization_tree_to_ckan(portal_url, apikey, org_tree, parent=None):
"""Toma un árbol de organizaciones y lo replica en el portal de
destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos q... | python | def push_organization_tree_to_ckan(portal_url, apikey, org_tree, parent=None):
"""Toma un árbol de organizaciones y lo replica en el portal de
destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos q... | Toma un árbol de organizaciones y lo replica en el portal de
destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan crear las organizaciones.
org_tree(... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L400-L428 |
datosgobar/pydatajson | pydatajson/federation.py | push_organization_to_ckan | def push_organization_to_ckan(portal_url, apikey, organization, parent=None):
"""Toma una organización y la crea en el portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan ... | python | def push_organization_to_ckan(portal_url, apikey, organization, parent=None):
"""Toma una organización y la crea en el portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan ... | Toma una organización y la crea en el portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan crear la organización.
organization(dict): Datos de la organización a cre... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L431-L457 |
datosgobar/pydatajson | pydatajson/federation.py | remove_organization_from_ckan | def remove_organization_from_ckan(portal_url, apikey, organization_id):
"""Toma un id de organización y la purga del portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan bo... | python | def remove_organization_from_ckan(portal_url, apikey, organization_id):
"""Toma un id de organización y la purga del portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan bo... | Toma un id de organización y la purga del portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan borrar la organización.
organization_id(str): Id o name de la organiz... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L460-L478 |
datosgobar/pydatajson | pydatajson/federation.py | remove_organizations_from_ckan | def remove_organizations_from_ckan(portal_url, apikey, organization_list):
"""Toma una lista de ids de organización y las purga del portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
... | python | def remove_organizations_from_ckan(portal_url, apikey, organization_list):
"""Toma una lista de ids de organización y las purga del portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
... | Toma una lista de ids de organización y las purga del portal de destino.
Args:
portal_url (str): La URL del portal CKAN de destino.
apikey (str): La apikey de un usuario con los permisos que le
permitan borrar la organización.
organization_list(list): Id o nam... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L481-L493 |
datosgobar/pydatajson | pydatajson/federation.py | restore_organization_to_ckan | def restore_organization_to_ckan(catalog, owner_org, portal_url, apikey,
dataset_list=None, download_strategy=None,
generate_new_access_url=None):
"""Restaura los datasets de la organización de un catálogo al portal pasado
por parámetro. Si ha... | python | def restore_organization_to_ckan(catalog, owner_org, portal_url, apikey,
dataset_list=None, download_strategy=None,
generate_new_access_url=None):
"""Restaura los datasets de la organización de un catálogo al portal pasado
por parámetro. Si ha... | Restaura los datasets de la organización de un catálogo al portal pasado
por parámetro. Si hay temas presentes en el DataJson que no están en el
portal de CKAN, los genera.
Args:
catalog (DataJson): El catálogo de origen que se restaura.
portal_url (str): La URL del portal... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L496-L541 |
datosgobar/pydatajson | pydatajson/federation.py | restore_catalog_to_ckan | def restore_catalog_to_ckan(catalog, origin_portal_url, destination_portal_url,
apikey, download_strategy=None,
generate_new_access_url=None):
"""Restaura los datasets de un catálogo original al portal pasado
por parámetro. Si hay temas presentes en el ... | python | def restore_catalog_to_ckan(catalog, origin_portal_url, destination_portal_url,
apikey, download_strategy=None,
generate_new_access_url=None):
"""Restaura los datasets de un catálogo original al portal pasado
por parámetro. Si hay temas presentes en el ... | Restaura los datasets de un catálogo original al portal pasado
por parámetro. Si hay temas presentes en el DataJson que no están en
el portal de CKAN, los genera.
Args:
catalog (DataJson): El catálogo de origen que se restaura.
origin_portal_url (str): La URL d... | https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/federation.py#L544-L598 |
ihmeuw/vivarium | src/vivarium/interface/interactive.py | initialize_simulation | def initialize_simulation(components: List, input_config: Mapping=None,
plugin_config: Mapping=None) -> InteractiveContext:
"""Construct a simulation from a list of components, component
configuration, and a plugin configuration.
The simulation context returned by this method stil... | python | def initialize_simulation(components: List, input_config: Mapping=None,
plugin_config: Mapping=None) -> InteractiveContext:
"""Construct a simulation from a list of components, component
configuration, and a plugin configuration.
The simulation context returned by this method stil... | Construct a simulation from a list of components, component
configuration, and a plugin configuration.
The simulation context returned by this method still needs to be setup by
calling its setup method. It is mostly useful for testing and debugging.
Parameters
----------
components
A l... | https://github.com/ihmeuw/vivarium/blob/c5f5d50f775c8bf337d3aae1ff7c57c025a8e258/src/vivarium/interface/interactive.py#L195-L227 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.