partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | EfficientFrontier.portfolio_performance | After optimising, calculate (and optionally print) the performance of the optimal
portfolio. Currently calculates expected return, volatility, and the Sharpe ratio.
:param verbose: whether performance should be printed, defaults to False
:type verbose: bool, optional
:param risk_free_ra... | pypfopt/efficient_frontier.py | def portfolio_performance(self, verbose=False, risk_free_rate=0.02):
"""
After optimising, calculate (and optionally print) the performance of the optimal
portfolio. Currently calculates expected return, volatility, and the Sharpe ratio.
:param verbose: whether performance should be pri... | def portfolio_performance(self, verbose=False, risk_free_rate=0.02):
"""
After optimising, calculate (and optionally print) the performance of the optimal
portfolio. Currently calculates expected return, volatility, and the Sharpe ratio.
:param verbose: whether performance should be pri... | [
"After",
"optimising",
"calculate",
"(",
"and",
"optionally",
"print",
")",
"the",
"performance",
"of",
"the",
"optimal",
"portfolio",
".",
"Currently",
"calculates",
"expected",
"return",
"volatility",
"and",
"the",
"Sharpe",
"ratio",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/efficient_frontier.py#L257-L276 | [
"def",
"portfolio_performance",
"(",
"self",
",",
"verbose",
"=",
"False",
",",
"risk_free_rate",
"=",
"0.02",
")",
":",
"return",
"base_optimizer",
".",
"portfolio_performance",
"(",
"self",
".",
"expected_returns",
",",
"self",
".",
"cov_matrix",
",",
"self",
... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | portfolio_performance | After optimising, calculate (and optionally print) the performance of the optimal
portfolio. Currently calculates expected return, volatility, and the Sharpe ratio.
:param expected_returns: expected returns for each asset. Set to None if
optimising for volatility only.
:type ex... | pypfopt/base_optimizer.py | def portfolio_performance(
expected_returns, cov_matrix, weights, verbose=False, risk_free_rate=0.02
):
"""
After optimising, calculate (and optionally print) the performance of the optimal
portfolio. Currently calculates expected return, volatility, and the Sharpe ratio.
:param expected_returns: e... | def portfolio_performance(
expected_returns, cov_matrix, weights, verbose=False, risk_free_rate=0.02
):
"""
After optimising, calculate (and optionally print) the performance of the optimal
portfolio. Currently calculates expected return, volatility, and the Sharpe ratio.
:param expected_returns: e... | [
"After",
"optimising",
"calculate",
"(",
"and",
"optionally",
"print",
")",
"the",
"performance",
"of",
"the",
"optimal",
"portfolio",
".",
"Currently",
"calculates",
"expected",
"return",
"volatility",
"and",
"the",
"Sharpe",
"ratio",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/base_optimizer.py#L94-L143 | [
"def",
"portfolio_performance",
"(",
"expected_returns",
",",
"cov_matrix",
",",
"weights",
",",
"verbose",
"=",
"False",
",",
"risk_free_rate",
"=",
"0.02",
")",
":",
"if",
"isinstance",
"(",
"weights",
",",
"dict",
")",
":",
"if",
"isinstance",
"(",
"expec... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | BaseOptimizer.clean_weights | Helper method to clean the raw weights, setting any weights whose absolute
values are below the cutoff to zero, and rounding the rest.
:param cutoff: the lower bound, defaults to 1e-4
:type cutoff: float, optional
:param rounding: number of decimal places to round the weights, defaults ... | pypfopt/base_optimizer.py | def clean_weights(self, cutoff=1e-4, rounding=5):
"""
Helper method to clean the raw weights, setting any weights whose absolute
values are below the cutoff to zero, and rounding the rest.
:param cutoff: the lower bound, defaults to 1e-4
:type cutoff: float, optional
:pa... | def clean_weights(self, cutoff=1e-4, rounding=5):
"""
Helper method to clean the raw weights, setting any weights whose absolute
values are below the cutoff to zero, and rounding the rest.
:param cutoff: the lower bound, defaults to 1e-4
:type cutoff: float, optional
:pa... | [
"Helper",
"method",
"to",
"clean",
"the",
"raw",
"weights",
"setting",
"any",
"weights",
"whose",
"absolute",
"values",
"are",
"below",
"the",
"cutoff",
"to",
"zero",
"and",
"rounding",
"the",
"rest",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/base_optimizer.py#L37-L56 | [
"def",
"clean_weights",
"(",
"self",
",",
"cutoff",
"=",
"1e-4",
",",
"rounding",
"=",
"5",
")",
":",
"if",
"not",
"isinstance",
"(",
"rounding",
",",
"int",
")",
"or",
"rounding",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"rounding must be a positive i... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | BaseScipyOptimizer._make_valid_bounds | Private method: process input bounds into a form acceptable by scipy.optimize,
and check the validity of said bounds.
:param test_bounds: minimum and maximum weight of an asset
:type test_bounds: tuple
:raises ValueError: if ``test_bounds`` is not a tuple of length two.
:raises ... | pypfopt/base_optimizer.py | def _make_valid_bounds(self, test_bounds):
"""
Private method: process input bounds into a form acceptable by scipy.optimize,
and check the validity of said bounds.
:param test_bounds: minimum and maximum weight of an asset
:type test_bounds: tuple
:raises ValueError: if... | def _make_valid_bounds(self, test_bounds):
"""
Private method: process input bounds into a form acceptable by scipy.optimize,
and check the validity of said bounds.
:param test_bounds: minimum and maximum weight of an asset
:type test_bounds: tuple
:raises ValueError: if... | [
"Private",
"method",
":",
"process",
"input",
"bounds",
"into",
"a",
"form",
"acceptable",
"by",
"scipy",
".",
"optimize",
"and",
"check",
"the",
"validity",
"of",
"said",
"bounds",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/base_optimizer.py#L72-L91 | [
"def",
"_make_valid_bounds",
"(",
"self",
",",
"test_bounds",
")",
":",
"if",
"len",
"(",
"test_bounds",
")",
"!=",
"2",
"or",
"not",
"isinstance",
"(",
"test_bounds",
",",
"tuple",
")",
":",
"raise",
"ValueError",
"(",
"\"test_bounds must be a tuple of (lower b... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | portfolio | For a long only portfolio, convert the continuous weights to a discrete allocation
in a greedy iterative approach. This can be thought of as a clever way to round
the continuous weights to an integer number of shares
:param weights: continuous weights generated from the ``efficient_frontier`` module
:t... | pypfopt/discrete_allocation.py | def portfolio(weights, latest_prices, min_allocation=0.01, total_portfolio_value=10000):
"""
For a long only portfolio, convert the continuous weights to a discrete allocation
in a greedy iterative approach. This can be thought of as a clever way to round
the continuous weights to an integer number of s... | def portfolio(weights, latest_prices, min_allocation=0.01, total_portfolio_value=10000):
"""
For a long only portfolio, convert the continuous weights to a discrete allocation
in a greedy iterative approach. This can be thought of as a clever way to round
the continuous weights to an integer number of s... | [
"For",
"a",
"long",
"only",
"portfolio",
"convert",
"the",
"continuous",
"weights",
"to",
"a",
"discrete",
"allocation",
"in",
"a",
"greedy",
"iterative",
"approach",
".",
"This",
"can",
"be",
"thought",
"of",
"as",
"a",
"clever",
"way",
"to",
"round",
"th... | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/discrete_allocation.py#L27-L127 | [
"def",
"portfolio",
"(",
"weights",
",",
"latest_prices",
",",
"min_allocation",
"=",
"0.01",
",",
"total_portfolio_value",
"=",
"10000",
")",
":",
"if",
"not",
"isinstance",
"(",
"weights",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"\"weights should b... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | portfolio_lp | For a long only portfolio, convert the continuous weights to a discrete allocation
using Mixed Integer Linear Programming. This can be thought of as a clever way to round
the continuous weights to an integer number of shares
:param weights: continuous weights generated from the ``efficient_frontier`` modul... | pypfopt/discrete_allocation.py | def portfolio_lp(
weights, latest_prices, min_allocation=0.01, total_portfolio_value=10000
):
"""
For a long only portfolio, convert the continuous weights to a discrete allocation
using Mixed Integer Linear Programming. This can be thought of as a clever way to round
the continuous weights to an in... | def portfolio_lp(
weights, latest_prices, min_allocation=0.01, total_portfolio_value=10000
):
"""
For a long only portfolio, convert the continuous weights to a discrete allocation
using Mixed Integer Linear Programming. This can be thought of as a clever way to round
the continuous weights to an in... | [
"For",
"a",
"long",
"only",
"portfolio",
"convert",
"the",
"continuous",
"weights",
"to",
"a",
"discrete",
"allocation",
"using",
"Mixed",
"Integer",
"Linear",
"Programming",
".",
"This",
"can",
"be",
"thought",
"of",
"as",
"a",
"clever",
"way",
"to",
"round... | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/discrete_allocation.py#L130-L184 | [
"def",
"portfolio_lp",
"(",
"weights",
",",
"latest_prices",
",",
"min_allocation",
"=",
"0.01",
",",
"total_portfolio_value",
"=",
"10000",
")",
":",
"import",
"pulp",
"if",
"not",
"isinstance",
"(",
"weights",
",",
"dict",
")",
":",
"raise",
"TypeError",
"... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | portfolio_byvalue | For a long only portfolio, convert the continuous weights to a discrete
allocation using Mixed Integer Linear Programming. This function assumes
that we buy some asset based on value instead of shares, and there is a
limit of minimum value and increasing step.
:param weights: continuous weights generat... | pypfopt/discrete_allocation.py | def portfolio_byvalue(
weights, steps, min_values, max_values=1e9, total_portfolio_value=10000
):
"""
For a long only portfolio, convert the continuous weights to a discrete
allocation using Mixed Integer Linear Programming. This function assumes
that we buy some asset based on value instead of shar... | def portfolio_byvalue(
weights, steps, min_values, max_values=1e9, total_portfolio_value=10000
):
"""
For a long only portfolio, convert the continuous weights to a discrete
allocation using Mixed Integer Linear Programming. This function assumes
that we buy some asset based on value instead of shar... | [
"For",
"a",
"long",
"only",
"portfolio",
"convert",
"the",
"continuous",
"weights",
"to",
"a",
"discrete",
"allocation",
"using",
"Mixed",
"Integer",
"Linear",
"Programming",
".",
"This",
"function",
"assumes",
"that",
"we",
"buy",
"some",
"asset",
"based",
"o... | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/discrete_allocation.py#L187-L250 | [
"def",
"portfolio_byvalue",
"(",
"weights",
",",
"steps",
",",
"min_values",
",",
"max_values",
"=",
"1e9",
",",
"total_portfolio_value",
"=",
"10000",
")",
":",
"import",
"pulp",
"if",
"not",
"isinstance",
"(",
"weights",
",",
"dict",
")",
":",
"raise",
"... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CVAROpt.min_cvar | Find the portfolio weights that minimises the CVaR, via
Monte Carlo sampling from the return distribution.
:param s: number of bootstrap draws, defaults to 10000
:type s: int, optional
:param beta: "significance level" (i. 1 - q), defaults to 0.95
:type beta: float, optional
... | pypfopt/value_at_risk.py | def min_cvar(self, s=10000, beta=0.95, random_state=None):
"""
Find the portfolio weights that minimises the CVaR, via
Monte Carlo sampling from the return distribution.
:param s: number of bootstrap draws, defaults to 10000
:type s: int, optional
:param beta: "significa... | def min_cvar(self, s=10000, beta=0.95, random_state=None):
"""
Find the portfolio weights that minimises the CVaR, via
Monte Carlo sampling from the return distribution.
:param s: number of bootstrap draws, defaults to 10000
:type s: int, optional
:param beta: "significa... | [
"Find",
"the",
"portfolio",
"weights",
"that",
"minimises",
"the",
"CVaR",
"via",
"Monte",
"Carlo",
"sampling",
"from",
"the",
"return",
"distribution",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/value_at_risk.py#L54-L78 | [
"def",
"min_cvar",
"(",
"self",
",",
"s",
"=",
"10000",
",",
"beta",
"=",
"0.95",
",",
"random_state",
"=",
"None",
")",
":",
"args",
"=",
"(",
"self",
".",
"returns",
",",
"s",
",",
"beta",
",",
"random_state",
")",
"result",
"=",
"noisyopt",
".",... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | sample_cov | Calculate the annualised sample covariance matrix of (daily) asset returns.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.DataFrame
:param frequency: number of time periods in a year, defaults to 252 (the number
... | pypfopt/risk_models.py | def sample_cov(prices, frequency=252):
"""
Calculate the annualised sample covariance matrix of (daily) asset returns.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.DataFrame
:param frequency: number of ti... | def sample_cov(prices, frequency=252):
"""
Calculate the annualised sample covariance matrix of (daily) asset returns.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.DataFrame
:param frequency: number of ti... | [
"Calculate",
"the",
"annualised",
"sample",
"covariance",
"matrix",
"of",
"(",
"daily",
")",
"asset",
"returns",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L28-L45 | [
"def",
"sample_cov",
"(",
"prices",
",",
"frequency",
"=",
"252",
")",
":",
"if",
"not",
"isinstance",
"(",
"prices",
",",
"pd",
".",
"DataFrame",
")",
":",
"warnings",
".",
"warn",
"(",
"\"prices are not in a dataframe\"",
",",
"RuntimeWarning",
")",
"price... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | semicovariance | Estimate the semicovariance matrix, i.e the covariance given that
the returns are less than the benchmark.
.. semicov = E([min(r_i - B, 0)] . [min(r_j - B, 0)])
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.D... | pypfopt/risk_models.py | def semicovariance(prices, benchmark=0, frequency=252):
"""
Estimate the semicovariance matrix, i.e the covariance given that
the returns are less than the benchmark.
.. semicov = E([min(r_i - B, 0)] . [min(r_j - B, 0)])
:param prices: adjusted closing prices of the asset, each row is a date
... | def semicovariance(prices, benchmark=0, frequency=252):
"""
Estimate the semicovariance matrix, i.e the covariance given that
the returns are less than the benchmark.
.. semicov = E([min(r_i - B, 0)] . [min(r_j - B, 0)])
:param prices: adjusted closing prices of the asset, each row is a date
... | [
"Estimate",
"the",
"semicovariance",
"matrix",
"i",
".",
"e",
"the",
"covariance",
"given",
"that",
"the",
"returns",
"are",
"less",
"than",
"the",
"benchmark",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L48-L71 | [
"def",
"semicovariance",
"(",
"prices",
",",
"benchmark",
"=",
"0",
",",
"frequency",
"=",
"252",
")",
":",
"if",
"not",
"isinstance",
"(",
"prices",
",",
"pd",
".",
"DataFrame",
")",
":",
"warnings",
".",
"warn",
"(",
"\"prices are not in a dataframe\"",
... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | _pair_exp_cov | Calculate the exponential covariance between two timeseries of returns.
:param X: first time series of returns
:type X: pd.Series
:param Y: second time series of returns
:type Y: pd.Series
:param span: the span of the exponential weighting function, defaults to 180
:type span: int, optional
... | pypfopt/risk_models.py | def _pair_exp_cov(X, Y, span=180):
"""
Calculate the exponential covariance between two timeseries of returns.
:param X: first time series of returns
:type X: pd.Series
:param Y: second time series of returns
:type Y: pd.Series
:param span: the span of the exponential weighting function, de... | def _pair_exp_cov(X, Y, span=180):
"""
Calculate the exponential covariance between two timeseries of returns.
:param X: first time series of returns
:type X: pd.Series
:param Y: second time series of returns
:type Y: pd.Series
:param span: the span of the exponential weighting function, de... | [
"Calculate",
"the",
"exponential",
"covariance",
"between",
"two",
"timeseries",
"of",
"returns",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L74-L91 | [
"def",
"_pair_exp_cov",
"(",
"X",
",",
"Y",
",",
"span",
"=",
"180",
")",
":",
"covariation",
"=",
"(",
"X",
"-",
"X",
".",
"mean",
"(",
")",
")",
"*",
"(",
"Y",
"-",
"Y",
".",
"mean",
"(",
")",
")",
"# Exponentially weight the covariation and take t... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | exp_cov | Estimate the exponentially-weighted covariance matrix, which gives
greater weight to more recent data.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.DataFrame
:param span: the span of the exponential weighting... | pypfopt/risk_models.py | def exp_cov(prices, span=180, frequency=252):
"""
Estimate the exponentially-weighted covariance matrix, which gives
greater weight to more recent data.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.DataFr... | def exp_cov(prices, span=180, frequency=252):
"""
Estimate the exponentially-weighted covariance matrix, which gives
greater weight to more recent data.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.DataFr... | [
"Estimate",
"the",
"exponentially",
"-",
"weighted",
"covariance",
"matrix",
"which",
"gives",
"greater",
"weight",
"to",
"more",
"recent",
"data",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L94-L124 | [
"def",
"exp_cov",
"(",
"prices",
",",
"span",
"=",
"180",
",",
"frequency",
"=",
"252",
")",
":",
"if",
"not",
"isinstance",
"(",
"prices",
",",
"pd",
".",
"DataFrame",
")",
":",
"warnings",
".",
"warn",
"(",
"\"prices are not in a dataframe\"",
",",
"Ru... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | min_cov_determinant | Calculate the minimum covariance determinant, an estimator of the covariance matrix
that is more robust to noise.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker/id.
:type prices: pd.DataFrame
:param frequency: number of time period... | pypfopt/risk_models.py | def min_cov_determinant(prices, frequency=252, random_state=None):
"""
Calculate the minimum covariance determinant, an estimator of the covariance matrix
that is more robust to noise.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker... | def min_cov_determinant(prices, frequency=252, random_state=None):
"""
Calculate the minimum covariance determinant, an estimator of the covariance matrix
that is more robust to noise.
:param prices: adjusted closing prices of the asset, each row is a date
and each column is a ticker... | [
"Calculate",
"the",
"minimum",
"covariance",
"determinant",
"an",
"estimator",
"of",
"the",
"covariance",
"matrix",
"that",
"is",
"more",
"robust",
"to",
"noise",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L127-L150 | [
"def",
"min_cov_determinant",
"(",
"prices",
",",
"frequency",
"=",
"252",
",",
"random_state",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"prices",
",",
"pd",
".",
"DataFrame",
")",
":",
"warnings",
".",
"warn",
"(",
"\"prices are not in a dataf... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CovarianceShrinkage.format_and_annualise | Helper method which annualises the output of shrinkage calculations,
and formats the result into a dataframe
:param raw_cov_array: raw covariance matrix of daily returns
:type raw_cov_array: np.ndarray
:return: annualised covariance matrix
:rtype: pd.DataFrame | pypfopt/risk_models.py | def format_and_annualise(self, raw_cov_array):
"""
Helper method which annualises the output of shrinkage calculations,
and formats the result into a dataframe
:param raw_cov_array: raw covariance matrix of daily returns
:type raw_cov_array: np.ndarray
:return: annualise... | def format_and_annualise(self, raw_cov_array):
"""
Helper method which annualises the output of shrinkage calculations,
and formats the result into a dataframe
:param raw_cov_array: raw covariance matrix of daily returns
:type raw_cov_array: np.ndarray
:return: annualise... | [
"Helper",
"method",
"which",
"annualises",
"the",
"output",
"of",
"shrinkage",
"calculations",
"and",
"formats",
"the",
"result",
"into",
"a",
"dataframe"
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L182-L195 | [
"def",
"format_and_annualise",
"(",
"self",
",",
"raw_cov_array",
")",
":",
"assets",
"=",
"self",
".",
"X",
".",
"columns",
"return",
"(",
"pd",
".",
"DataFrame",
"(",
"raw_cov_array",
",",
"index",
"=",
"assets",
",",
"columns",
"=",
"assets",
")",
"*"... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CovarianceShrinkage.shrunk_covariance | Shrink a sample covariance matrix to the identity matrix (scaled by the average
sample variance). This method does not estimate an optimal shrinkage parameter,
it requires manual input.
:param delta: shrinkage parameter, defaults to 0.2.
:type delta: float, optional
:return: shr... | pypfopt/risk_models.py | def shrunk_covariance(self, delta=0.2):
"""
Shrink a sample covariance matrix to the identity matrix (scaled by the average
sample variance). This method does not estimate an optimal shrinkage parameter,
it requires manual input.
:param delta: shrinkage parameter, defaults to 0.... | def shrunk_covariance(self, delta=0.2):
"""
Shrink a sample covariance matrix to the identity matrix (scaled by the average
sample variance). This method does not estimate an optimal shrinkage parameter,
it requires manual input.
:param delta: shrinkage parameter, defaults to 0.... | [
"Shrink",
"a",
"sample",
"covariance",
"matrix",
"to",
"the",
"identity",
"matrix",
"(",
"scaled",
"by",
"the",
"average",
"sample",
"variance",
")",
".",
"This",
"method",
"does",
"not",
"estimate",
"an",
"optimal",
"shrinkage",
"parameter",
"it",
"requires",... | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L197-L215 | [
"def",
"shrunk_covariance",
"(",
"self",
",",
"delta",
"=",
"0.2",
")",
":",
"self",
".",
"delta",
"=",
"delta",
"N",
"=",
"self",
".",
"S",
".",
"shape",
"[",
"1",
"]",
"# Shrinkage target",
"mu",
"=",
"np",
".",
"trace",
"(",
"self",
".",
"S",
... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CovarianceShrinkage.ledoit_wolf | Calculate the Ledoit-Wolf shrinkage estimate.
:return: shrunk sample covariance matrix
:rtype: np.ndarray | pypfopt/risk_models.py | def ledoit_wolf(self):
"""
Calculate the Ledoit-Wolf shrinkage estimate.
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
X = np.nan_to_num(self.X.values)
shrunk_cov, self.delta = covariance.ledoit_wolf(X)
return self.format_and_annualise(s... | def ledoit_wolf(self):
"""
Calculate the Ledoit-Wolf shrinkage estimate.
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
X = np.nan_to_num(self.X.values)
shrunk_cov, self.delta = covariance.ledoit_wolf(X)
return self.format_and_annualise(s... | [
"Calculate",
"the",
"Ledoit",
"-",
"Wolf",
"shrinkage",
"estimate",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L217-L226 | [
"def",
"ledoit_wolf",
"(",
"self",
")",
":",
"X",
"=",
"np",
".",
"nan_to_num",
"(",
"self",
".",
"X",
".",
"values",
")",
"shrunk_cov",
",",
"self",
".",
"delta",
"=",
"covariance",
".",
"ledoit_wolf",
"(",
"X",
")",
"return",
"self",
".",
"format_a... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CovarianceShrinkage.oracle_approximating | Calculate the Oracle Approximating Shrinkage estimate
:return: shrunk sample covariance matrix
:rtype: np.ndarray | pypfopt/risk_models.py | def oracle_approximating(self):
"""
Calculate the Oracle Approximating Shrinkage estimate
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
X = np.nan_to_num(self.X.values)
shrunk_cov, self.delta = covariance.oas(X)
return self.format_and_an... | def oracle_approximating(self):
"""
Calculate the Oracle Approximating Shrinkage estimate
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
X = np.nan_to_num(self.X.values)
shrunk_cov, self.delta = covariance.oas(X)
return self.format_and_an... | [
"Calculate",
"the",
"Oracle",
"Approximating",
"Shrinkage",
"estimate"
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L228-L237 | [
"def",
"oracle_approximating",
"(",
"self",
")",
":",
"X",
"=",
"np",
".",
"nan_to_num",
"(",
"self",
".",
"X",
".",
"values",
")",
"shrunk_cov",
",",
"self",
".",
"delta",
"=",
"covariance",
".",
"oas",
"(",
"X",
")",
"return",
"self",
".",
"format_... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | ConstantCorrelation.shrink | Calculate the Constant-Correlation covariance matrix.
:return: shrunk sample covariance matrix
:rtype: np.ndarray | pypfopt/risk_models.py | def shrink(self):
"""
Calculate the Constant-Correlation covariance matrix.
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
x = np.nan_to_num(self.X.values)
# de-mean returns
t, n = np.shape(x)
meanx = x.mean(axis=0)
x = x... | def shrink(self):
"""
Calculate the Constant-Correlation covariance matrix.
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
x = np.nan_to_num(self.X.values)
# de-mean returns
t, n = np.shape(x)
meanx = x.mean(axis=0)
x = x... | [
"Calculate",
"the",
"Constant",
"-",
"Correlation",
"covariance",
"matrix",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L248-L308 | [
"def",
"shrink",
"(",
"self",
")",
":",
"x",
"=",
"np",
".",
"nan_to_num",
"(",
"self",
".",
"X",
".",
"values",
")",
"# de-mean returns",
"t",
",",
"n",
"=",
"np",
".",
"shape",
"(",
"x",
")",
"meanx",
"=",
"x",
".",
"mean",
"(",
"axis",
"=",
... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | SingleIndex.shrink | Calculate the Constant-Correlation covariance matrix.
:return: shrunk sample covariance matrix
:rtype: np.ndarray | pypfopt/risk_models.py | def shrink(self):
"""
Calculate the Constant-Correlation covariance matrix.
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
x = np.nan_to_num(self.X.values)
# de-mean returns
t, n = np.shape(x)
meanx = x.mean(axis=0)
x = x... | def shrink(self):
"""
Calculate the Constant-Correlation covariance matrix.
:return: shrunk sample covariance matrix
:rtype: np.ndarray
"""
x = np.nan_to_num(self.X.values)
# de-mean returns
t, n = np.shape(x)
meanx = x.mean(axis=0)
x = x... | [
"Calculate",
"the",
"Constant",
"-",
"Correlation",
"covariance",
"matrix",
"."
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/risk_models.py#L323-L379 | [
"def",
"shrink",
"(",
"self",
")",
":",
"x",
"=",
"np",
".",
"nan_to_num",
"(",
"self",
".",
"X",
".",
"values",
")",
"# de-mean returns",
"t",
",",
"n",
"=",
"np",
".",
"shape",
"(",
"x",
")",
"meanx",
"=",
"x",
".",
"mean",
"(",
"axis",
"=",
... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CLA.min_volatility | Get the minimum variance solution | pypfopt/cla.py | def min_volatility(self):
"""Get the minimum variance solution"""
if not self.w:
self.solve()
var = []
for w in self.w:
a = np.dot(np.dot(w.T, self.cov_matrix), w)
var.append(a)
# return min(var)**.5, self.w[var.index(min(var))]
self.we... | def min_volatility(self):
"""Get the minimum variance solution"""
if not self.w:
self.solve()
var = []
for w in self.w:
a = np.dot(np.dot(w.T, self.cov_matrix), w)
var.append(a)
# return min(var)**.5, self.w[var.index(min(var))]
self.we... | [
"Get",
"the",
"minimum",
"variance",
"solution"
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/cla.py#L275-L285 | [
"def",
"min_volatility",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"w",
":",
"self",
".",
"solve",
"(",
")",
"var",
"=",
"[",
"]",
"for",
"w",
"in",
"self",
".",
"w",
":",
"a",
"=",
"np",
".",
"dot",
"(",
"np",
".",
"dot",
"(",
"w",
... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CLA.max_sharpe | Get the max Sharpe ratio portfolio | pypfopt/cla.py | def max_sharpe(self):
"""Get the max Sharpe ratio portfolio"""
if not self.w:
self.solve()
# 1) Compute the local max SR portfolio between any two neighbor turning points
w_sr, sr = [], []
for i in range(len(self.w) - 1):
w0 = np.copy(self.w[i])
... | def max_sharpe(self):
"""Get the max Sharpe ratio portfolio"""
if not self.w:
self.solve()
# 1) Compute the local max SR portfolio between any two neighbor turning points
w_sr, sr = [], []
for i in range(len(self.w) - 1):
w0 = np.copy(self.w[i])
... | [
"Get",
"the",
"max",
"Sharpe",
"ratio",
"portfolio"
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/cla.py#L287-L302 | [
"def",
"max_sharpe",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"w",
":",
"self",
".",
"solve",
"(",
")",
"# 1) Compute the local max SR portfolio between any two neighbor turning points",
"w_sr",
",",
"sr",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"i",
"i... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | CLA.efficient_frontier | Get the efficient frontier | pypfopt/cla.py | def efficient_frontier(self, points):
"""Get the efficient frontier"""
mu, sigma, weights = [], [], []
# remove the 1, to avoid duplications
a = np.linspace(0, 1, points / len(self.w))[:-1]
b = list(range(len(self.w) - 1))
for i in b:
w0, w1 = self.w[i], self.... | def efficient_frontier(self, points):
"""Get the efficient frontier"""
mu, sigma, weights = [], [], []
# remove the 1, to avoid duplications
a = np.linspace(0, 1, points / len(self.w))[:-1]
b = list(range(len(self.w) - 1))
for i in b:
w0, w1 = self.w[i], self.... | [
"Get",
"the",
"efficient",
"frontier"
] | robertmartin8/PyPortfolioOpt | python | https://github.com/robertmartin8/PyPortfolioOpt/blob/dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc/pypfopt/cla.py#L347-L363 | [
"def",
"efficient_frontier",
"(",
"self",
",",
"points",
")",
":",
"mu",
",",
"sigma",
",",
"weights",
"=",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
"# remove the 1, to avoid duplications",
"a",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"1",
",",
"po... | dfad1256cb6995c7fbd7a025eedb54b1ca04b2fc |
train | emit | Emit a SocketIO event.
This function emits a SocketIO event to one or more connected clients. A
JSON blob can be attached to the event as payload. This is a function that
can only be called from a SocketIO event handler, as in obtains some
information from the current client context. Example::
... | flask_socketio/__init__.py | def emit(event, *args, **kwargs):
"""Emit a SocketIO event.
This function emits a SocketIO event to one or more connected clients. A
JSON blob can be attached to the event as payload. This is a function that
can only be called from a SocketIO event handler, as in obtains some
information from the c... | def emit(event, *args, **kwargs):
"""Emit a SocketIO event.
This function emits a SocketIO event to one or more connected clients. A
JSON blob can be attached to the event as payload. This is a function that
can only be called from a SocketIO event handler, as in obtains some
information from the c... | [
"Emit",
"a",
"SocketIO",
"event",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L676-L726 | [
"def",
"emit",
"(",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'namespace'",
"in",
"kwargs",
":",
"namespace",
"=",
"kwargs",
"[",
"'namespace'",
"]",
"else",
":",
"namespace",
"=",
"flask",
".",
"request",
".",
"namespace",
... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | send | Send a SocketIO message.
This function sends a simple SocketIO message to one or more connected
clients. The message can be a string or a JSON blob. This is a simpler
version of ``emit()``, which should be preferred. This is a function that
can only be called from a SocketIO event handler.
:param ... | flask_socketio/__init__.py | def send(message, **kwargs):
"""Send a SocketIO message.
This function sends a simple SocketIO message to one or more connected
clients. The message can be a string or a JSON blob. This is a simpler
version of ``emit()``, which should be preferred. This is a function that
can only be called from a ... | def send(message, **kwargs):
"""Send a SocketIO message.
This function sends a simple SocketIO message to one or more connected
clients. The message can be a string or a JSON blob. This is a simpler
version of ``emit()``, which should be preferred. This is a function that
can only be called from a ... | [
"Send",
"a",
"SocketIO",
"message",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L729-L776 | [
"def",
"send",
"(",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"json",
"=",
"kwargs",
".",
"get",
"(",
"'json'",
",",
"False",
")",
"if",
"'namespace'",
"in",
"kwargs",
":",
"namespace",
"=",
"kwargs",
"[",
"'namespace'",
"]",
"else",
":",
"namesp... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | join_room | Join a room.
This function puts the user in a room, under the current namespace. The
user and the namespace are obtained from the event context. This is a
function that can only be called from a SocketIO event handler. Example::
@socketio.on('join')
def on_join(data):
username ... | flask_socketio/__init__.py | def join_room(room, sid=None, namespace=None):
"""Join a room.
This function puts the user in a room, under the current namespace. The
user and the namespace are obtained from the event context. This is a
function that can only be called from a SocketIO event handler. Example::
@socketio.on('j... | def join_room(room, sid=None, namespace=None):
"""Join a room.
This function puts the user in a room, under the current namespace. The
user and the namespace are obtained from the event context. This is a
function that can only be called from a SocketIO event handler. Example::
@socketio.on('j... | [
"Join",
"a",
"room",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L779-L802 | [
"def",
"join_room",
"(",
"room",
",",
"sid",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"socketio",
"=",
"flask",
".",
"current_app",
".",
"extensions",
"[",
"'socketio'",
"]",
"sid",
"=",
"sid",
"or",
"flask",
".",
"request",
".",
"sid",
... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | leave_room | Leave a room.
This function removes the user from a room, under the current namespace.
The user and the namespace are obtained from the event context. Example::
@socketio.on('leave')
def on_leave(data):
username = session['username']
room = data['room']
leav... | flask_socketio/__init__.py | def leave_room(room, sid=None, namespace=None):
"""Leave a room.
This function removes the user from a room, under the current namespace.
The user and the namespace are obtained from the event context. Example::
@socketio.on('leave')
def on_leave(data):
username = session['user... | def leave_room(room, sid=None, namespace=None):
"""Leave a room.
This function removes the user from a room, under the current namespace.
The user and the namespace are obtained from the event context. Example::
@socketio.on('leave')
def on_leave(data):
username = session['user... | [
"Leave",
"a",
"room",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L805-L827 | [
"def",
"leave_room",
"(",
"room",
",",
"sid",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"socketio",
"=",
"flask",
".",
"current_app",
".",
"extensions",
"[",
"'socketio'",
"]",
"sid",
"=",
"sid",
"or",
"flask",
".",
"request",
".",
"sid",
... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | close_room | Close a room.
This function removes any users that are in the given room and then deletes
the room from the server.
:param room: The name of the room to close.
:param namespace: The namespace for the room. If not provided, the
namespace is obtained from the request context. | flask_socketio/__init__.py | def close_room(room, namespace=None):
"""Close a room.
This function removes any users that are in the given room and then deletes
the room from the server.
:param room: The name of the room to close.
:param namespace: The namespace for the room. If not provided, the
namespac... | def close_room(room, namespace=None):
"""Close a room.
This function removes any users that are in the given room and then deletes
the room from the server.
:param room: The name of the room to close.
:param namespace: The namespace for the room. If not provided, the
namespac... | [
"Close",
"a",
"room",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L830-L842 | [
"def",
"close_room",
"(",
"room",
",",
"namespace",
"=",
"None",
")",
":",
"socketio",
"=",
"flask",
".",
"current_app",
".",
"extensions",
"[",
"'socketio'",
"]",
"namespace",
"=",
"namespace",
"or",
"flask",
".",
"request",
".",
"namespace",
"socketio",
... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | rooms | Return a list of the rooms the client is in.
This function returns all the rooms the client has entered, including its
own room, assigned by the Socket.IO server.
:param sid: The session id of the client. If not provided, the client is
obtained from the request context.
:param namespac... | flask_socketio/__init__.py | def rooms(sid=None, namespace=None):
"""Return a list of the rooms the client is in.
This function returns all the rooms the client has entered, including its
own room, assigned by the Socket.IO server.
:param sid: The session id of the client. If not provided, the client is
obtained f... | def rooms(sid=None, namespace=None):
"""Return a list of the rooms the client is in.
This function returns all the rooms the client has entered, including its
own room, assigned by the Socket.IO server.
:param sid: The session id of the client. If not provided, the client is
obtained f... | [
"Return",
"a",
"list",
"of",
"the",
"rooms",
"the",
"client",
"is",
"in",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L845-L859 | [
"def",
"rooms",
"(",
"sid",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"socketio",
"=",
"flask",
".",
"current_app",
".",
"extensions",
"[",
"'socketio'",
"]",
"sid",
"=",
"sid",
"or",
"flask",
".",
"request",
".",
"sid",
"namespace",
"=",
... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | disconnect | Disconnect the client.
This function terminates the connection with the client. As a result of
this call the client will receive a disconnect event. Example::
@socketio.on('message')
def receive_message(msg):
if is_banned(session['username']):
disconnect()
... | flask_socketio/__init__.py | def disconnect(sid=None, namespace=None, silent=False):
"""Disconnect the client.
This function terminates the connection with the client. As a result of
this call the client will receive a disconnect event. Example::
@socketio.on('message')
def receive_message(msg):
if is_bann... | def disconnect(sid=None, namespace=None, silent=False):
"""Disconnect the client.
This function terminates the connection with the client. As a result of
this call the client will receive a disconnect event. Example::
@socketio.on('message')
def receive_message(msg):
if is_bann... | [
"Disconnect",
"the",
"client",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L862-L884 | [
"def",
"disconnect",
"(",
"sid",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"silent",
"=",
"False",
")",
":",
"socketio",
"=",
"flask",
".",
"current_app",
".",
"extensions",
"[",
"'socketio'",
"]",
"sid",
"=",
"sid",
"or",
"flask",
".",
"request... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.on | Decorator to register a SocketIO event handler.
This decorator must be applied to SocketIO event handlers. Example::
@socketio.on('my event', namespace='/chat')
def handle_my_custom_event(json):
print('received json: ' + str(json))
:param message: The name of t... | flask_socketio/__init__.py | def on(self, message, namespace=None):
"""Decorator to register a SocketIO event handler.
This decorator must be applied to SocketIO event handlers. Example::
@socketio.on('my event', namespace='/chat')
def handle_my_custom_event(json):
print('received json: ' +... | def on(self, message, namespace=None):
"""Decorator to register a SocketIO event handler.
This decorator must be applied to SocketIO event handlers. Example::
@socketio.on('my event', namespace='/chat')
def handle_my_custom_event(json):
print('received json: ' +... | [
"Decorator",
"to",
"register",
"a",
"SocketIO",
"event",
"handler",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L235-L266 | [
"def",
"on",
"(",
"self",
",",
"message",
",",
"namespace",
"=",
"None",
")",
":",
"namespace",
"=",
"namespace",
"or",
"'/'",
"def",
"decorator",
"(",
"handler",
")",
":",
"def",
"_handler",
"(",
"sid",
",",
"*",
"args",
")",
":",
"return",
"self",
... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.on_error | Decorator to define a custom error handler for SocketIO events.
This decorator can be applied to a function that acts as an error
handler for a namespace. This handler will be invoked when a SocketIO
event handler raises an exception. The handler function must accept one
argument, which... | flask_socketio/__init__.py | def on_error(self, namespace=None):
"""Decorator to define a custom error handler for SocketIO events.
This decorator can be applied to a function that acts as an error
handler for a namespace. This handler will be invoked when a SocketIO
event handler raises an exception. The handler f... | def on_error(self, namespace=None):
"""Decorator to define a custom error handler for SocketIO events.
This decorator can be applied to a function that acts as an error
handler for a namespace. This handler will be invoked when a SocketIO
event handler raises an exception. The handler f... | [
"Decorator",
"to",
"define",
"a",
"custom",
"error",
"handler",
"for",
"SocketIO",
"events",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L268-L290 | [
"def",
"on_error",
"(",
"self",
",",
"namespace",
"=",
"None",
")",
":",
"namespace",
"=",
"namespace",
"or",
"'/'",
"def",
"decorator",
"(",
"exception_handler",
")",
":",
"if",
"not",
"callable",
"(",
"exception_handler",
")",
":",
"raise",
"ValueError",
... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.on_error_default | Decorator to define a default error handler for SocketIO events.
This decorator can be applied to a function that acts as a default
error handler for any namespaces that do not have a specific handler.
Example::
@socketio.on_error_default
def error_handler(e):
... | flask_socketio/__init__.py | def on_error_default(self, exception_handler):
"""Decorator to define a default error handler for SocketIO events.
This decorator can be applied to a function that acts as a default
error handler for any namespaces that do not have a specific handler.
Example::
@socketio.on... | def on_error_default(self, exception_handler):
"""Decorator to define a default error handler for SocketIO events.
This decorator can be applied to a function that acts as a default
error handler for any namespaces that do not have a specific handler.
Example::
@socketio.on... | [
"Decorator",
"to",
"define",
"a",
"default",
"error",
"handler",
"for",
"SocketIO",
"events",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L292-L306 | [
"def",
"on_error_default",
"(",
"self",
",",
"exception_handler",
")",
":",
"if",
"not",
"callable",
"(",
"exception_handler",
")",
":",
"raise",
"ValueError",
"(",
"'exception_handler must be callable'",
")",
"self",
".",
"default_exception_handler",
"=",
"exception_... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.on_event | Register a SocketIO event handler.
``on_event`` is the non-decorator version of ``'on'``.
Example::
def on_foo_event(json):
print('received json: ' + str(json))
socketio.on_event('my event', on_foo_event, namespace='/chat')
:param message: The name of... | flask_socketio/__init__.py | def on_event(self, message, handler, namespace=None):
"""Register a SocketIO event handler.
``on_event`` is the non-decorator version of ``'on'``.
Example::
def on_foo_event(json):
print('received json: ' + str(json))
socketio.on_event('my event', on_f... | def on_event(self, message, handler, namespace=None):
"""Register a SocketIO event handler.
``on_event`` is the non-decorator version of ``'on'``.
Example::
def on_foo_event(json):
print('received json: ' + str(json))
socketio.on_event('my event', on_f... | [
"Register",
"a",
"SocketIO",
"event",
"handler",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L308-L331 | [
"def",
"on_event",
"(",
"self",
",",
"message",
",",
"handler",
",",
"namespace",
"=",
"None",
")",
":",
"self",
".",
"on",
"(",
"message",
",",
"namespace",
"=",
"namespace",
")",
"(",
"handler",
")"
] | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.emit | Emit a server generated SocketIO event.
This function emits a SocketIO event to one or more connected clients.
A JSON blob can be attached to the event as payload. This function can
be used outside of a SocketIO event context, so it is appropriate to
use when the server is the originato... | flask_socketio/__init__.py | def emit(self, event, *args, **kwargs):
"""Emit a server generated SocketIO event.
This function emits a SocketIO event to one or more connected clients.
A JSON blob can be attached to the event as payload. This function can
be used outside of a SocketIO event context, so it is appropri... | def emit(self, event, *args, **kwargs):
"""Emit a server generated SocketIO event.
This function emits a SocketIO event to one or more connected clients.
A JSON blob can be attached to the event as payload. This function can
be used outside of a SocketIO event context, so it is appropri... | [
"Emit",
"a",
"server",
"generated",
"SocketIO",
"event",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L342-L381 | [
"def",
"emit",
"(",
"self",
",",
"event",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"kwargs",
".",
"pop",
"(",
"'namespace'",
",",
"'/'",
")",
"room",
"=",
"kwargs",
".",
"pop",
"(",
"'room'",
",",
"None",
")",
"inclu... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.send | Send a server-generated SocketIO message.
This function sends a simple SocketIO message to one or more connected
clients. The message can be a string or a JSON blob. This is a simpler
version of ``emit()``, which should be preferred. This function can be
used outside of a SocketIO event... | flask_socketio/__init__.py | def send(self, data, json=False, namespace=None, room=None,
callback=None, include_self=True, skip_sid=None, **kwargs):
"""Send a server-generated SocketIO message.
This function sends a simple SocketIO message to one or more connected
clients. The message can be a string or a JSON... | def send(self, data, json=False, namespace=None, room=None,
callback=None, include_self=True, skip_sid=None, **kwargs):
"""Send a server-generated SocketIO message.
This function sends a simple SocketIO message to one or more connected
clients. The message can be a string or a JSON... | [
"Send",
"a",
"server",
"-",
"generated",
"SocketIO",
"message",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L383-L417 | [
"def",
"send",
"(",
"self",
",",
"data",
",",
"json",
"=",
"False",
",",
"namespace",
"=",
"None",
",",
"room",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"include_self",
"=",
"True",
",",
"skip_sid",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.run | Run the SocketIO web server.
:param app: The Flask application instance.
:param host: The hostname or IP address for the server to listen on.
Defaults to 127.0.0.1.
:param port: The port number for the server to listen on. Defaults to
5000.
:par... | flask_socketio/__init__.py | def run(self, app, host=None, port=None, **kwargs):
"""Run the SocketIO web server.
:param app: The Flask application instance.
:param host: The hostname or IP address for the server to listen on.
Defaults to 127.0.0.1.
:param port: The port number for the server to... | def run(self, app, host=None, port=None, **kwargs):
"""Run the SocketIO web server.
:param app: The Flask application instance.
:param host: The hostname or IP address for the server to listen on.
Defaults to 127.0.0.1.
:param port: The port number for the server to... | [
"Run",
"the",
"SocketIO",
"web",
"server",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L432-L564 | [
"def",
"run",
"(",
"self",
",",
"app",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"host",
"is",
"None",
":",
"host",
"=",
"'127.0.0.1'",
"if",
"port",
"is",
"None",
":",
"server_name",
"=",
"app",... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.stop | Stop a running SocketIO web server.
This method must be called from a HTTP or SocketIO handler function. | flask_socketio/__init__.py | def stop(self):
"""Stop a running SocketIO web server.
This method must be called from a HTTP or SocketIO handler function.
"""
if self.server.eio.async_mode == 'threading':
func = flask.request.environ.get('werkzeug.server.shutdown')
if func:
fun... | def stop(self):
"""Stop a running SocketIO web server.
This method must be called from a HTTP or SocketIO handler function.
"""
if self.server.eio.async_mode == 'threading':
func = flask.request.environ.get('werkzeug.server.shutdown')
if func:
fun... | [
"Stop",
"a",
"running",
"SocketIO",
"web",
"server",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L566-L580 | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"server",
".",
"eio",
".",
"async_mode",
"==",
"'threading'",
":",
"func",
"=",
"flask",
".",
"request",
".",
"environ",
".",
"get",
"(",
"'werkzeug.server.shutdown'",
")",
"if",
"func",
":",
"fu... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | SocketIO.start_background_task | Start a background task using the appropriate async model.
This is a utility function that applications can use to start a
background task using the method that is compatible with the
selected async mode.
:param target: the target function to execute.
:param args: arguments to ... | flask_socketio/__init__.py | def start_background_task(self, target, *args, **kwargs):
"""Start a background task using the appropriate async model.
This is a utility function that applications can use to start a
background task using the method that is compatible with the
selected async mode.
:param targe... | def start_background_task(self, target, *args, **kwargs):
"""Start a background task using the appropriate async model.
This is a utility function that applications can use to start a
background task using the method that is compatible with the
selected async mode.
:param targe... | [
"Start",
"a",
"background",
"task",
"using",
"the",
"appropriate",
"async",
"model",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/__init__.py#L582-L597 | [
"def",
"start_background_task",
"(",
"self",
",",
"target",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"server",
".",
"start_background_task",
"(",
"target",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | Namespace.trigger_event | Dispatch an event to the proper handler method.
In the most common usage, this method is not overloaded by subclasses,
as it performs the routing of events to methods. However, this
method can be overriden if special dispatching rules are needed, or if
having a single method that catche... | flask_socketio/namespace.py | def trigger_event(self, event, *args):
"""Dispatch an event to the proper handler method.
In the most common usage, this method is not overloaded by subclasses,
as it performs the routing of events to methods. However, this
method can be overriden if special dispatching rules are needed... | def trigger_event(self, event, *args):
"""Dispatch an event to the proper handler method.
In the most common usage, this method is not overloaded by subclasses,
as it performs the routing of events to methods. However, this
method can be overriden if special dispatching rules are needed... | [
"Dispatch",
"an",
"event",
"to",
"the",
"proper",
"handler",
"method",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/namespace.py#L12-L26 | [
"def",
"trigger_event",
"(",
"self",
",",
"event",
",",
"*",
"args",
")",
":",
"handler_name",
"=",
"'on_'",
"+",
"event",
"if",
"not",
"hasattr",
"(",
"self",
",",
"handler_name",
")",
":",
"# there is no handler for this event, so we ignore it",
"return",
"han... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | Namespace.emit | Emit a custom event to one or more connected clients. | flask_socketio/namespace.py | def emit(self, event, data=None, room=None, include_self=True,
namespace=None, callback=None):
"""Emit a custom event to one or more connected clients."""
return self.socketio.emit(event, data, room=room,
include_self=include_self,
... | def emit(self, event, data=None, room=None, include_self=True,
namespace=None, callback=None):
"""Emit a custom event to one or more connected clients."""
return self.socketio.emit(event, data, room=room,
include_self=include_self,
... | [
"Emit",
"a",
"custom",
"event",
"to",
"one",
"or",
"more",
"connected",
"clients",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/namespace.py#L28-L34 | [
"def",
"emit",
"(",
"self",
",",
"event",
",",
"data",
"=",
"None",
",",
"room",
"=",
"None",
",",
"include_self",
"=",
"True",
",",
"namespace",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"return",
"self",
".",
"socketio",
".",
"emit",
"... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | Namespace.send | Send a message to one or more connected clients. | flask_socketio/namespace.py | def send(self, data, room=None, include_self=True, namespace=None,
callback=None):
"""Send a message to one or more connected clients."""
return self.socketio.send(data, room=room, include_self=include_self,
namespace=namespace or self.namespace,
... | def send(self, data, room=None, include_self=True, namespace=None,
callback=None):
"""Send a message to one or more connected clients."""
return self.socketio.send(data, room=room, include_self=include_self,
namespace=namespace or self.namespace,
... | [
"Send",
"a",
"message",
"to",
"one",
"or",
"more",
"connected",
"clients",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/namespace.py#L36-L41 | [
"def",
"send",
"(",
"self",
",",
"data",
",",
"room",
"=",
"None",
",",
"include_self",
"=",
"True",
",",
"namespace",
"=",
"None",
",",
"callback",
"=",
"None",
")",
":",
"return",
"self",
".",
"socketio",
".",
"send",
"(",
"data",
",",
"room",
"=... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | Namespace.close_room | Close a room. | flask_socketio/namespace.py | def close_room(self, room, namespace=None):
"""Close a room."""
return self.socketio.close_room(room=room,
namespace=namespace or self.namespace) | def close_room(self, room, namespace=None):
"""Close a room."""
return self.socketio.close_room(room=room,
namespace=namespace or self.namespace) | [
"Close",
"a",
"room",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/flask_socketio/namespace.py#L43-L46 | [
"def",
"close_room",
"(",
"self",
",",
"room",
",",
"namespace",
"=",
"None",
")",
":",
"return",
"self",
".",
"socketio",
".",
"close_room",
"(",
"room",
"=",
"room",
",",
"namespace",
"=",
"namespace",
"or",
"self",
".",
"namespace",
")"
] | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | background_thread | Example of how to send server generated events to clients. | example/app.py | def background_thread():
"""Example of how to send server generated events to clients."""
count = 0
while True:
socketio.sleep(10)
count += 1
socketio.emit('my_response',
{'data': 'Server generated event', 'count': count},
namespace='/test'... | def background_thread():
"""Example of how to send server generated events to clients."""
count = 0
while True:
socketio.sleep(10)
count += 1
socketio.emit('my_response',
{'data': 'Server generated event', 'count': count},
namespace='/test'... | [
"Example",
"of",
"how",
"to",
"send",
"server",
"generated",
"events",
"to",
"clients",
"."
] | miguelgrinberg/Flask-SocketIO | python | https://github.com/miguelgrinberg/Flask-SocketIO/blob/4bef800d5e7ba7d98a6f4cd94191ff0b4496c334/example/app.py#L19-L27 | [
"def",
"background_thread",
"(",
")",
":",
"count",
"=",
"0",
"while",
"True",
":",
"socketio",
".",
"sleep",
"(",
"10",
")",
"count",
"+=",
"1",
"socketio",
".",
"emit",
"(",
"'my_response'",
",",
"{",
"'data'",
":",
"'Server generated event'",
",",
"'c... | 4bef800d5e7ba7d98a6f4cd94191ff0b4496c334 |
train | OperationTask.on_failure | Update query status and send email notification to a user | polyaxon/pipelines/celery_task.py | def on_failure(self, exc, task_id, args, kwargs, einfo):
"""Update query status and send email notification to a user"""
super().on_failure(exc, task_id, args, kwargs, einfo)
if isinstance(exc, OperationRunDoesNotExist):
return
self._operation_run.on_failure() | def on_failure(self, exc, task_id, args, kwargs, einfo):
"""Update query status and send email notification to a user"""
super().on_failure(exc, task_id, args, kwargs, einfo)
if isinstance(exc, OperationRunDoesNotExist):
return
self._operation_run.on_failure() | [
"Update",
"query",
"status",
"and",
"send",
"email",
"notification",
"to",
"a",
"user"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/pipelines/celery_task.py#L32-L37 | [
"def",
"on_failure",
"(",
"self",
",",
"exc",
",",
"task_id",
",",
"args",
",",
"kwargs",
",",
"einfo",
")",
":",
"super",
"(",
")",
".",
"on_failure",
"(",
"exc",
",",
"task_id",
",",
"args",
",",
"kwargs",
",",
"einfo",
")",
"if",
"isinstance",
"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | OperationTask.on_success | Send email notification and a file, if requested to do so by a user | polyaxon/pipelines/celery_task.py | def on_success(self, retval, task_id, args, kwargs):
"""Send email notification and a file, if requested to do so by a user"""
super().on_success(retval, task_id, args, kwargs)
self._operation_run.on_success() | def on_success(self, retval, task_id, args, kwargs):
"""Send email notification and a file, if requested to do so by a user"""
super().on_success(retval, task_id, args, kwargs)
self._operation_run.on_success() | [
"Send",
"email",
"notification",
"and",
"a",
"file",
"if",
"requested",
"to",
"do",
"so",
"by",
"a",
"user"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/pipelines/celery_task.py#L43-L46 | [
"def",
"on_success",
"(",
"self",
",",
"retval",
",",
"task_id",
",",
"args",
",",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"on_success",
"(",
"retval",
",",
"task_id",
",",
"args",
",",
"kwargs",
")",
"self",
".",
"_operation_run",
".",
"on_success... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | AuditorService.record_event | Record the event async. | polyaxon/auditor/service.py | def record_event(self, event: Event) -> None:
"""
Record the event async.
"""
from polyaxon.celery_api import celery_app
from polyaxon.settings import EventsCeleryTasks
if not event.ref_id:
event.ref_id = self.get_ref_id()
serialized_event = event.ser... | def record_event(self, event: Event) -> None:
"""
Record the event async.
"""
from polyaxon.celery_api import celery_app
from polyaxon.settings import EventsCeleryTasks
if not event.ref_id:
event.ref_id = self.get_ref_id()
serialized_event = event.ser... | [
"Record",
"the",
"event",
"async",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/auditor/service.py#L33-L51 | [
"def",
"record_event",
"(",
"self",
",",
"event",
":",
"Event",
")",
"->",
"None",
":",
"from",
"polyaxon",
".",
"celery_api",
"import",
"celery_app",
"from",
"polyaxon",
".",
"settings",
"import",
"EventsCeleryTasks",
"if",
"not",
"event",
".",
"ref_id",
":... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | EventManager.user_write_events | Return event types where use acted on an object.
The write events are events with actions:
* CREATED
* UPDATED
* DELETED
* RESUMED
* COPIED
* CLONED
* STOPPED | polyaxon/event_manager/event_manager.py | def user_write_events(self) -> List[str]:
"""Return event types where use acted on an object.
The write events are events with actions:
* CREATED
* UPDATED
* DELETED
* RESUMED
* COPIED
* CLONED
* STOPPED
"""
... | def user_write_events(self) -> List[str]:
"""Return event types where use acted on an object.
The write events are events with actions:
* CREATED
* UPDATED
* DELETED
* RESUMED
* COPIED
* CLONED
* STOPPED
"""
... | [
"Return",
"event",
"types",
"where",
"use",
"acted",
"on",
"an",
"object",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/event_manager/event_manager.py#L26-L39 | [
"def",
"user_write_events",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"event_type",
"for",
"event_type",
",",
"event",
"in",
"self",
".",
"items",
"if",
"event",
".",
"get_event_action",
"(",
")",
"in",
"event_actions",
".",
"W... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | EventManager.user_view_events | Return event types where use viewed a main object. | polyaxon/event_manager/event_manager.py | def user_view_events(self) -> List[str]:
"""Return event types where use viewed a main object."""
return [event_type for event_type, event in self.items if event.get_event_action()
== event_actions.VIEWED] | def user_view_events(self) -> List[str]:
"""Return event types where use viewed a main object."""
return [event_type for event_type, event in self.items if event.get_event_action()
== event_actions.VIEWED] | [
"Return",
"event",
"types",
"where",
"use",
"viewed",
"a",
"main",
"object",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/event_manager/event_manager.py#L41-L44 | [
"def",
"user_view_events",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"event_type",
"for",
"event_type",
",",
"event",
"in",
"self",
".",
"items",
"if",
"event",
".",
"get_event_action",
"(",
")",
"==",
"event_actions",
".",
"VI... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | validate_new_email | Validates a "new" email address by checking if it is already used by other users. | polyaxon/api/users/validators.py | def validate_new_email(email):
"""Validates a "new" email address by checking if it is already used by other users."""
email = normalize_email(email)
User = get_user_model() # noqa
if User.objects.filter(email=email).exists():
raise ValidationError('The given email address is already registered... | def validate_new_email(email):
"""Validates a "new" email address by checking if it is already used by other users."""
email = normalize_email(email)
User = get_user_model() # noqa
if User.objects.filter(email=email).exists():
raise ValidationError('The given email address is already registered... | [
"Validates",
"a",
"new",
"email",
"address",
"by",
"checking",
"if",
"it",
"is",
"already",
"used",
"by",
"other",
"users",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/api/users/validators.py#L14-L19 | [
"def",
"validate_new_email",
"(",
"email",
")",
":",
"email",
"=",
"normalize_email",
"(",
"email",
")",
"User",
"=",
"get_user_model",
"(",
")",
"# noqa",
"if",
"User",
".",
"objects",
".",
"filter",
"(",
"email",
"=",
"email",
")",
".",
"exists",
"(",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | get_project_pod_spec | Pod spec to be used to create pods for project: tensorboard, notebooks. | polyaxon/scheduler/spawners/templates/project_jobs/pods.py | def get_project_pod_spec(volume_mounts,
volumes,
image,
command,
args,
ports,
env_vars=None,
env_from=None,
container_na... | def get_project_pod_spec(volume_mounts,
volumes,
image,
command,
args,
ports,
env_vars=None,
env_from=None,
container_na... | [
"Pod",
"spec",
"to",
"be",
"used",
"to",
"create",
"pods",
"for",
"project",
":",
"tensorboard",
"notebooks",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/scheduler/spawners/templates/project_jobs/pods.py#L41-L90 | [
"def",
"get_project_pod_spec",
"(",
"volume_mounts",
",",
"volumes",
",",
"image",
",",
"command",
",",
"args",
",",
"ports",
",",
"env_vars",
"=",
"None",
",",
"env_from",
"=",
"None",
",",
"container_name",
"=",
"None",
",",
"resources",
"=",
"None",
","... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | BaseEndpoint.get_object | We memoize the access to this function in case a second call is made. | polyaxon/api/endpoint/base.py | def get_object(self):
"""We memoize the access to this function in case a second call is made."""
if self._object:
return self._object
self._object = super().get_object()
if not self.AUDITOR_EVENT_TYPES:
return self._object
method = self.request.method
... | def get_object(self):
"""We memoize the access to this function in case a second call is made."""
if self._object:
return self._object
self._object = super().get_object()
if not self.AUDITOR_EVENT_TYPES:
return self._object
method = self.request.method
... | [
"We",
"memoize",
"the",
"access",
"to",
"this",
"function",
"in",
"case",
"a",
"second",
"call",
"is",
"made",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/api/endpoint/base.py#L37-L56 | [
"def",
"get_object",
"(",
"self",
")",
":",
"if",
"self",
".",
"_object",
":",
"return",
"self",
".",
"_object",
"self",
".",
"_object",
"=",
"super",
"(",
")",
".",
"get_object",
"(",
")",
"if",
"not",
"self",
".",
"AUDITOR_EVENT_TYPES",
":",
"return"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | BaseEndpoint.initialize_context | Initializes the endpoint with the context keys based on the passed
and/or based on the query parameters (request.GET). | polyaxon/api/endpoint/base.py | def initialize_context(self, request: HttpRequest, *args, **kwargs) -> None:
"""
Initializes the endpoint with the context keys based on the passed
and/or based on the query parameters (request.GET).
"""
for key in self.CONTEXT_KEYS:
setattr(self, key, kwargs.get(key)... | def initialize_context(self, request: HttpRequest, *args, **kwargs) -> None:
"""
Initializes the endpoint with the context keys based on the passed
and/or based on the query parameters (request.GET).
"""
for key in self.CONTEXT_KEYS:
setattr(self, key, kwargs.get(key)... | [
"Initializes",
"the",
"endpoint",
"with",
"the",
"context",
"keys",
"based",
"on",
"the",
"passed",
"and",
"/",
"or",
"based",
"on",
"the",
"query",
"parameters",
"(",
"request",
".",
"GET",
")",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/api/endpoint/base.py#L86-L96 | [
"def",
"initialize_context",
"(",
"self",
",",
"request",
":",
"HttpRequest",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"for",
"key",
"in",
"self",
".",
"CONTEXT_KEYS",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"kwargs",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | get_shm_volumes | Mount an tmpfs volume to /dev/shm.
This will set /dev/shm size to half of the RAM of node.
By default, /dev/shm is very small, only 64MB.
Some experiments will fail due to lack of share memory,
such as some experiments running on Pytorch. | polyaxon/scheduler/spawners/templates/volumes.py | def get_shm_volumes():
"""
Mount an tmpfs volume to /dev/shm.
This will set /dev/shm size to half of the RAM of node.
By default, /dev/shm is very small, only 64MB.
Some experiments will fail due to lack of share memory,
such as some experiments running on Pytorch.
"""
volumes, volume_mo... | def get_shm_volumes():
"""
Mount an tmpfs volume to /dev/shm.
This will set /dev/shm size to half of the RAM of node.
By default, /dev/shm is very small, only 64MB.
Some experiments will fail due to lack of share memory,
such as some experiments running on Pytorch.
"""
volumes, volume_mo... | [
"Mount",
"an",
"tmpfs",
"volume",
"to",
"/",
"dev",
"/",
"shm",
".",
"This",
"will",
"set",
"/",
"dev",
"/",
"shm",
"size",
"to",
"half",
"of",
"the",
"RAM",
"of",
"node",
".",
"By",
"default",
"/",
"dev",
"/",
"shm",
"is",
"very",
"small",
"only... | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/scheduler/spawners/templates/volumes.py#L128-L144 | [
"def",
"get_shm_volumes",
"(",
")",
":",
"volumes",
",",
"volume_mounts",
"=",
"[",
"]",
",",
"[",
"]",
"shm_volume",
"=",
"client",
".",
"V1Volume",
"(",
"name",
"=",
"constants",
".",
"SHM_VOLUME",
",",
"empty_dir",
"=",
"client",
".",
"V1EmptyDirVolumeS... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Experiment.last_job_statuses | The last constants of the job in this experiment. | polyaxon/db/models/experiments.py | def last_job_statuses(self) -> List[str]:
"""The last constants of the job in this experiment."""
statuses = []
for status in self.jobs.values_list('status__status', flat=True):
if status is not None:
statuses.append(status)
return statuses | def last_job_statuses(self) -> List[str]:
"""The last constants of the job in this experiment."""
statuses = []
for status in self.jobs.values_list('status__status', flat=True):
if status is not None:
statuses.append(status)
return statuses | [
"The",
"last",
"constants",
"of",
"the",
"job",
"in",
"this",
"experiment",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/experiments.py#L196-L202 | [
"def",
"last_job_statuses",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"statuses",
"=",
"[",
"]",
"for",
"status",
"in",
"self",
".",
"jobs",
".",
"values_list",
"(",
"'status__status'",
",",
"flat",
"=",
"True",
")",
":",
"if",
"status",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Experiment.has_running_jobs | Return a boolean indicating if the experiment has any running jobs | polyaxon/db/models/experiments.py | def has_running_jobs(self) -> bool:
""""Return a boolean indicating if the experiment has any running jobs"""
return self.jobs.exclude(status__status__in=ExperimentLifeCycle.DONE_STATUS).exists() | def has_running_jobs(self) -> bool:
""""Return a boolean indicating if the experiment has any running jobs"""
return self.jobs.exclude(status__status__in=ExperimentLifeCycle.DONE_STATUS).exists() | [
"Return",
"a",
"boolean",
"indicating",
"if",
"the",
"experiment",
"has",
"any",
"running",
"jobs"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/experiments.py#L205-L207 | [
"def",
"has_running_jobs",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"jobs",
".",
"exclude",
"(",
"status__status__in",
"=",
"ExperimentLifeCycle",
".",
"DONE_STATUS",
")",
".",
"exists",
"(",
")"
] | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | get_internal_header | Return request's 'X_POLYAXON_INTERNAL:' header, as a bytestring. | polyaxon/scopes/authentication/internal.py | def get_internal_header(request: HttpRequest) -> str:
"""
Return request's 'X_POLYAXON_INTERNAL:' header, as a bytestring.
"""
return get_header(request=request, header_service=conf.get('HEADERS_INTERNAL')) | def get_internal_header(request: HttpRequest) -> str:
"""
Return request's 'X_POLYAXON_INTERNAL:' header, as a bytestring.
"""
return get_header(request=request, header_service=conf.get('HEADERS_INTERNAL')) | [
"Return",
"request",
"s",
"X_POLYAXON_INTERNAL",
":",
"header",
"as",
"a",
"bytestring",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/scopes/authentication/internal.py#L49-L53 | [
"def",
"get_internal_header",
"(",
"request",
":",
"HttpRequest",
")",
"->",
"str",
":",
"return",
"get_header",
"(",
"request",
"=",
"request",
",",
"header_service",
"=",
"conf",
".",
"get",
"(",
"'HEADERS_INTERNAL'",
")",
")"
] | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | logs_sidecars_experiments | Signal handling for sidecars logs. | polyaxon/logs_handlers/tasks/log_sidecars.py | def logs_sidecars_experiments(experiment_name: str,
experiment_uuid: str,
job_uuid: str,
log_lines: Optional[Union[str, Iterable[str]]]) -> None:
"""Signal handling for sidecars logs."""
handle_experiment_job_log(experimen... | def logs_sidecars_experiments(experiment_name: str,
experiment_uuid: str,
job_uuid: str,
log_lines: Optional[Union[str, Iterable[str]]]) -> None:
"""Signal handling for sidecars logs."""
handle_experiment_job_log(experimen... | [
"Signal",
"handling",
"for",
"sidecars",
"logs",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/logs_handlers/tasks/log_sidecars.py#L11-L25 | [
"def",
"logs_sidecars_experiments",
"(",
"experiment_name",
":",
"str",
",",
"experiment_uuid",
":",
"str",
",",
"job_uuid",
":",
"str",
",",
"log_lines",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Iterable",
"[",
"str",
"]",
"]",
"]",
")",
"->",
"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | logs_sidecars_jobs | Signal handling for sidecars logs. | polyaxon/logs_handlers/tasks/log_sidecars.py | def logs_sidecars_jobs(job_uuid: str,
job_name: str,
log_lines: Optional[Union[str, Iterable[str]]]) -> None:
"""Signal handling for sidecars logs."""
handle_job_logs(job_uuid=job_uuid,
job_name=job_name,
log_lines=log_lines)
... | def logs_sidecars_jobs(job_uuid: str,
job_name: str,
log_lines: Optional[Union[str, Iterable[str]]]) -> None:
"""Signal handling for sidecars logs."""
handle_job_logs(job_uuid=job_uuid,
job_name=job_name,
log_lines=log_lines)
... | [
"Signal",
"handling",
"for",
"sidecars",
"logs",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/logs_handlers/tasks/log_sidecars.py#L29-L41 | [
"def",
"logs_sidecars_jobs",
"(",
"job_uuid",
":",
"str",
",",
"job_name",
":",
"str",
",",
"log_lines",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Iterable",
"[",
"str",
"]",
"]",
"]",
")",
"->",
"None",
":",
"handle_job_logs",
"(",
"job_uuid",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | logs_sidecars_builds | Signal handling for sidecars logs. | polyaxon/logs_handlers/tasks/log_sidecars.py | def logs_sidecars_builds(job_uuid: str,
job_name: str,
log_lines: Optional[Union[str, Iterable[str]]]) -> None:
"""Signal handling for sidecars logs."""
handle_build_job_logs(job_uuid=job_uuid,
job_name=job_name,
... | def logs_sidecars_builds(job_uuid: str,
job_name: str,
log_lines: Optional[Union[str, Iterable[str]]]) -> None:
"""Signal handling for sidecars logs."""
handle_build_job_logs(job_uuid=job_uuid,
job_name=job_name,
... | [
"Signal",
"handling",
"for",
"sidecars",
"logs",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/logs_handlers/tasks/log_sidecars.py#L45-L57 | [
"def",
"logs_sidecars_builds",
"(",
"job_uuid",
":",
"str",
",",
"job_name",
":",
"str",
",",
"log_lines",
":",
"Optional",
"[",
"Union",
"[",
"str",
",",
"Iterable",
"[",
"str",
"]",
"]",
"]",
")",
"->",
"None",
":",
"handle_build_job_logs",
"(",
"job_u... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | GroupChecks.is_checked | One task ran (checked). | polyaxon/db/redis/group_check.py | def is_checked(self) -> bool:
"""One task ran (checked)."""
if not self.redis_key_checked:
return False
value = self._red.get(self.redis_key_checked)
if not value:
return False
return True | def is_checked(self) -> bool:
"""One task ran (checked)."""
if not self.redis_key_checked:
return False
value = self._red.get(self.redis_key_checked)
if not value:
return False
return True | [
"One",
"task",
"ran",
"(",
"checked",
")",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/redis/group_check.py#L37-L46 | [
"def",
"is_checked",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"redis_key_checked",
":",
"return",
"False",
"value",
"=",
"self",
".",
"_red",
".",
"get",
"(",
"self",
".",
"redis_key_checked",
")",
"if",
"not",
"value",
":",
"retu... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | GroupChecks.is_delayed | One task ran (checked), and one task has been delayed. | polyaxon/db/redis/group_check.py | def is_delayed(self) -> bool:
"""One task ran (checked), and one task has been delayed."""
if not self.redis_key_delayed:
return False
value = self._red.get(self.redis_key_delayed)
if not value:
return False
return True | def is_delayed(self) -> bool:
"""One task ran (checked), and one task has been delayed."""
if not self.redis_key_delayed:
return False
value = self._red.get(self.redis_key_delayed)
if not value:
return False
return True | [
"One",
"task",
"ran",
"(",
"checked",
")",
"and",
"one",
"task",
"has",
"been",
"delayed",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/redis/group_check.py#L48-L57 | [
"def",
"is_delayed",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"redis_key_delayed",
":",
"return",
"False",
"value",
"=",
"self",
".",
"_red",
".",
"get",
"(",
"self",
".",
"redis_key_delayed",
")",
"if",
"not",
"value",
":",
"retu... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.connect | This method connects to RabbitMQ, returning the connection handle.
When the connection is established, the on_connection_open method
will be invoked by pika.
:rtype: pika.SelectConnection | polyaxon/streams/consumers/consumers.py | def connect(self):
"""This method connects to RabbitMQ, returning the connection handle.
When the connection is established, the on_connection_open method
will be invoked by pika.
:rtype: pika.SelectConnection
"""
_logger.info('Connecting to %s', self.AMQP_URL)
w... | def connect(self):
"""This method connects to RabbitMQ, returning the connection handle.
When the connection is established, the on_connection_open method
will be invoked by pika.
:rtype: pika.SelectConnection
"""
_logger.info('Connecting to %s', self.AMQP_URL)
w... | [
"This",
"method",
"connects",
"to",
"RabbitMQ",
"returning",
"the",
"connection",
"handle",
".",
"When",
"the",
"connection",
"is",
"established",
"the",
"on_connection_open",
"method",
"will",
"be",
"invoked",
"by",
"pika",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L48-L61 | [
"def",
"connect",
"(",
"self",
")",
":",
"_logger",
".",
"info",
"(",
"'Connecting to %s'",
",",
"self",
".",
"AMQP_URL",
")",
"while",
"True",
":",
"try",
":",
"return",
"adapters",
".",
"AsyncioConnection",
"(",
"pika",
".",
"URLParameters",
"(",
"self",... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.on_channel_open | This method is invoked by pika when the channel has been opened.
The channel object is passed in so we can make use of it.
Since the channel is now open, we'll declare the exchange to use.
:param pika.channel.Channel channel: The channel object | polyaxon/streams/consumers/consumers.py | def on_channel_open(self, channel):
"""This method is invoked by pika when the channel has been opened.
The channel object is passed in so we can make use of it.
Since the channel is now open, we'll declare the exchange to use.
:param pika.channel.Channel channel: The channel object
... | def on_channel_open(self, channel):
"""This method is invoked by pika when the channel has been opened.
The channel object is passed in so we can make use of it.
Since the channel is now open, we'll declare the exchange to use.
:param pika.channel.Channel channel: The channel object
... | [
"This",
"method",
"is",
"invoked",
"by",
"pika",
"when",
"the",
"channel",
"has",
"been",
"opened",
".",
"The",
"channel",
"object",
"is",
"passed",
"in",
"so",
"we",
"can",
"make",
"use",
"of",
"it",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L121-L132 | [
"def",
"on_channel_open",
"(",
"self",
",",
"channel",
")",
":",
"_logger",
".",
"info",
"(",
"'Channel opened'",
")",
"self",
".",
"_channel",
"=",
"channel",
"self",
".",
"add_on_channel_close_callback",
"(",
")",
"self",
".",
"setup_exchange",
"(",
"self",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.setup_exchange | Setup the exchange on RabbitMQ by invoking the Exchange.Declare RPC
command. When it is complete, the on_exchange_declareok method will
be invoked by pika.
:param str|unicode exchange_name: The name of the exchange to declare | polyaxon/streams/consumers/consumers.py | def setup_exchange(self, exchange_name):
"""Setup the exchange on RabbitMQ by invoking the Exchange.Declare RPC
command. When it is complete, the on_exchange_declareok method will
be invoked by pika.
:param str|unicode exchange_name: The name of the exchange to declare
"""
... | def setup_exchange(self, exchange_name):
"""Setup the exchange on RabbitMQ by invoking the Exchange.Declare RPC
command. When it is complete, the on_exchange_declareok method will
be invoked by pika.
:param str|unicode exchange_name: The name of the exchange to declare
"""
... | [
"Setup",
"the",
"exchange",
"on",
"RabbitMQ",
"by",
"invoking",
"the",
"Exchange",
".",
"Declare",
"RPC",
"command",
".",
"When",
"it",
"is",
"complete",
"the",
"on_exchange_declareok",
"method",
"will",
"be",
"invoked",
"by",
"pika",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L134-L146 | [
"def",
"setup_exchange",
"(",
"self",
",",
"exchange_name",
")",
":",
"_logger",
".",
"debug",
"(",
"'Declaring exchange %s'",
",",
"exchange_name",
")",
"self",
".",
"_channel",
".",
"exchange_declare",
"(",
"self",
".",
"on_exchange_declareok",
",",
"exchange_na... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.setup_queue | Setup the queue on RabbitMQ by invoking the Queue.Declare RPC
command. When it is complete, the on_queue_declareok method will
be invoked by pika.
:param str|unicode queue_name: The name of the queue to declare. | polyaxon/streams/consumers/consumers.py | def setup_queue(self, queue_name):
"""Setup the queue on RabbitMQ by invoking the Queue.Declare RPC
command. When it is complete, the on_queue_declareok method will
be invoked by pika.
:param str|unicode queue_name: The name of the queue to declare.
"""
_logger.debug('De... | def setup_queue(self, queue_name):
"""Setup the queue on RabbitMQ by invoking the Queue.Declare RPC
command. When it is complete, the on_queue_declareok method will
be invoked by pika.
:param str|unicode queue_name: The name of the queue to declare.
"""
_logger.debug('De... | [
"Setup",
"the",
"queue",
"on",
"RabbitMQ",
"by",
"invoking",
"the",
"Queue",
".",
"Declare",
"RPC",
"command",
".",
"When",
"it",
"is",
"complete",
"the",
"on_queue_declareok",
"method",
"will",
"be",
"invoked",
"by",
"pika",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L157-L165 | [
"def",
"setup_queue",
"(",
"self",
",",
"queue_name",
")",
":",
"_logger",
".",
"debug",
"(",
"'Declaring queue %s'",
",",
"queue_name",
")",
"self",
".",
"_channel",
".",
"queue_declare",
"(",
"self",
".",
"on_queue_declareok",
",",
"queue_name",
")"
] | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.on_queue_declareok | Method invoked by pika when the Queue.Declare RPC call made in
setup_queue has completed. In this method we will bind the queue
and exchange together with the routing key by issuing the Queue.Bind
RPC command. When this command is complete, the on_bindok method will
be invoked by pika.
... | polyaxon/streams/consumers/consumers.py | def on_queue_declareok(self, method_frame):
"""Method invoked by pika when the Queue.Declare RPC call made in
setup_queue has completed. In this method we will bind the queue
and exchange together with the routing key by issuing the Queue.Bind
RPC command. When this command is complete, ... | def on_queue_declareok(self, method_frame):
"""Method invoked by pika when the Queue.Declare RPC call made in
setup_queue has completed. In this method we will bind the queue
and exchange together with the routing key by issuing the Queue.Bind
RPC command. When this command is complete, ... | [
"Method",
"invoked",
"by",
"pika",
"when",
"the",
"Queue",
".",
"Declare",
"RPC",
"call",
"made",
"in",
"setup_queue",
"has",
"completed",
".",
"In",
"this",
"method",
"we",
"will",
"bind",
"the",
"queue",
"and",
"exchange",
"together",
"with",
"the",
"rou... | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L167-L179 | [
"def",
"on_queue_declareok",
"(",
"self",
",",
"method_frame",
")",
":",
"_logger",
".",
"info",
"(",
"'Binding %s to %s with %s'",
",",
"self",
".",
"EXCHANGE",
",",
"self",
".",
"_queue",
",",
"self",
".",
"_routing_key",
")",
"self",
".",
"_channel",
".",... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.on_consumer_cancelled | Invoked by pika when RabbitMQ sends a Basic.Cancel for a consumer
receiving messages.
:param pika.frame.Method method_frame: The Basic.Cancel frame | polyaxon/streams/consumers/consumers.py | def on_consumer_cancelled(self, method_frame):
"""Invoked by pika when RabbitMQ sends a Basic.Cancel for a consumer
receiving messages.
:param pika.frame.Method method_frame: The Basic.Cancel frame
"""
_logger.info('Consumer was cancelled remotely, shutting down: %r', method_fra... | def on_consumer_cancelled(self, method_frame):
"""Invoked by pika when RabbitMQ sends a Basic.Cancel for a consumer
receiving messages.
:param pika.frame.Method method_frame: The Basic.Cancel frame
"""
_logger.info('Consumer was cancelled remotely, shutting down: %r', method_fra... | [
"Invoked",
"by",
"pika",
"when",
"RabbitMQ",
"sends",
"a",
"Basic",
".",
"Cancel",
"for",
"a",
"consumer",
"receiving",
"messages",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L189-L197 | [
"def",
"on_consumer_cancelled",
"(",
"self",
",",
"method_frame",
")",
":",
"_logger",
".",
"info",
"(",
"'Consumer was cancelled remotely, shutting down: %r'",
",",
"method_frame",
")",
"if",
"self",
".",
"_channel",
":",
"self",
".",
"_channel",
".",
"close",
"(... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.acknowledge_message | Acknowledge the message delivery from RabbitMQ by sending a
Basic.Ack RPC method for the delivery tag.
:param int delivery_tag: The delivery tag from the Basic.Deliver frame | polyaxon/streams/consumers/consumers.py | def acknowledge_message(self, delivery_tag):
"""Acknowledge the message delivery from RabbitMQ by sending a
Basic.Ack RPC method for the delivery tag.
:param int delivery_tag: The delivery tag from the Basic.Deliver frame
"""
_logger.debug('Acknowledging message %s', delivery_ta... | def acknowledge_message(self, delivery_tag):
"""Acknowledge the message delivery from RabbitMQ by sending a
Basic.Ack RPC method for the delivery tag.
:param int delivery_tag: The delivery tag from the Basic.Deliver frame
"""
_logger.debug('Acknowledging message %s', delivery_ta... | [
"Acknowledge",
"the",
"message",
"delivery",
"from",
"RabbitMQ",
"by",
"sending",
"a",
"Basic",
".",
"Ack",
"RPC",
"method",
"for",
"the",
"delivery",
"tag",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L199-L206 | [
"def",
"acknowledge_message",
"(",
"self",
",",
"delivery_tag",
")",
":",
"_logger",
".",
"debug",
"(",
"'Acknowledging message %s'",
",",
"delivery_tag",
")",
"self",
".",
"_channel",
".",
"basic_ack",
"(",
"delivery_tag",
")"
] | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.on_message | Invoked by pika when a message is delivered from RabbitMQ. The
channel is passed for your convenience. The basic_deliver object that
is passed in carries the exchange, routing key, delivery tag and
a redelivered flag for the message. The properties passed in is an
instance of BasicProper... | polyaxon/streams/consumers/consumers.py | def on_message(self, unused_channel, basic_deliver, properties, body):
"""Invoked by pika when a message is delivered from RabbitMQ. The
channel is passed for your convenience. The basic_deliver object that
is passed in carries the exchange, routing key, delivery tag and
a redelivered fl... | def on_message(self, unused_channel, basic_deliver, properties, body):
"""Invoked by pika when a message is delivered from RabbitMQ. The
channel is passed for your convenience. The basic_deliver object that
is passed in carries the exchange, routing key, delivery tag and
a redelivered fl... | [
"Invoked",
"by",
"pika",
"when",
"a",
"message",
"is",
"delivered",
"from",
"RabbitMQ",
".",
"The",
"channel",
"is",
"passed",
"for",
"your",
"convenience",
".",
"The",
"basic_deliver",
"object",
"that",
"is",
"passed",
"in",
"carries",
"the",
"exchange",
"r... | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L208-L227 | [
"def",
"on_message",
"(",
"self",
",",
"unused_channel",
",",
"basic_deliver",
",",
"properties",
",",
"body",
")",
":",
"_logger",
".",
"debug",
"(",
"'Received message # %s from %s: %s'",
",",
"basic_deliver",
".",
"delivery_tag",
",",
"properties",
".",
"app_id... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.stop_consuming | Tell RabbitMQ that you would like to stop consuming by sending the
Basic.Cancel RPC command. | polyaxon/streams/consumers/consumers.py | def stop_consuming(self):
"""Tell RabbitMQ that you would like to stop consuming by sending the
Basic.Cancel RPC command.
"""
if self._channel:
_logger.debug('Sending a Basic.Cancel RPC command to RabbitMQ')
self._channel.basic_cancel(self.on_cancelok, self._consu... | def stop_consuming(self):
"""Tell RabbitMQ that you would like to stop consuming by sending the
Basic.Cancel RPC command.
"""
if self._channel:
_logger.debug('Sending a Basic.Cancel RPC command to RabbitMQ')
self._channel.basic_cancel(self.on_cancelok, self._consu... | [
"Tell",
"RabbitMQ",
"that",
"you",
"would",
"like",
"to",
"stop",
"consuming",
"by",
"sending",
"the",
"Basic",
".",
"Cancel",
"RPC",
"command",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L240-L246 | [
"def",
"stop_consuming",
"(",
"self",
")",
":",
"if",
"self",
".",
"_channel",
":",
"_logger",
".",
"debug",
"(",
"'Sending a Basic.Cancel RPC command to RabbitMQ'",
")",
"self",
".",
"_channel",
".",
"basic_cancel",
"(",
"self",
".",
"on_cancelok",
",",
"self",... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.open_channel | Open a new channel with RabbitMQ by issuing the Channel.Open RPC
command. When RabbitMQ responds that the channel is open, the
on_channel_open callback will be invoked by pika. | polyaxon/streams/consumers/consumers.py | def open_channel(self):
"""Open a new channel with RabbitMQ by issuing the Channel.Open RPC
command. When RabbitMQ responds that the channel is open, the
on_channel_open callback will be invoked by pika.
"""
_logger.info('Creating a new channel')
self._connection.channel(... | def open_channel(self):
"""Open a new channel with RabbitMQ by issuing the Channel.Open RPC
command. When RabbitMQ responds that the channel is open, the
on_channel_open callback will be invoked by pika.
"""
_logger.info('Creating a new channel')
self._connection.channel(... | [
"Open",
"a",
"new",
"channel",
"with",
"RabbitMQ",
"by",
"issuing",
"the",
"Channel",
".",
"Open",
"RPC",
"command",
".",
"When",
"RabbitMQ",
"responds",
"that",
"the",
"channel",
"is",
"open",
"the",
"on_channel_open",
"callback",
"will",
"be",
"invoked",
"... | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L280-L286 | [
"def",
"open_channel",
"(",
"self",
")",
":",
"_logger",
".",
"info",
"(",
"'Creating a new channel'",
")",
"self",
".",
"_connection",
".",
"channel",
"(",
"on_open_callback",
"=",
"self",
".",
"on_channel_open",
")"
] | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.run | Run the example consumer by connecting to RabbitMQ and then
starting the IOLoop to block and allow the SelectConnection to operate. | polyaxon/streams/consumers/consumers.py | def run(self):
"""Run the example consumer by connecting to RabbitMQ and then
starting the IOLoop to block and allow the SelectConnection to operate.
"""
self._connection = self.connect()
self._connection.ioloop.start() | def run(self):
"""Run the example consumer by connecting to RabbitMQ and then
starting the IOLoop to block and allow the SelectConnection to operate.
"""
self._connection = self.connect()
self._connection.ioloop.start() | [
"Run",
"the",
"example",
"consumer",
"by",
"connecting",
"to",
"RabbitMQ",
"and",
"then",
"starting",
"the",
"IOLoop",
"to",
"block",
"and",
"allow",
"the",
"SelectConnection",
"to",
"operate",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L288-L293 | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"_connection",
"=",
"self",
".",
"connect",
"(",
")",
"self",
".",
"_connection",
".",
"ioloop",
".",
"start",
"(",
")"
] | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Consumer.stop | Cleanly shutdown the connection to RabbitMQ by stopping the consumer
with RabbitMQ. When RabbitMQ confirms the cancellation, on_cancelok
will be invoked by pika, which will then closing the channel and
connection. The IOLoop is started again because this method is invoked
when CTRL-C is ... | polyaxon/streams/consumers/consumers.py | def stop(self):
"""Cleanly shutdown the connection to RabbitMQ by stopping the consumer
with RabbitMQ. When RabbitMQ confirms the cancellation, on_cancelok
will be invoked by pika, which will then closing the channel and
connection. The IOLoop is started again because this method is invo... | def stop(self):
"""Cleanly shutdown the connection to RabbitMQ by stopping the consumer
with RabbitMQ. When RabbitMQ confirms the cancellation, on_cancelok
will be invoked by pika, which will then closing the channel and
connection. The IOLoop is started again because this method is invo... | [
"Cleanly",
"shutdown",
"the",
"connection",
"to",
"RabbitMQ",
"by",
"stopping",
"the",
"consumer",
"with",
"RabbitMQ",
".",
"When",
"RabbitMQ",
"confirms",
"the",
"cancellation",
"on_cancelok",
"will",
"be",
"invoked",
"by",
"pika",
"which",
"will",
"then",
"clo... | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/streams/consumers/consumers.py#L295-L309 | [
"def",
"stop",
"(",
"self",
")",
":",
"_logger",
".",
"debug",
"(",
"'Stopping'",
")",
"self",
".",
"_closing",
"=",
"True",
"self",
".",
"stop_consuming",
"(",
")",
"self",
".",
"_connection",
".",
"ioloop",
".",
"start",
"(",
")",
"_logger",
".",
"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | render_mail_template | Renders both the subject and body templates in the given context.
Returns a tuple (subject, body) of the result. | polyaxon/action_manager/utils/email.py | def render_mail_template(subject_template, body_template, context):
"""
Renders both the subject and body templates in the given context.
Returns a tuple (subject, body) of the result.
"""
try:
subject = strip_spaces(render_to_string(subject_template, context))
body = render_to_strin... | def render_mail_template(subject_template, body_template, context):
"""
Renders both the subject and body templates in the given context.
Returns a tuple (subject, body) of the result.
"""
try:
subject = strip_spaces(render_to_string(subject_template, context))
body = render_to_strin... | [
"Renders",
"both",
"the",
"subject",
"and",
"body",
"templates",
"in",
"the",
"given",
"context",
".",
"Returns",
"a",
"tuple",
"(",
"subject",
"body",
")",
"of",
"the",
"result",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/action_manager/utils/email.py#L9-L20 | [
"def",
"render_mail_template",
"(",
"subject_template",
",",
"body_template",
",",
"context",
")",
":",
"try",
":",
"subject",
"=",
"strip_spaces",
"(",
"render_to_string",
"(",
"subject_template",
",",
"context",
")",
")",
"body",
"=",
"render_to_string",
"(",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | send_mass_template_mail | Renders an email subject and body using the given templates and context,
then sends it to the given recipients list.
The emails are send one-by-one. | polyaxon/action_manager/utils/email.py | def send_mass_template_mail(subject_template, body_template, recipients, context=None):
"""
Renders an email subject and body using the given templates and context,
then sends it to the given recipients list.
The emails are send one-by-one.
"""
if context:
subject, body = render_mail_te... | def send_mass_template_mail(subject_template, body_template, recipients, context=None):
"""
Renders an email subject and body using the given templates and context,
then sends it to the given recipients list.
The emails are send one-by-one.
"""
if context:
subject, body = render_mail_te... | [
"Renders",
"an",
"email",
"subject",
"and",
"body",
"using",
"the",
"given",
"templates",
"and",
"context",
"then",
"sends",
"it",
"to",
"the",
"given",
"recipients",
"list",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/action_manager/utils/email.py#L23-L37 | [
"def",
"send_mass_template_mail",
"(",
"subject_template",
",",
"body_template",
",",
"recipients",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
":",
"subject",
",",
"body",
"=",
"render_mail_template",
"(",
"subject_template",
",",
"body_template",
","... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | send_mass_user_template_mail | Similar to `send_mass_template_mail` this function renders the given templates
into email subjects and bodies.
The emails are send one-by-one. | polyaxon/action_manager/utils/email.py | def send_mass_user_template_mail(subject_template, body_template, users, context):
"""
Similar to `send_mass_template_mail` this function renders the given templates
into email subjects and bodies.
The emails are send one-by-one.
"""
message_tuples = []
for user in users:
context['u... | def send_mass_user_template_mail(subject_template, body_template, users, context):
"""
Similar to `send_mass_template_mail` this function renders the given templates
into email subjects and bodies.
The emails are send one-by-one.
"""
message_tuples = []
for user in users:
context['u... | [
"Similar",
"to",
"send_mass_template_mail",
"this",
"function",
"renders",
"the",
"given",
"templates",
"into",
"email",
"subjects",
"and",
"bodies",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/action_manager/utils/email.py#L40-L55 | [
"def",
"send_mass_user_template_mail",
"(",
"subject_template",
",",
"body_template",
",",
"users",
",",
"context",
")",
":",
"message_tuples",
"=",
"[",
"]",
"for",
"user",
"in",
"users",
":",
"context",
"[",
"'user'",
"]",
"=",
"user",
"subject",
",",
"bod... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | checkout_commit | Checkout to a specific commit.
If commit is None then checkout to master. | polyaxon/libs/repos/git/__init__.py | def checkout_commit(repo_path: str,
commit: Any = None) -> None: # pylint:disable=redefined-outer-name
"""Checkout to a specific commit.
If commit is None then checkout to master.
"""
commit = commit or 'master'
run_command(cmd='git checkout {}'.format(commit), data=None, locat... | def checkout_commit(repo_path: str,
commit: Any = None) -> None: # pylint:disable=redefined-outer-name
"""Checkout to a specific commit.
If commit is None then checkout to master.
"""
commit = commit or 'master'
run_command(cmd='git checkout {}'.format(commit), data=None, locat... | [
"Checkout",
"to",
"a",
"specific",
"commit",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/libs/repos/git/__init__.py#L120-L127 | [
"def",
"checkout_commit",
"(",
"repo_path",
":",
"str",
",",
"commit",
":",
"Any",
"=",
"None",
")",
"->",
"None",
":",
"# pylint:disable=redefined-outer-name",
"commit",
"=",
"commit",
"or",
"'master'",
"run_command",
"(",
"cmd",
"=",
"'git checkout {}'",
".",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | create_tarfile | Create a tar file based on the list of files passed | polyaxon/libs/archive.py | def create_tarfile(files: List[str], tar_path: str) -> None:
"""Create a tar file based on the list of files passed"""
with tarfile.open(tar_path, "w:gz") as tar:
for f in files:
tar.add(f) | def create_tarfile(files: List[str], tar_path: str) -> None:
"""Create a tar file based on the list of files passed"""
with tarfile.open(tar_path, "w:gz") as tar:
for f in files:
tar.add(f) | [
"Create",
"a",
"tar",
"file",
"based",
"on",
"the",
"list",
"of",
"files",
"passed"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/libs/archive.py#L16-L20 | [
"def",
"create_tarfile",
"(",
"files",
":",
"List",
"[",
"str",
"]",
",",
"tar_path",
":",
"str",
")",
"->",
"None",
":",
"with",
"tarfile",
".",
"open",
"(",
"tar_path",
",",
"\"w:gz\"",
")",
"as",
"tar",
":",
"for",
"f",
"in",
"files",
":",
"tar"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | RabbitMQCheck.check | Open and close the broker channel. | polyaxon/checks/rabbitmq.py | def check() -> Result:
"""Open and close the broker channel."""
try:
# Context to release connection
with Connection(conf.get('CELERY_BROKER_URL')) as conn:
conn.connect()
except ConnectionRefusedError:
return Result(message='Service unable to ... | def check() -> Result:
"""Open and close the broker channel."""
try:
# Context to release connection
with Connection(conf.get('CELERY_BROKER_URL')) as conn:
conn.connect()
except ConnectionRefusedError:
return Result(message='Service unable to ... | [
"Open",
"and",
"close",
"the",
"broker",
"channel",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/checks/rabbitmq.py#L19-L39 | [
"def",
"check",
"(",
")",
"->",
"Result",
":",
"try",
":",
"# Context to release connection",
"with",
"Connection",
"(",
"conf",
".",
"get",
"(",
"'CELERY_BROKER_URL'",
")",
")",
"as",
"conn",
":",
"conn",
".",
"connect",
"(",
")",
"except",
"ConnectionRefus... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | GridSearchManager.get_suggestions | Return a list of suggestions based on grid search.
Params:
matrix: `dict` representing the {hyperparam: hyperparam matrix config}.
n_suggestions: number of suggestions to make. | polyaxon/hpsearch/search_managers/grid.py | def get_suggestions(self, iteration_config=None):
"""Return a list of suggestions based on grid search.
Params:
matrix: `dict` representing the {hyperparam: hyperparam matrix config}.
n_suggestions: number of suggestions to make.
"""
matrix = self.hptuning_config... | def get_suggestions(self, iteration_config=None):
"""Return a list of suggestions based on grid search.
Params:
matrix: `dict` representing the {hyperparam: hyperparam matrix config}.
n_suggestions: number of suggestions to make.
"""
matrix = self.hptuning_config... | [
"Return",
"a",
"list",
"of",
"suggestions",
"based",
"on",
"grid",
"search",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/search_managers/grid.py#L12-L31 | [
"def",
"get_suggestions",
"(",
"self",
",",
"iteration_config",
"=",
"None",
")",
":",
"matrix",
"=",
"self",
".",
"hptuning_config",
".",
"matrix",
"suggestions",
"=",
"[",
"]",
"keys",
"=",
"list",
"(",
"matrix",
".",
"keys",
"(",
")",
")",
"values",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | BOOptimizer._maximize | Find argmax of the acquisition function. | polyaxon/hpsearch/search_managers/bayesian_optimization/optimizer.py | def _maximize(self):
""" Find argmax of the acquisition function."""
if not self.space.is_observations_valid():
return None
y_max = self.space.y.max()
self.utility_function.gaussian_process.fit(self.space.x, self.space.y)
return self.utility_function.max_compute(y_max... | def _maximize(self):
""" Find argmax of the acquisition function."""
if not self.space.is_observations_valid():
return None
y_max = self.space.y.max()
self.utility_function.gaussian_process.fit(self.space.x, self.space.y)
return self.utility_function.max_compute(y_max... | [
"Find",
"argmax",
"of",
"the",
"acquisition",
"function",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/search_managers/bayesian_optimization/optimizer.py#L16-L25 | [
"def",
"_maximize",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"space",
".",
"is_observations_valid",
"(",
")",
":",
"return",
"None",
"y_max",
"=",
"self",
".",
"space",
".",
"y",
".",
"max",
"(",
")",
"self",
".",
"utility_function",
".",
"ga... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Pipeline.dag | Construct the DAG of this pipeline based on the its operations and their downstream. | polyaxon/db/models/pipelines.py | def dag(self) -> Tuple[Dict, Dict]:
"""Construct the DAG of this pipeline based on the its operations and their downstream."""
from pipelines import dags
operations = self.operations.all().prefetch_related('downstream_operations')
def get_downstream(op):
return op.downstrea... | def dag(self) -> Tuple[Dict, Dict]:
"""Construct the DAG of this pipeline based on the its operations and their downstream."""
from pipelines import dags
operations = self.operations.all().prefetch_related('downstream_operations')
def get_downstream(op):
return op.downstrea... | [
"Construct",
"the",
"DAG",
"of",
"this",
"pipeline",
"based",
"on",
"the",
"its",
"operations",
"and",
"their",
"downstream",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L136-L145 | [
"def",
"dag",
"(",
"self",
")",
"->",
"Tuple",
"[",
"Dict",
",",
"Dict",
"]",
":",
"from",
"pipelines",
"import",
"dags",
"operations",
"=",
"self",
".",
"operations",
".",
"all",
"(",
")",
".",
"prefetch_related",
"(",
"'downstream_operations'",
")",
"d... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Operation.get_countdown | Calculate the countdown for a celery task retry. | polyaxon/db/models/pipelines.py | def get_countdown(self, retries) -> int:
"""Calculate the countdown for a celery task retry."""
retry_delay = self.retry_delay
if self.retry_exponential_backoff:
return min(
max(2 ** retries, retry_delay), # Exp. backoff
self.max_retry_delay # The co... | def get_countdown(self, retries) -> int:
"""Calculate the countdown for a celery task retry."""
retry_delay = self.retry_delay
if self.retry_exponential_backoff:
return min(
max(2 ** retries, retry_delay), # Exp. backoff
self.max_retry_delay # The co... | [
"Calculate",
"the",
"countdown",
"for",
"a",
"celery",
"task",
"retry",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L248-L256 | [
"def",
"get_countdown",
"(",
"self",
",",
"retries",
")",
"->",
"int",
":",
"retry_delay",
"=",
"self",
".",
"retry_delay",
"if",
"self",
".",
"retry_exponential_backoff",
":",
"return",
"min",
"(",
"max",
"(",
"2",
"**",
"retries",
",",
"retry_delay",
")"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | Operation.get_run_params | Return the params to run the celery task. | polyaxon/db/models/pipelines.py | def get_run_params(self) -> Dict:
"""Return the params to run the celery task."""
params = {}
if self.celery_queue:
params['queue'] = self.celery_queue
if self.timeout:
params['soft_time_limit'] = self.timeout
# We set also a hard time limit that will... | def get_run_params(self) -> Dict:
"""Return the params to run the celery task."""
params = {}
if self.celery_queue:
params['queue'] = self.celery_queue
if self.timeout:
params['soft_time_limit'] = self.timeout
# We set also a hard time limit that will... | [
"Return",
"the",
"params",
"to",
"run",
"the",
"celery",
"task",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L258-L273 | [
"def",
"get_run_params",
"(",
"self",
")",
"->",
"Dict",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"celery_queue",
":",
"params",
"[",
"'queue'",
"]",
"=",
"self",
".",
"celery_queue",
"if",
"self",
".",
"timeout",
":",
"params",
"[",
"'soft_tim... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | RunModel.can_transition | Update the status of the current instance.
Returns:
boolean: if the instance is updated. | polyaxon/db/models/pipelines.py | def can_transition(self, status_from: str, status_to: str) -> bool:
"""Update the status of the current instance.
Returns:
boolean: if the instance is updated.
"""
if not self.STATUSES.can_transition(status_from=status_from, status_to=status_to):
_logger.info(
... | def can_transition(self, status_from: str, status_to: str) -> bool:
"""Update the status of the current instance.
Returns:
boolean: if the instance is updated.
"""
if not self.STATUSES.can_transition(status_from=status_from, status_to=status_to):
_logger.info(
... | [
"Update",
"the",
"status",
"of",
"the",
"current",
"instance",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L343-L355 | [
"def",
"can_transition",
"(",
"self",
",",
"status_from",
":",
"str",
",",
"status_to",
":",
"str",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"STATUSES",
".",
"can_transition",
"(",
"status_from",
"=",
"status_from",
",",
"status_to",
"=",
"status_... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | PipelineRun.dag | Construct the DAG of this pipeline run
based on the its operation runs and their downstream. | polyaxon/db/models/pipelines.py | def dag(self) -> Tuple[Dict, Dict]:
"""Construct the DAG of this pipeline run
based on the its operation runs and their downstream.
"""
from pipelines import dags
operation_runs = self.operation_runs.all().prefetch_related('downstream_runs')
def get_downstream(op_run):
... | def dag(self) -> Tuple[Dict, Dict]:
"""Construct the DAG of this pipeline run
based on the its operation runs and their downstream.
"""
from pipelines import dags
operation_runs = self.operation_runs.all().prefetch_related('downstream_runs')
def get_downstream(op_run):
... | [
"Construct",
"the",
"DAG",
"of",
"this",
"pipeline",
"run",
"based",
"on",
"the",
"its",
"operation",
"runs",
"and",
"their",
"downstream",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L398-L409 | [
"def",
"dag",
"(",
"self",
")",
"->",
"Tuple",
"[",
"Dict",
",",
"Dict",
"]",
":",
"from",
"pipelines",
"import",
"dags",
"operation_runs",
"=",
"self",
".",
"operation_runs",
".",
"all",
"(",
")",
".",
"prefetch_related",
"(",
"'downstream_runs'",
")",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | OperationRun.check_concurrency | Checks the concurrency of the operation run.
Checks the concurrency of the operation run
to validate if we can start a new operation run.
Returns:
boolean: Whether to start a new operation run or not. | polyaxon/db/models/pipelines.py | def check_concurrency(self) -> bool:
"""Checks the concurrency of the operation run.
Checks the concurrency of the operation run
to validate if we can start a new operation run.
Returns:
boolean: Whether to start a new operation run or not.
"""
if not self.o... | def check_concurrency(self) -> bool:
"""Checks the concurrency of the operation run.
Checks the concurrency of the operation run
to validate if we can start a new operation run.
Returns:
boolean: Whether to start a new operation run or not.
"""
if not self.o... | [
"Checks",
"the",
"concurrency",
"of",
"the",
"operation",
"run",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L533-L547 | [
"def",
"check_concurrency",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"operation",
".",
"concurrency",
":",
"# No concurrency set",
"return",
"True",
"ops_count",
"=",
"self",
".",
"operation",
".",
"runs",
".",
"filter",
"(",
"status__s... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | OperationRun.check_upstream_trigger | Checks the upstream and the trigger rule. | polyaxon/db/models/pipelines.py | def check_upstream_trigger(self) -> bool:
"""Checks the upstream and the trigger rule."""
if self.operation.trigger_policy == TriggerPolicy.ONE_DONE:
return self.upstream_runs.filter(
status__status__in=self.STATUSES.DONE_STATUS).exists()
if self.operation.trigger_pol... | def check_upstream_trigger(self) -> bool:
"""Checks the upstream and the trigger rule."""
if self.operation.trigger_policy == TriggerPolicy.ONE_DONE:
return self.upstream_runs.filter(
status__status__in=self.STATUSES.DONE_STATUS).exists()
if self.operation.trigger_pol... | [
"Checks",
"the",
"upstream",
"and",
"the",
"trigger",
"rule",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L549-L570 | [
"def",
"check_upstream_trigger",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"operation",
".",
"trigger_policy",
"==",
"TriggerPolicy",
".",
"ONE_DONE",
":",
"return",
"self",
".",
"upstream_runs",
".",
"filter",
"(",
"status__status__in",
"=",
"se... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | OperationRun.schedule_start | Schedule the task: check first if the task can start:
1. we check that the task is still in the CREATED state.
2. we check that the upstream dependency is met.
3. we check that pipeline can start a new task;
i.e. we check the concurrency of the pipeline.
4. ... | polyaxon/db/models/pipelines.py | def schedule_start(self) -> bool:
"""Schedule the task: check first if the task can start:
1. we check that the task is still in the CREATED state.
2. we check that the upstream dependency is met.
3. we check that pipeline can start a new task;
i.e. we check the... | def schedule_start(self) -> bool:
"""Schedule the task: check first if the task can start:
1. we check that the task is still in the CREATED state.
2. we check that the upstream dependency is met.
3. we check that pipeline can start a new task;
i.e. we check the... | [
"Schedule",
"the",
"task",
":",
"check",
"first",
"if",
"the",
"task",
"can",
"start",
":",
"1",
".",
"we",
"check",
"that",
"the",
"task",
"is",
"still",
"in",
"the",
"CREATED",
"state",
".",
"2",
".",
"we",
"check",
"that",
"the",
"upstream",
"depe... | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L578-L623 | [
"def",
"schedule_start",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"last_status",
"!=",
"self",
".",
"STATUSES",
".",
"CREATED",
":",
"return",
"False",
"upstream_trigger_check",
"=",
"self",
".",
"check_upstream_trigger",
"(",
")",
"if",
"not"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | OperationRun.start | Start the celery task of this operation. | polyaxon/db/models/pipelines.py | def start(self) -> None:
"""Start the celery task of this operation."""
kwargs = self.celery_task_context
# Update we the operation run id
kwargs['operation_run_id'] = self.id # pylint:disable=unsupported-assignment-operation
async_result = celery_app.send_task(
sel... | def start(self) -> None:
"""Start the celery task of this operation."""
kwargs = self.celery_task_context
# Update we the operation run id
kwargs['operation_run_id'] = self.id # pylint:disable=unsupported-assignment-operation
async_result = celery_app.send_task(
sel... | [
"Start",
"the",
"celery",
"task",
"of",
"this",
"operation",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/db/models/pipelines.py#L625-L636 | [
"def",
"start",
"(",
"self",
")",
"->",
"None",
":",
"kwargs",
"=",
"self",
".",
"celery_task_context",
"# Update we the operation run id",
"kwargs",
"[",
"'operation_run_id'",
"]",
"=",
"self",
".",
"id",
"# pylint:disable=unsupported-assignment-operation",
"async_resu... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | get_experiment_image_info | Return the image name and image tag for an experiment | polyaxon/docker_images/image_info.py | def get_experiment_image_info(experiment: 'Experiment') -> Tuple[str, str]:
"""Return the image name and image tag for an experiment"""
project_name = experiment.project.name
repo_name = project_name
image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
image_tag = experiment.code_refere... | def get_experiment_image_info(experiment: 'Experiment') -> Tuple[str, str]:
"""Return the image name and image tag for an experiment"""
project_name = experiment.project.name
repo_name = project_name
image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
image_tag = experiment.code_refere... | [
"Return",
"the",
"image",
"name",
"and",
"image",
"tag",
"for",
"an",
"experiment"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/docker_images/image_info.py#L12-L19 | [
"def",
"get_experiment_image_info",
"(",
"experiment",
":",
"'Experiment'",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"project_name",
"=",
"experiment",
".",
"project",
".",
"name",
"repo_name",
"=",
"project_name",
"image_name",
"=",
"'{}/{}'",
".... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | get_job_image_info | Return the image name and image tag for a job | polyaxon/docker_images/image_info.py | def get_job_image_info(project: 'Project', job: Any) -> Tuple[str, str]:
"""Return the image name and image tag for a job"""
project_name = project.name
repo_name = project_name
image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
try:
last_commit = project.repo.last_commit
... | def get_job_image_info(project: 'Project', job: Any) -> Tuple[str, str]:
"""Return the image name and image tag for a job"""
project_name = project.name
repo_name = project_name
image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
try:
last_commit = project.repo.last_commit
... | [
"Return",
"the",
"image",
"name",
"and",
"image",
"tag",
"for",
"a",
"job"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/docker_images/image_info.py#L22-L32 | [
"def",
"get_job_image_info",
"(",
"project",
":",
"'Project'",
",",
"job",
":",
"Any",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"project_name",
"=",
"project",
".",
"name",
"repo_name",
"=",
"project_name",
"image_name",
"=",
"'{}/{}'",
".",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | get_notebook_image_info | Return the image name and image tag for a job | polyaxon/docker_images/image_info.py | def get_notebook_image_info(project: 'Project', job: Any) -> Tuple[str, str]:
"""Return the image name and image tag for a job"""
image_name, _ = get_job_image_info(project, job)
return image_name, LATEST_IMAGE_TAG | def get_notebook_image_info(project: 'Project', job: Any) -> Tuple[str, str]:
"""Return the image name and image tag for a job"""
image_name, _ = get_job_image_info(project, job)
return image_name, LATEST_IMAGE_TAG | [
"Return",
"the",
"image",
"name",
"and",
"image",
"tag",
"for",
"a",
"job"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/docker_images/image_info.py#L35-L38 | [
"def",
"get_notebook_image_info",
"(",
"project",
":",
"'Project'",
",",
"job",
":",
"Any",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"image_name",
",",
"_",
"=",
"get_job_image_info",
"(",
"project",
",",
"job",
")",
"return",
"image_name",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | BOIterationManager.create_iteration | Create an iteration for the experiment group. | polyaxon/hpsearch/iteration_managers/bayesian_optimization.py | def create_iteration(self, num_suggestions):
"""Create an iteration for the experiment group."""
from db.models.experiment_groups import ExperimentGroupIteration
iteration_config = self.experiment_group.iteration_config
if iteration_config is None:
iteration = 0
... | def create_iteration(self, num_suggestions):
"""Create an iteration for the experiment group."""
from db.models.experiment_groups import ExperimentGroupIteration
iteration_config = self.experiment_group.iteration_config
if iteration_config is None:
iteration = 0
... | [
"Create",
"an",
"iteration",
"for",
"the",
"experiment",
"group",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/iteration_managers/bayesian_optimization.py#L9-L38 | [
"def",
"create_iteration",
"(",
"self",
",",
"num_suggestions",
")",
":",
"from",
"db",
".",
"models",
".",
"experiment_groups",
"import",
"ExperimentGroupIteration",
"iteration_config",
"=",
"self",
".",
"experiment_group",
".",
"iteration_config",
"if",
"iteration_c... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | BOIterationManager.update_iteration | Update the last experiment group's iteration with experiment performance. | polyaxon/hpsearch/iteration_managers/bayesian_optimization.py | def update_iteration(self):
"""Update the last experiment group's iteration with experiment performance."""
iteration_config = self.get_iteration_config()
if not iteration_config:
return
experiments_metrics = self.experiment_group.get_experiments_metrics(
experime... | def update_iteration(self):
"""Update the last experiment group's iteration with experiment performance."""
iteration_config = self.get_iteration_config()
if not iteration_config:
return
experiments_metrics = self.experiment_group.get_experiments_metrics(
experime... | [
"Update",
"the",
"last",
"experiment",
"group",
"s",
"iteration",
"with",
"experiment",
"performance",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/iteration_managers/bayesian_optimization.py#L40-L54 | [
"def",
"update_iteration",
"(",
"self",
")",
":",
"iteration_config",
"=",
"self",
".",
"get_iteration_config",
"(",
")",
"if",
"not",
"iteration_config",
":",
"return",
"experiments_metrics",
"=",
"self",
".",
"experiment_group",
".",
"get_experiments_metrics",
"("... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | HyperbandSearchManager.get_n_config_to_keep | Return the number of configs to keep and resume. | polyaxon/hpsearch/search_managers/hyperband.py | def get_n_config_to_keep(self, n_suggestions, bracket_iteration):
"""Return the number of configs to keep and resume."""
n_configs = n_suggestions * (self.eta ** -bracket_iteration)
return int(n_configs / self.eta) | def get_n_config_to_keep(self, n_suggestions, bracket_iteration):
"""Return the number of configs to keep and resume."""
n_configs = n_suggestions * (self.eta ** -bracket_iteration)
return int(n_configs / self.eta) | [
"Return",
"the",
"number",
"of",
"configs",
"to",
"keep",
"and",
"resume",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/search_managers/hyperband.py#L83-L86 | [
"def",
"get_n_config_to_keep",
"(",
"self",
",",
"n_suggestions",
",",
"bracket_iteration",
")",
":",
"n_configs",
"=",
"n_suggestions",
"*",
"(",
"self",
".",
"eta",
"**",
"-",
"bracket_iteration",
")",
"return",
"int",
"(",
"n_configs",
"/",
"self",
".",
"... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | HyperbandSearchManager.get_n_config_to_keep_for_iteration | Return the number of configs to keep for an iteration and iteration bracket.
This is just util function around `get_n_config_to_keep` | polyaxon/hpsearch/search_managers/hyperband.py | def get_n_config_to_keep_for_iteration(self, iteration, bracket_iteration):
"""Return the number of configs to keep for an iteration and iteration bracket.
This is just util function around `get_n_config_to_keep`
"""
bracket = self.get_bracket(iteration=iteration)
if bracket_ite... | def get_n_config_to_keep_for_iteration(self, iteration, bracket_iteration):
"""Return the number of configs to keep for an iteration and iteration bracket.
This is just util function around `get_n_config_to_keep`
"""
bracket = self.get_bracket(iteration=iteration)
if bracket_ite... | [
"Return",
"the",
"number",
"of",
"configs",
"to",
"keep",
"for",
"an",
"iteration",
"and",
"iteration",
"bracket",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/search_managers/hyperband.py#L88-L100 | [
"def",
"get_n_config_to_keep_for_iteration",
"(",
"self",
",",
"iteration",
",",
"bracket_iteration",
")",
":",
"bracket",
"=",
"self",
".",
"get_bracket",
"(",
"iteration",
"=",
"iteration",
")",
"if",
"bracket_iteration",
"==",
"bracket",
"+",
"1",
":",
"# End... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | HyperbandSearchManager.get_n_resources_for_iteration | Return the number of iterations to run for this barcket_i
This is just util function around `get_n_resources` | polyaxon/hpsearch/search_managers/hyperband.py | def get_n_resources_for_iteration(self, iteration, bracket_iteration):
"""Return the number of iterations to run for this barcket_i
This is just util function around `get_n_resources`
"""
bracket = self.get_bracket(iteration=iteration)
n_resources = self.get_resources(bracket=br... | def get_n_resources_for_iteration(self, iteration, bracket_iteration):
"""Return the number of iterations to run for this barcket_i
This is just util function around `get_n_resources`
"""
bracket = self.get_bracket(iteration=iteration)
n_resources = self.get_resources(bracket=br... | [
"Return",
"the",
"number",
"of",
"iterations",
"to",
"run",
"for",
"this",
"barcket_i"
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/search_managers/hyperband.py#L106-L113 | [
"def",
"get_n_resources_for_iteration",
"(",
"self",
",",
"iteration",
",",
"bracket_iteration",
")",
":",
"bracket",
"=",
"self",
".",
"get_bracket",
"(",
"iteration",
"=",
"iteration",
")",
"n_resources",
"=",
"self",
".",
"get_resources",
"(",
"bracket",
"=",... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | HyperbandSearchManager.get_suggestions | Return a list of suggestions/arms based on hyperband. | polyaxon/hpsearch/search_managers/hyperband.py | def get_suggestions(self, iteration_config=None):
"""Return a list of suggestions/arms based on hyperband."""
if not iteration_config or not isinstance(iteration_config, HyperbandIterationConfig):
raise ValueError('Hyperband get suggestions requires an iteration.')
bracket = self.get... | def get_suggestions(self, iteration_config=None):
"""Return a list of suggestions/arms based on hyperband."""
if not iteration_config or not isinstance(iteration_config, HyperbandIterationConfig):
raise ValueError('Hyperband get suggestions requires an iteration.')
bracket = self.get... | [
"Return",
"a",
"list",
"of",
"suggestions",
"/",
"arms",
"based",
"on",
"hyperband",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/search_managers/hyperband.py#L115-L131 | [
"def",
"get_suggestions",
"(",
"self",
",",
"iteration_config",
"=",
"None",
")",
":",
"if",
"not",
"iteration_config",
"or",
"not",
"isinstance",
"(",
"iteration_config",
",",
"HyperbandIterationConfig",
")",
":",
"raise",
"ValueError",
"(",
"'Hyperband get suggest... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
train | HyperbandSearchManager.should_reschedule | Return a boolean to indicate if we need to reschedule another iteration. | polyaxon/hpsearch/search_managers/hyperband.py | def should_reschedule(self, iteration, bracket_iteration):
"""Return a boolean to indicate if we need to reschedule another iteration."""
bracket = self.get_bracket(iteration=iteration)
if bracket_iteration < bracket:
# The bracket is still processing
return False
... | def should_reschedule(self, iteration, bracket_iteration):
"""Return a boolean to indicate if we need to reschedule another iteration."""
bracket = self.get_bracket(iteration=iteration)
if bracket_iteration < bracket:
# The bracket is still processing
return False
... | [
"Return",
"a",
"boolean",
"to",
"indicate",
"if",
"we",
"need",
"to",
"reschedule",
"another",
"iteration",
"."
] | polyaxon/polyaxon | python | https://github.com/polyaxon/polyaxon/blob/e1724f0756b1a42f9e7aa08a976584a84ef7f016/polyaxon/hpsearch/search_managers/hyperband.py#L133-L141 | [
"def",
"should_reschedule",
"(",
"self",
",",
"iteration",
",",
"bracket_iteration",
")",
":",
"bracket",
"=",
"self",
".",
"get_bracket",
"(",
"iteration",
"=",
"iteration",
")",
"if",
"bracket_iteration",
"<",
"bracket",
":",
"# The bracket is still processing",
... | e1724f0756b1a42f9e7aa08a976584a84ef7f016 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.