body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def write(self, data):
'Send raw bytes to the instrument.\n\n :param data: bytes to be sent to the instrument\n :type data: bytes\n '
(begin, end, size) = (0, 0, len(data))
bytes_sent = 0
raw_write = super(USBTMC, self).write
while ((end == 0) or (end < size)):
(begin, e... | -2,811,891,068,964,354,000 | Send raw bytes to the instrument.
:param data: bytes to be sent to the instrument
:type data: bytes | pyvisa-py/protocols/usbtmc.py | write | circuitfox/pyvisa-py | python | def write(self, data):
'Send raw bytes to the instrument.\n\n :param data: bytes to be sent to the instrument\n :type data: bytes\n '
(begin, end, size) = (0, 0, len(data))
bytes_sent = 0
raw_write = super(USBTMC, self).write
while ((end == 0) or (end < size)):
(begin, e... |
def testV1ScaleIOVolumeSource(self):
'\n Test V1ScaleIOVolumeSource\n '
pass | 7,621,895,843,589,934,000 | Test V1ScaleIOVolumeSource | kubernetes/test/test_v1_scale_io_volume_source.py | testV1ScaleIOVolumeSource | MiaoRachelYu/python | python | def testV1ScaleIOVolumeSource(self):
'\n \n '
pass |
def create_tenant(self, name: str, slug: str=None) -> str:
'\n Creates a new tenant.\n\n Note this route only works when run against Prefect Server.\n\n Args:\n - name (str): the name of the tenant to create\n - slug (str, optional): the slug of the tenant to create; defau... | 4,363,685,843,409,000,400 | Creates a new tenant.
Note this route only works when run against Prefect Server.
Args:
- name (str): the name of the tenant to create
- slug (str, optional): the slug of the tenant to create; defaults to name
Returns:
- str: the ID of the newly created tenant, or the ID of the currently active tenant
R... | src/prefect/client/client.py | create_tenant | zmac12/prefect | python | def create_tenant(self, name: str, slug: str=None) -> str:
'\n Creates a new tenant.\n\n Note this route only works when run against Prefect Server.\n\n Args:\n - name (str): the name of the tenant to create\n - slug (str, optional): the slug of the tenant to create; defau... |
def get(self, path: str, server: str=None, headers: dict=None, params: Dict[(str, JSONLike)]=None, token: str=None, retry_on_api_error: bool=True) -> dict:
"\n Convenience function for calling the Prefect API with token auth and GET request\n\n Args:\n - path (str): the path of the API url.... | -2,281,131,258,830,956,500 | Convenience function for calling the Prefect API with token auth and GET request
Args:
- path (str): the path of the API url. For example, to GET
http://prefect-server/v1/auth/login, path would be 'auth/login'.
- server (str, optional): the server to send the GET request to;
defaults to `self.a... | src/prefect/client/client.py | get | zmac12/prefect | python | def get(self, path: str, server: str=None, headers: dict=None, params: Dict[(str, JSONLike)]=None, token: str=None, retry_on_api_error: bool=True) -> dict:
"\n Convenience function for calling the Prefect API with token auth and GET request\n\n Args:\n - path (str): the path of the API url.... |
def post(self, path: str, server: str=None, headers: dict=None, params: Dict[(str, JSONLike)]=None, token: str=None, retry_on_api_error: bool=True) -> dict:
"\n Convenience function for calling the Prefect API with token auth and POST request\n\n Args:\n - path (str): the path of the API ur... | -5,386,446,069,364,894,000 | Convenience function for calling the Prefect API with token auth and POST request
Args:
- path (str): the path of the API url. For example, to POST
http://prefect-server/v1/auth/login, path would be 'auth/login'.
- server (str, optional): the server to send the POST request to;
defaults to `sel... | src/prefect/client/client.py | post | zmac12/prefect | python | def post(self, path: str, server: str=None, headers: dict=None, params: Dict[(str, JSONLike)]=None, token: str=None, retry_on_api_error: bool=True) -> dict:
"\n Convenience function for calling the Prefect API with token auth and POST request\n\n Args:\n - path (str): the path of the API ur... |
def graphql(self, query: Any, raise_on_error: bool=True, headers: Dict[(str, str)]=None, variables: Dict[(str, JSONLike)]=None, token: str=None, retry_on_api_error: bool=True) -> GraphQLResult:
'\n Convenience function for running queries against the Prefect GraphQL API\n\n Args:\n - query ... | 6,395,111,916,919,576,000 | Convenience function for running queries against the Prefect GraphQL API
Args:
- query (Any): A representation of a graphql query to be executed. It will be
parsed by prefect.utilities.graphql.parse_graphql().
- raise_on_error (bool): if True, a `ClientError` will be raised if the GraphQL
retur... | src/prefect/client/client.py | graphql | zmac12/prefect | python | def graphql(self, query: Any, raise_on_error: bool=True, headers: Dict[(str, str)]=None, variables: Dict[(str, JSONLike)]=None, token: str=None, retry_on_api_error: bool=True) -> GraphQLResult:
'\n Convenience function for running queries against the Prefect GraphQL API\n\n Args:\n - query ... |
def _request(self, method: str, path: str, params: Dict[(str, JSONLike)]=None, server: str=None, headers: dict=None, token: str=None, retry_on_api_error: bool=True) -> 'requests.models.Response':
'\n Runs any specified request (GET, POST, DELETE) against the server\n\n Args:\n - method (str... | -4,203,393,476,046,338,000 | Runs any specified request (GET, POST, DELETE) against the server
Args:
- method (str): The type of request to be made (GET, POST, DELETE)
- path (str): Path of the API URL
- params (dict, optional): Parameters used for the request
- server (str, optional): The server to make requests against, base API... | src/prefect/client/client.py | _request | zmac12/prefect | python | def _request(self, method: str, path: str, params: Dict[(str, JSONLike)]=None, server: str=None, headers: dict=None, token: str=None, retry_on_api_error: bool=True) -> 'requests.models.Response':
'\n Runs any specified request (GET, POST, DELETE) against the server\n\n Args:\n - method (str... |
def attach_headers(self, headers: dict) -> None:
'\n Set headers to be attached to this Client\n\n Args:\n - headers (dict): A dictionary of headers to attach to this client. These headers\n get added on to the existing dictionary of headers.\n '
self._attached_hea... | -7,213,665,426,098,937,000 | Set headers to be attached to this Client
Args:
- headers (dict): A dictionary of headers to attach to this client. These headers
get added on to the existing dictionary of headers. | src/prefect/client/client.py | attach_headers | zmac12/prefect | python | def attach_headers(self, headers: dict) -> None:
'\n Set headers to be attached to this Client\n\n Args:\n - headers (dict): A dictionary of headers to attach to this client. These headers\n get added on to the existing dictionary of headers.\n '
self._attached_hea... |
@property
def _local_settings_path(self) -> Path:
'\n Returns the local settings directory corresponding to the current API servers\n '
path = '{home}/client/{server}'.format(home=prefect.context.config.home_dir, server=slugify(self.api_server, regex_pattern='[^-\\.a-z0-9]+'))
return (Path(os.... | -4,684,211,161,303,825,000 | Returns the local settings directory corresponding to the current API servers | src/prefect/client/client.py | _local_settings_path | zmac12/prefect | python | @property
def _local_settings_path(self) -> Path:
'\n \n '
path = '{home}/client/{server}'.format(home=prefect.context.config.home_dir, server=slugify(self.api_server, regex_pattern='[^-\\.a-z0-9]+'))
return (Path(os.path.expanduser(path)) / 'settings.toml') |
def _save_local_settings(self, settings: dict) -> None:
'\n Writes settings to local storage\n '
self._local_settings_path.parent.mkdir(exist_ok=True, parents=True)
with self._local_settings_path.open('w+') as f:
toml.dump(settings, f) | 7,160,887,922,359,211,000 | Writes settings to local storage | src/prefect/client/client.py | _save_local_settings | zmac12/prefect | python | def _save_local_settings(self, settings: dict) -> None:
'\n \n '
self._local_settings_path.parent.mkdir(exist_ok=True, parents=True)
with self._local_settings_path.open('w+') as f:
toml.dump(settings, f) |
def _load_local_settings(self) -> dict:
'\n Loads settings from local storage\n '
if self._local_settings_path.exists():
with self._local_settings_path.open('r') as f:
return toml.load(f)
return {} | -4,027,457,190,338,211,000 | Loads settings from local storage | src/prefect/client/client.py | _load_local_settings | zmac12/prefect | python | def _load_local_settings(self) -> dict:
'\n \n '
if self._local_settings_path.exists():
with self._local_settings_path.open('r') as f:
return toml.load(f)
return {} |
def save_api_token(self) -> None:
'\n Saves the API token in local storage.\n '
settings = self._load_local_settings()
settings['api_token'] = self._api_token
self._save_local_settings(settings) | -1,917,627,436,893,828,400 | Saves the API token in local storage. | src/prefect/client/client.py | save_api_token | zmac12/prefect | python | def save_api_token(self) -> None:
'\n \n '
settings = self._load_local_settings()
settings['api_token'] = self._api_token
self._save_local_settings(settings) |
def get_auth_token(self) -> str:
"\n Returns an auth token:\n - if no explicit access token is stored, returns the api token\n - if there is an access token:\n - if there's a refresh token and the access token expires in the next 30 seconds,\n then we ref... | -1,884,620,996,661,254,100 | Returns an auth token:
- if no explicit access token is stored, returns the api token
- if there is an access token:
- if there's a refresh token and the access token expires in the next 30 seconds,
then we refresh the access token and store the result
- return the access token
Return... | src/prefect/client/client.py | get_auth_token | zmac12/prefect | python | def get_auth_token(self) -> str:
"\n Returns an auth token:\n - if no explicit access token is stored, returns the api token\n - if there is an access token:\n - if there's a refresh token and the access token expires in the next 30 seconds,\n then we ref... |
def get_available_tenants(self) -> List[Dict]:
'\n Returns a list of available tenants.\n\n NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n Returns:\n - List[Dict]: a list of dictionaries containing the id, slug, and name of\n avail... | -4,935,558,625,172,033,000 | Returns a list of available tenants.
NOTE: this should only be called by users who have provided a USER-scoped API token.
Returns:
- List[Dict]: a list of dictionaries containing the id, slug, and name of
available tenants | src/prefect/client/client.py | get_available_tenants | zmac12/prefect | python | def get_available_tenants(self) -> List[Dict]:
'\n Returns a list of available tenants.\n\n NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n Returns:\n - List[Dict]: a list of dictionaries containing the id, slug, and name of\n avail... |
def login_to_tenant(self, tenant_slug: str=None, tenant_id: str=None) -> bool:
"\n Log in to a specific tenant\n\n NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n Args:\n - tenant_slug (str): the tenant's slug\n - tenant_id (str): t... | -1,303,885,025,766,660,600 | Log in to a specific tenant
NOTE: this should only be called by users who have provided a USER-scoped API token.
Args:
- tenant_slug (str): the tenant's slug
- tenant_id (str): the tenant's id
Returns:
- bool: True if the login was successful
Raises:
- ValueError: if at least one of `tenant_slug` or... | src/prefect/client/client.py | login_to_tenant | zmac12/prefect | python | def login_to_tenant(self, tenant_slug: str=None, tenant_id: str=None) -> bool:
"\n Log in to a specific tenant\n\n NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n Args:\n - tenant_slug (str): the tenant's slug\n - tenant_id (str): t... |
def _refresh_access_token(self) -> bool:
"\n Refresh the client's JWT access token.\n\n NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n Returns:\n - bool: True if the refresh succeeds\n "
payload = self.graphql({'mutation($input: re... | 674,399,932,671,175,400 | Refresh the client's JWT access token.
NOTE: this should only be called by users who have provided a USER-scoped API token.
Returns:
- bool: True if the refresh succeeds | src/prefect/client/client.py | _refresh_access_token | zmac12/prefect | python | def _refresh_access_token(self) -> bool:
"\n Refresh the client's JWT access token.\n\n NOTE: this should only be called by users who have provided a USER-scoped API token.\n\n Returns:\n - bool: True if the refresh succeeds\n "
payload = self.graphql({'mutation($input: re... |
def register(self, flow: 'Flow', project_name: str=None, build: bool=True, set_schedule_active: bool=True, version_group_id: str=None, compressed: bool=True, no_url: bool=False) -> str:
"\n Push a new flow to Prefect Cloud\n\n Args:\n - flow (Flow): a flow to register\n - project... | -6,778,166,901,766,833,000 | Push a new flow to Prefect Cloud
Args:
- flow (Flow): a flow to register
- project_name (str, optional): the project that should contain this flow.
- build (bool, optional): if `True`, the flow's environment is built
prior to serialization; defaults to `True`
- set_schedule_active (bool, option... | src/prefect/client/client.py | register | zmac12/prefect | python | def register(self, flow: 'Flow', project_name: str=None, build: bool=True, set_schedule_active: bool=True, version_group_id: str=None, compressed: bool=True, no_url: bool=False) -> str:
"\n Push a new flow to Prefect Cloud\n\n Args:\n - flow (Flow): a flow to register\n - project... |
def get_cloud_url(self, subdirectory: str, id: str, as_user: bool=True) -> str:
'\n Convenience method for creating Prefect Cloud URLs for a given subdirectory.\n\n Args:\n - subdirectory (str): the subdirectory to use (e.g., `"flow-run"`)\n - id (str): the ID of the page\n ... | -3,544,279,537,556,646,000 | Convenience method for creating Prefect Cloud URLs for a given subdirectory.
Args:
- subdirectory (str): the subdirectory to use (e.g., `"flow-run"`)
- id (str): the ID of the page
- as_user (bool, optional): whether this query is being made from a USER scoped token;
defaults to `True`. Only used i... | src/prefect/client/client.py | get_cloud_url | zmac12/prefect | python | def get_cloud_url(self, subdirectory: str, id: str, as_user: bool=True) -> str:
'\n Convenience method for creating Prefect Cloud URLs for a given subdirectory.\n\n Args:\n - subdirectory (str): the subdirectory to use (e.g., `"flow-run"`)\n - id (str): the ID of the page\n ... |
def get_default_tenant_slug(self, as_user: bool=True) -> str:
'\n Get the default tenant slug for the currently authenticated user\n\n Args:\n - as_user (bool, optional): whether this query is being made from a USER scoped token;\n defaults to `True`. Only used internally for... | -8,470,113,905,930,942,000 | Get the default tenant slug for the currently authenticated user
Args:
- as_user (bool, optional): whether this query is being made from a USER scoped token;
defaults to `True`. Only used internally for queries made from RUNNERs
Returns:
- str: the slug of the current default tenant for this user | src/prefect/client/client.py | get_default_tenant_slug | zmac12/prefect | python | def get_default_tenant_slug(self, as_user: bool=True) -> str:
'\n Get the default tenant slug for the currently authenticated user\n\n Args:\n - as_user (bool, optional): whether this query is being made from a USER scoped token;\n defaults to `True`. Only used internally for... |
def create_project(self, project_name: str, project_description: str=None) -> str:
'\n Create a new Project\n\n Args:\n - project_name (str): the project that should contain this flow\n - project_description (str, optional): the project description\n\n Returns:\n ... | 8,238,271,992,302,800,000 | Create a new Project
Args:
- project_name (str): the project that should contain this flow
- project_description (str, optional): the project description
Returns:
- str: the ID of the newly-created project
Raises:
- ClientError: if the project creation failed | src/prefect/client/client.py | create_project | zmac12/prefect | python | def create_project(self, project_name: str, project_description: str=None) -> str:
'\n Create a new Project\n\n Args:\n - project_name (str): the project that should contain this flow\n - project_description (str, optional): the project description\n\n Returns:\n ... |
def create_flow_run(self, flow_id: str=None, context: dict=None, parameters: dict=None, scheduled_start_time: datetime.datetime=None, idempotency_key: str=None, run_name: str=None, version_group_id: str=None) -> str:
"\n Create a new flow run for the given flow id. If `start_time` is not provided, the flow\... | 2,886,062,023,428,716,000 | Create a new flow run for the given flow id. If `start_time` is not provided, the flow
run will be scheduled to start immediately. If both `flow_id` and `version_group_id`
are provided, only the `flow_id` will be used.
Args:
- flow_id (str, optional): the id of the Flow you wish to schedule
- context (dict, ... | src/prefect/client/client.py | create_flow_run | zmac12/prefect | python | def create_flow_run(self, flow_id: str=None, context: dict=None, parameters: dict=None, scheduled_start_time: datetime.datetime=None, idempotency_key: str=None, run_name: str=None, version_group_id: str=None) -> str:
"\n Create a new flow run for the given flow id. If `start_time` is not provided, the flow\... |
def get_flow_run_info(self, flow_run_id: str) -> FlowRunInfoResult:
'\n Retrieves version and current state information for the given flow run.\n\n Args:\n - flow_run_id (str): the id of the flow run to get information for\n\n Returns:\n - GraphQLResult: an object represen... | -7,162,629,357,981,999,000 | Retrieves version and current state information for the given flow run.
Args:
- flow_run_id (str): the id of the flow run to get information for
Returns:
- GraphQLResult: an object representing information about the flow run
Raises:
- ClientError: if the GraphQL mutation is bad for any reason | src/prefect/client/client.py | get_flow_run_info | zmac12/prefect | python | def get_flow_run_info(self, flow_run_id: str) -> FlowRunInfoResult:
'\n Retrieves version and current state information for the given flow run.\n\n Args:\n - flow_run_id (str): the id of the flow run to get information for\n\n Returns:\n - GraphQLResult: an object represen... |
def update_flow_run_heartbeat(self, flow_run_id: str) -> None:
'\n Convenience method for heartbeating a flow run.\n\n Does NOT raise an error if the update fails.\n\n Args:\n - flow_run_id (str): the flow run ID to heartbeat\n\n '
mutation = {'mutation': {with_args('updat... | 6,089,364,651,048,748,000 | Convenience method for heartbeating a flow run.
Does NOT raise an error if the update fails.
Args:
- flow_run_id (str): the flow run ID to heartbeat | src/prefect/client/client.py | update_flow_run_heartbeat | zmac12/prefect | python | def update_flow_run_heartbeat(self, flow_run_id: str) -> None:
'\n Convenience method for heartbeating a flow run.\n\n Does NOT raise an error if the update fails.\n\n Args:\n - flow_run_id (str): the flow run ID to heartbeat\n\n '
mutation = {'mutation': {with_args('updat... |
def update_task_run_heartbeat(self, task_run_id: str) -> None:
'\n Convenience method for heartbeating a task run.\n\n Does NOT raise an error if the update fails.\n\n Args:\n - task_run_id (str): the task run ID to heartbeat\n\n '
mutation = {'mutation': {with_args('updat... | 7,843,818,405,197,987,000 | Convenience method for heartbeating a task run.
Does NOT raise an error if the update fails.
Args:
- task_run_id (str): the task run ID to heartbeat | src/prefect/client/client.py | update_task_run_heartbeat | zmac12/prefect | python | def update_task_run_heartbeat(self, task_run_id: str) -> None:
'\n Convenience method for heartbeating a task run.\n\n Does NOT raise an error if the update fails.\n\n Args:\n - task_run_id (str): the task run ID to heartbeat\n\n '
mutation = {'mutation': {with_args('updat... |
def get_flow_run_state(self, flow_run_id: str) -> 'prefect.engine.state.State':
'\n Retrieves the current state for a flow run.\n\n Args:\n - flow_run_id (str): the id for this flow run\n\n Returns:\n - State: a Prefect State object\n '
query = {'query': {with_a... | -7,446,695,253,653,859,000 | Retrieves the current state for a flow run.
Args:
- flow_run_id (str): the id for this flow run
Returns:
- State: a Prefect State object | src/prefect/client/client.py | get_flow_run_state | zmac12/prefect | python | def get_flow_run_state(self, flow_run_id: str) -> 'prefect.engine.state.State':
'\n Retrieves the current state for a flow run.\n\n Args:\n - flow_run_id (str): the id for this flow run\n\n Returns:\n - State: a Prefect State object\n '
query = {'query': {with_a... |
def set_flow_run_state(self, flow_run_id: str, state: 'prefect.engine.state.State', version: int=None) -> 'prefect.engine.state.State':
'\n Sets new state for a flow run in the database.\n\n Args:\n - flow_run_id (str): the id of the flow run to set state for\n - state (State): t... | -6,250,182,351,231,868,000 | Sets new state for a flow run in the database.
Args:
- flow_run_id (str): the id of the flow run to set state for
- state (State): the new state for this flow run
- version (int, optional): the current version of the flow run state. This is optional
but it can be supplied to enforce version-locking... | src/prefect/client/client.py | set_flow_run_state | zmac12/prefect | python | def set_flow_run_state(self, flow_run_id: str, state: 'prefect.engine.state.State', version: int=None) -> 'prefect.engine.state.State':
'\n Sets new state for a flow run in the database.\n\n Args:\n - flow_run_id (str): the id of the flow run to set state for\n - state (State): t... |
def get_latest_cached_states(self, task_id: str, cache_key: Optional[str], created_after: datetime.datetime) -> List['prefect.engine.state.State']:
"\n Pulls all Cached states for the given task that were created after the provided date.\n\n Args:\n - task_id (str): the task id for this tas... | -683,146,956,107,417,100 | Pulls all Cached states for the given task that were created after the provided date.
Args:
- task_id (str): the task id for this task run
- cache_key (Optional[str]): the cache key for this Task's cache; if `None`, the
task id alone will be used
- created_after (datetime.datetime): the earliest da... | src/prefect/client/client.py | get_latest_cached_states | zmac12/prefect | python | def get_latest_cached_states(self, task_id: str, cache_key: Optional[str], created_after: datetime.datetime) -> List['prefect.engine.state.State']:
"\n Pulls all Cached states for the given task that were created after the provided date.\n\n Args:\n - task_id (str): the task id for this tas... |
def get_task_run_info(self, flow_run_id: str, task_id: str, map_index: Optional[int]=None) -> TaskRunInfoResult:
'\n Retrieves version and current state information for the given task run.\n\n Args:\n - flow_run_id (str): the id of the flow run that this task run lives in\n - tas... | 5,572,389,203,775,407,000 | Retrieves version and current state information for the given task run.
Args:
- flow_run_id (str): the id of the flow run that this task run lives in
- task_id (str): the task id for this task run
- map_index (int, optional): the mapping index for this task run; if
`None`, it is assumed this task i... | src/prefect/client/client.py | get_task_run_info | zmac12/prefect | python | def get_task_run_info(self, flow_run_id: str, task_id: str, map_index: Optional[int]=None) -> TaskRunInfoResult:
'\n Retrieves version and current state information for the given task run.\n\n Args:\n - flow_run_id (str): the id of the flow run that this task run lives in\n - tas... |
def set_task_run_name(self, task_run_id: str, name: str) -> bool:
'\n Set the name of a task run\n\n Args:\n - task_run_id (str): the id of a task run\n - name (str): a name for this task run\n\n Returns:\n - bool: whether or not the task run name was updated\n ... | -5,408,736,090,355,613,000 | Set the name of a task run
Args:
- task_run_id (str): the id of a task run
- name (str): a name for this task run
Returns:
- bool: whether or not the task run name was updated | src/prefect/client/client.py | set_task_run_name | zmac12/prefect | python | def set_task_run_name(self, task_run_id: str, name: str) -> bool:
'\n Set the name of a task run\n\n Args:\n - task_run_id (str): the id of a task run\n - name (str): a name for this task run\n\n Returns:\n - bool: whether or not the task run name was updated\n ... |
def get_task_run_state(self, task_run_id: str) -> 'prefect.engine.state.State':
'\n Retrieves the current state for a task run.\n\n Args:\n - task_run_id (str): the id for this task run\n\n Returns:\n - State: a Prefect State object\n '
query = {'query': {with_a... | -7,783,051,125,377,341,000 | Retrieves the current state for a task run.
Args:
- task_run_id (str): the id for this task run
Returns:
- State: a Prefect State object | src/prefect/client/client.py | get_task_run_state | zmac12/prefect | python | def get_task_run_state(self, task_run_id: str) -> 'prefect.engine.state.State':
'\n Retrieves the current state for a task run.\n\n Args:\n - task_run_id (str): the id for this task run\n\n Returns:\n - State: a Prefect State object\n '
query = {'query': {with_a... |
def set_task_run_state(self, task_run_id: str, state: 'prefect.engine.state.State', version: int=None, cache_for: datetime.timedelta=None) -> 'prefect.engine.state.State':
'\n Sets new state for a task run.\n\n Args:\n - task_run_id (str): the id of the task run to set state for\n ... | 7,802,373,459,408,090,000 | Sets new state for a task run.
Args:
- task_run_id (str): the id of the task run to set state for
- state (State): the new state for this task run
- version (int, optional): the current version of the task run state. This is optional
but it can be supplied to enforce version-locking.
- cache_fo... | src/prefect/client/client.py | set_task_run_state | zmac12/prefect | python | def set_task_run_state(self, task_run_id: str, state: 'prefect.engine.state.State', version: int=None, cache_for: datetime.timedelta=None) -> 'prefect.engine.state.State':
'\n Sets new state for a task run.\n\n Args:\n - task_run_id (str): the id of the task run to set state for\n ... |
def set_secret(self, name: str, value: Any) -> None:
'\n Set a secret with the given name and value.\n\n Args:\n - name (str): the name of the secret; used for retrieving the secret\n during task runs\n - value (Any): the value of the secret\n\n Raises:\n ... | -493,880,310,508,623,550 | Set a secret with the given name and value.
Args:
- name (str): the name of the secret; used for retrieving the secret
during task runs
- value (Any): the value of the secret
Raises:
- ClientError: if the GraphQL mutation is bad for any reason
- ValueError: if the secret-setting was unsuccessf... | src/prefect/client/client.py | set_secret | zmac12/prefect | python | def set_secret(self, name: str, value: Any) -> None:
'\n Set a secret with the given name and value.\n\n Args:\n - name (str): the name of the secret; used for retrieving the secret\n during task runs\n - value (Any): the value of the secret\n\n Raises:\n ... |
def get_task_tag_limit(self, tag: str) -> Optional[int]:
'\n Retrieve the current task tag concurrency limit for a given tag.\n\n Args:\n - tag (str): the tag to update\n\n Raises:\n - ClientError: if the GraphQL query fails\n '
query = {'query': {with_args('tas... | -1,634,685,958,949,177,300 | Retrieve the current task tag concurrency limit for a given tag.
Args:
- tag (str): the tag to update
Raises:
- ClientError: if the GraphQL query fails | src/prefect/client/client.py | get_task_tag_limit | zmac12/prefect | python | def get_task_tag_limit(self, tag: str) -> Optional[int]:
'\n Retrieve the current task tag concurrency limit for a given tag.\n\n Args:\n - tag (str): the tag to update\n\n Raises:\n - ClientError: if the GraphQL query fails\n '
query = {'query': {with_args('tas... |
def update_task_tag_limit(self, tag: str, limit: int) -> None:
'\n Update the task tag concurrency limit for a given tag; requires tenant admin permissions.\n\n Args:\n - tag (str): the tag to update\n - limit (int): the concurrency limit to enforce on the tag; should be a value ... | 5,336,804,441,202,090,000 | Update the task tag concurrency limit for a given tag; requires tenant admin permissions.
Args:
- tag (str): the tag to update
- limit (int): the concurrency limit to enforce on the tag; should be a value >= 0
Raises:
- ClientError: if the GraphQL mutation is bad for any reason
- ValueError: if the ta... | src/prefect/client/client.py | update_task_tag_limit | zmac12/prefect | python | def update_task_tag_limit(self, tag: str, limit: int) -> None:
'\n Update the task tag concurrency limit for a given tag; requires tenant admin permissions.\n\n Args:\n - tag (str): the tag to update\n - limit (int): the concurrency limit to enforce on the tag; should be a value ... |
def delete_task_tag_limit(self, limit_id: str) -> None:
'\n Deletes a given task tag concurrency limit; requires tenant admin permissions.\n\n Args:\n - limit_id (str): the ID of the tag to delete\n\n Raises:\n - ClientError: if the GraphQL mutation is bad for any reason\n... | -925,700,551,522,546,800 | Deletes a given task tag concurrency limit; requires tenant admin permissions.
Args:
- limit_id (str): the ID of the tag to delete
Raises:
- ClientError: if the GraphQL mutation is bad for any reason
- ValueError: if the tag deletion was unsuccessful, or if a bad tag ID was provided | src/prefect/client/client.py | delete_task_tag_limit | zmac12/prefect | python | def delete_task_tag_limit(self, limit_id: str) -> None:
'\n Deletes a given task tag concurrency limit; requires tenant admin permissions.\n\n Args:\n - limit_id (str): the ID of the tag to delete\n\n Raises:\n - ClientError: if the GraphQL mutation is bad for any reason\n... |
def write_run_logs(self, logs: List[Dict]) -> None:
'\n Uploads a collection of logs to Cloud.\n\n Args:\n - logs (List[Dict]): a list of log entries to add\n\n Raises:\n - ValueError: if uploading the logs fail\n '
mutation = {'mutation($input: write_run_logs_i... | 5,444,238,842,283,366,000 | Uploads a collection of logs to Cloud.
Args:
- logs (List[Dict]): a list of log entries to add
Raises:
- ValueError: if uploading the logs fail | src/prefect/client/client.py | write_run_logs | zmac12/prefect | python | def write_run_logs(self, logs: List[Dict]) -> None:
'\n Uploads a collection of logs to Cloud.\n\n Args:\n - logs (List[Dict]): a list of log entries to add\n\n Raises:\n - ValueError: if uploading the logs fail\n '
mutation = {'mutation($input: write_run_logs_i... |
def register_agent(self, agent_type: str, name: str=None, labels: List[str]=None, agent_config_id: str=None) -> str:
'\n Register an agent with a backend API\n\n Args:\n - agent_type (str): The type of agent being registered\n - name: (str, optional): The name of the agent being ... | -199,111,105,601,504,480 | Register an agent with a backend API
Args:
- agent_type (str): The type of agent being registered
- name: (str, optional): The name of the agent being registered
- labels (List[str], optional): A list of any present labels on the agent
being registered
- agent_config_id (str, optional): The ID ... | src/prefect/client/client.py | register_agent | zmac12/prefect | python | def register_agent(self, agent_type: str, name: str=None, labels: List[str]=None, agent_config_id: str=None) -> str:
'\n Register an agent with a backend API\n\n Args:\n - agent_type (str): The type of agent being registered\n - name: (str, optional): The name of the agent being ... |
def get_agent_config(self, agent_config_id: str) -> dict:
"\n Get agent config settings\n\n Args:\n - agent_config_id (str): The ID of an agent configuration to retrieve\n\n Returns:\n - dict: the agent configuration's `settings`\n "
query = {'query': {with_args... | 209,077,097,488,946,200 | Get agent config settings
Args:
- agent_config_id (str): The ID of an agent configuration to retrieve
Returns:
- dict: the agent configuration's `settings` | src/prefect/client/client.py | get_agent_config | zmac12/prefect | python | def get_agent_config(self, agent_config_id: str) -> dict:
"\n Get agent config settings\n\n Args:\n - agent_config_id (str): The ID of an agent configuration to retrieve\n\n Returns:\n - dict: the agent configuration's `settings`\n "
query = {'query': {with_args... |
def initialize(self, tank_capacity, inputs, outputs, water_level):
'\n Initializes the simulation with the specified data.\n @param tank_capacity Capacity of the water tank, in liters.\n @param Array containing the flow volume of the inputs (such as water pumps), in liters per second. \n ... | 5,134,381,525,889,772,000 | Initializes the simulation with the specified data.
@param tank_capacity Capacity of the water tank, in liters.
@param Array containing the flow volume of the inputs (such as water pumps), in liters per second.
The flow can be modified dynamically, but no inputs can be added.
@param Array containing the outputs (such... | server/src/experiments/ud_xilinx/watertank_simulation.py | initialize | LR-FGMM/weblabdeusto | python | def initialize(self, tank_capacity, inputs, outputs, water_level):
'\n Initializes the simulation with the specified data.\n @param tank_capacity Capacity of the water tank, in liters.\n @param Array containing the flow volume of the inputs (such as water pumps), in liters per second. \n ... |
def update(self, delta):
'\n Updates the simulation. Can be done automatically if the autoupdater is used.\n @param delta Delta in seconds.\n @see autoupdater_start\n '
total_output = 0
for out in self.outputs:
total_output += (out * delta)
total_input = 0
(pump1,... | 7,955,144,620,373,460,000 | Updates the simulation. Can be done automatically if the autoupdater is used.
@param delta Delta in seconds.
@see autoupdater_start | server/src/experiments/ud_xilinx/watertank_simulation.py | update | LR-FGMM/weblabdeusto | python | def update(self, delta):
'\n Updates the simulation. Can be done automatically if the autoupdater is used.\n @param delta Delta in seconds.\n @see autoupdater_start\n '
total_output = 0
for out in self.outputs:
total_output += (out * delta)
total_input = 0
(pump1,... |
def t_updater(self):
'\n This internal method is used by the autoupdating thread to update\n the simulation every few seconds (specified as the autoupdater interval).\n '
while self._autoupdating:
time.sleep(self._autoupdating_interval)
self.update(self._autoupdating_interva... | -6,640,372,441,248,582,000 | This internal method is used by the autoupdating thread to update
the simulation every few seconds (specified as the autoupdater interval). | server/src/experiments/ud_xilinx/watertank_simulation.py | t_updater | LR-FGMM/weblabdeusto | python | def t_updater(self):
'\n This internal method is used by the autoupdating thread to update\n the simulation every few seconds (specified as the autoupdater interval).\n '
while self._autoupdating:
time.sleep(self._autoupdating_interval)
self.update(self._autoupdating_interva... |
def autoupdater_start(self, interval):
'\n Starts the autoupdating thread. That is, a thread that will call update\n every so often. If started, it should eventually be stopped. Otherwise,\n it will run forever in the background.\n @param interval Interval between updates, in seconds.\n ... | -5,620,668,677,739,745,000 | Starts the autoupdating thread. That is, a thread that will call update
every so often. If started, it should eventually be stopped. Otherwise,
it will run forever in the background.
@param interval Interval between updates, in seconds.
@see autoupdater_stop | server/src/experiments/ud_xilinx/watertank_simulation.py | autoupdater_start | LR-FGMM/weblabdeusto | python | def autoupdater_start(self, interval):
'\n Starts the autoupdating thread. That is, a thread that will call update\n every so often. If started, it should eventually be stopped. Otherwise,\n it will run forever in the background.\n @param interval Interval between updates, in seconds.\n ... |
def autoupdater_stop(self):
'\n Stops the autoupdating thread. This method is non-blocking. It will signal\n the thread to stop, but may take a while before it *really* does stop.\n There is a blocking version of this method.\n @see autoupdater_join\n '
self._autoupdating = Fa... | -3,828,925,256,979,739,000 | Stops the autoupdating thread. This method is non-blocking. It will signal
the thread to stop, but may take a while before it *really* does stop.
There is a blocking version of this method.
@see autoupdater_join | server/src/experiments/ud_xilinx/watertank_simulation.py | autoupdater_stop | LR-FGMM/weblabdeusto | python | def autoupdater_stop(self):
'\n Stops the autoupdating thread. This method is non-blocking. It will signal\n the thread to stop, but may take a while before it *really* does stop.\n There is a blocking version of this method.\n @see autoupdater_join\n '
self._autoupdating = Fa... |
def autoupdater_join(self):
"\n Stops the autoupdating thread, and joins that thread until it really does stop.\n May block forever if for some reason the thread won't stop, but that\n should not happen.\n "
self._autoupdating = False
self._thread.join(0) | -1,852,508,963,353,255,200 | Stops the autoupdating thread, and joins that thread until it really does stop.
May block forever if for some reason the thread won't stop, but that
should not happen. | server/src/experiments/ud_xilinx/watertank_simulation.py | autoupdater_join | LR-FGMM/weblabdeusto | python | def autoupdater_join(self):
"\n Stops the autoupdating thread, and joins that thread until it really does stop.\n May block forever if for some reason the thread won't stop, but that\n should not happen.\n "
self._autoupdating = False
self._thread.join(0) |
def set_input(self, input_number, input_flow):
'\n Sets the value for an input in the simulation. \n @param input_number Number identifying the input. The input should exist.\n @param input_flow New flow of the input, in liters per second.\n '
with self.simlock:
self.inputs[i... | -6,037,607,105,013,283,000 | Sets the value for an input in the simulation.
@param input_number Number identifying the input. The input should exist.
@param input_flow New flow of the input, in liters per second. | server/src/experiments/ud_xilinx/watertank_simulation.py | set_input | LR-FGMM/weblabdeusto | python | def set_input(self, input_number, input_flow):
'\n Sets the value for an input in the simulation. \n @param input_number Number identifying the input. The input should exist.\n @param input_flow New flow of the input, in liters per second.\n '
with self.simlock:
self.inputs[i... |
def set_output(self, output_number, output_flow):
'\n Sets the value for an output in the simulation.\n @param output_number Number identifying the output. The output should exist.\n @param output_flow New flow of the output, in liters per second.\n '
with self.simlock:
self.... | 8,023,729,128,761,339,000 | Sets the value for an output in the simulation.
@param output_number Number identifying the output. The output should exist.
@param output_flow New flow of the output, in liters per second. | server/src/experiments/ud_xilinx/watertank_simulation.py | set_output | LR-FGMM/weblabdeusto | python | def set_output(self, output_number, output_flow):
'\n Sets the value for an output in the simulation.\n @param output_number Number identifying the output. The output should exist.\n @param output_flow New flow of the output, in liters per second.\n '
with self.simlock:
self.... |
def set_inputs(self, inputs):
'\n Redefines the whole array of inputs.\n @param inputs Array containing the flow of every input.\n '
with self.simlock:
self.inputs = inputs | -5,571,642,313,052,897,000 | Redefines the whole array of inputs.
@param inputs Array containing the flow of every input. | server/src/experiments/ud_xilinx/watertank_simulation.py | set_inputs | LR-FGMM/weblabdeusto | python | def set_inputs(self, inputs):
'\n Redefines the whole array of inputs.\n @param inputs Array containing the flow of every input.\n '
with self.simlock:
self.inputs = inputs |
def set_outputs(self, outputs):
'\n Redefines the whole array of outputs.\n @param outputs Array containing the flow of every output.\n '
with self.simlock:
self.outputs = outputs | -8,458,866,352,859,930,000 | Redefines the whole array of outputs.
@param outputs Array containing the flow of every output. | server/src/experiments/ud_xilinx/watertank_simulation.py | set_outputs | LR-FGMM/weblabdeusto | python | def set_outputs(self, outputs):
'\n Redefines the whole array of outputs.\n @param outputs Array containing the flow of every output.\n '
with self.simlock:
self.outputs = outputs |
def get_temperatures(self):
'\n Get temperatures.\n :return:\n '
return [self.firstPumpTemperature, self.secondPumpTemperature] | -5,976,381,320,454,369,000 | Get temperatures.
:return: | server/src/experiments/ud_xilinx/watertank_simulation.py | get_temperatures | LR-FGMM/weblabdeusto | python | def get_temperatures(self):
'\n Get temperatures.\n :return:\n '
return [self.firstPumpTemperature, self.secondPumpTemperature] |
def get_water_volume(self):
"\n Gets the current water volume in liters. It will vary dynamically according to the \n simulation's state.\n "
with self.simlock:
return self.current_volume | -3,104,628,016,230,668,300 | Gets the current water volume in liters. It will vary dynamically according to the
simulation's state. | server/src/experiments/ud_xilinx/watertank_simulation.py | get_water_volume | LR-FGMM/weblabdeusto | python | def get_water_volume(self):
"\n Gets the current water volume in liters. It will vary dynamically according to the \n simulation's state.\n "
with self.simlock:
return self.current_volume |
def get_water_level(self):
"\n Gets the current water level, as a number from 0 to 1 (empty to full). It will vary dynamically\n according to the simulation's state.\n "
with self.simlock:
return ((1.0 * self.current_volume) / self.tank_capacity) | 964,212,182,402,237,200 | Gets the current water level, as a number from 0 to 1 (empty to full). It will vary dynamically
according to the simulation's state. | server/src/experiments/ud_xilinx/watertank_simulation.py | get_water_level | LR-FGMM/weblabdeusto | python | def get_water_level(self):
"\n Gets the current water level, as a number from 0 to 1 (empty to full). It will vary dynamically\n according to the simulation's state.\n "
with self.simlock:
return ((1.0 * self.current_volume) / self.tank_capacity) |
def get_json_state(self, input_capacities, output_capacities):
"\n Gets a json-encoded description of the simulation's state. \n As of now, it takes output and input capacities as arguments because the JSON state\n is described through relative values. (For instance, first output at 0.3 capacit... | -4,236,027,061,501,498,000 | Gets a json-encoded description of the simulation's state.
As of now, it takes output and input capacities as arguments because the JSON state
is described through relative values. (For instance, first output at 0.3 capacity).
@param input_capacities An array containing the maximum capacities of the input.
@param out... | server/src/experiments/ud_xilinx/watertank_simulation.py | get_json_state | LR-FGMM/weblabdeusto | python | def get_json_state(self, input_capacities, output_capacities):
"\n Gets a json-encoded description of the simulation's state. \n As of now, it takes output and input capacities as arguments because the JSON state\n is described through relative values. (For instance, first output at 0.3 capacit... |
def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -> None:
'Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public\n streams, so you have something to look at in your home view once\n you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES\n are marked... | 4,170,579,497,540,251,000 | Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public
streams, so you have something to look at in your home view once
you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES
are marked unread. | zerver/lib/actions.py | add_new_user_history | gutalavijay1111/zulip-vijay | python | def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -> None:
'Give you the last ONBOARDING_TOTAL_MESSAGES messages on your public\n streams, so you have something to look at in your home view once\n you finish the tutorial. The most recent ONBOARDING_UNREAD_MESSAGES\n are marked... |
def do_set_realm_property(realm: Realm, name: str, value: Any, acting_user: Optional[UserProfile]=None) -> None:
'Takes in a realm object, the name of an attribute to update, the\n value to update and and the user who initiated the update.\n '
property_type = Realm.property_types[name]
assert isins... | 7,533,641,336,225,873,000 | Takes in a realm object, the name of an attribute to update, the
value to update and and the user who initiated the update. | zerver/lib/actions.py | do_set_realm_property | gutalavijay1111/zulip-vijay | python | def do_set_realm_property(realm: Realm, name: str, value: Any, acting_user: Optional[UserProfile]=None) -> None:
'Takes in a realm object, the name of an attribute to update, the\n value to update and and the user who initiated the update.\n '
property_type = Realm.property_types[name]
assert isins... |
def do_deactivate_realm(realm: Realm, acting_user: Optional[UserProfile]=None) -> None:
"\n Deactivate this realm. Do NOT deactivate the users -- we need to be able to\n tell the difference between users that were intentionally deactivated,\n e.g. by a realm admin, and users who can't currently use Zulip b... | -3,333,272,059,511,270,000 | Deactivate this realm. Do NOT deactivate the users -- we need to be able to
tell the difference between users that were intentionally deactivated,
e.g. by a realm admin, and users who can't currently use Zulip because their
realm has been deactivated. | zerver/lib/actions.py | do_deactivate_realm | gutalavijay1111/zulip-vijay | python | def do_deactivate_realm(realm: Realm, acting_user: Optional[UserProfile]=None) -> None:
"\n Deactivate this realm. Do NOT deactivate the users -- we need to be able to\n tell the difference between users that were intentionally deactivated,\n e.g. by a realm admin, and users who can't currently use Zulip b... |
def do_send_messages(messages_maybe_none: Sequence[Optional[MutableMapping[(str, Any)]]], email_gateway: bool=False, mark_as_read: Sequence[int]=[]) -> List[int]:
'See\n https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html\n for high-level documentation on this subsystem.\n '
message... | 1,167,765,137,967,222,500 | See
https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
for high-level documentation on this subsystem. | zerver/lib/actions.py | do_send_messages | gutalavijay1111/zulip-vijay | python | def do_send_messages(messages_maybe_none: Sequence[Optional[MutableMapping[(str, Any)]]], email_gateway: bool=False, mark_as_read: Sequence[int]=[]) -> List[int]:
'See\n https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html\n for high-level documentation on this subsystem.\n '
message... |
def bulk_insert_ums(ums: List[UserMessageLite]) -> None:
"\n Doing bulk inserts this way is much faster than using Django,\n since we don't have any ORM overhead. Profiling with 1000\n users shows a speedup of 0.436 -> 0.027 seconds, so we're\n talking about a 15x speedup.\n "
if (not ums):
... | -8,615,920,368,105,321,000 | Doing bulk inserts this way is much faster than using Django,
since we don't have any ORM overhead. Profiling with 1000
users shows a speedup of 0.436 -> 0.027 seconds, so we're
talking about a 15x speedup. | zerver/lib/actions.py | bulk_insert_ums | gutalavijay1111/zulip-vijay | python | def bulk_insert_ums(ums: List[UserMessageLite]) -> None:
"\n Doing bulk inserts this way is much faster than using Django,\n since we don't have any ORM overhead. Profiling with 1000\n users shows a speedup of 0.436 -> 0.027 seconds, so we're\n talking about a 15x speedup.\n "
if (not ums):
... |
def send_rate_limited_pm_notification_to_bot_owner(sender: UserProfile, realm: Realm, content: str) -> None:
"\n Sends a PM error notification to a bot's owner if one hasn't already\n been sent in the last 5 minutes.\n "
if (sender.realm.is_zephyr_mirror_realm or sender.realm.deactivated):
retu... | -3,291,042,250,313,544,000 | Sends a PM error notification to a bot's owner if one hasn't already
been sent in the last 5 minutes. | zerver/lib/actions.py | send_rate_limited_pm_notification_to_bot_owner | gutalavijay1111/zulip-vijay | python | def send_rate_limited_pm_notification_to_bot_owner(sender: UserProfile, realm: Realm, content: str) -> None:
"\n Sends a PM error notification to a bot's owner if one hasn't already\n been sent in the last 5 minutes.\n "
if (sender.realm.is_zephyr_mirror_realm or sender.realm.deactivated):
retu... |
def send_pm_if_empty_stream(stream: Optional[Stream], realm: Realm, sender: UserProfile, stream_name: Optional[str]=None, stream_id: Optional[int]=None) -> None:
"If a bot sends a message to a stream that doesn't exist or has no\n subscribers, sends a notification to the bot owner (if not a\n cross-realm bot)... | -8,537,584,179,513,448,000 | If a bot sends a message to a stream that doesn't exist or has no
subscribers, sends a notification to the bot owner (if not a
cross-realm bot) so that the owner can correct the issue. | zerver/lib/actions.py | send_pm_if_empty_stream | gutalavijay1111/zulip-vijay | python | def send_pm_if_empty_stream(stream: Optional[Stream], realm: Realm, sender: UserProfile, stream_name: Optional[str]=None, stream_id: Optional[int]=None) -> None:
"If a bot sends a message to a stream that doesn't exist or has no\n subscribers, sends a notification to the bot owner (if not a\n cross-realm bot)... |
def check_message(sender: UserProfile, client: Client, addressee: Addressee, message_content_raw: str, realm: Optional[Realm]=None, forged: bool=False, forged_timestamp: Optional[float]=None, forwarder_user_profile: Optional[UserProfile]=None, local_id: Optional[str]=None, sender_queue_id: Optional[str]=None, widget_co... | -1,645,878,623,583,306,000 | See
https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html
for high-level documentation on this subsystem. | zerver/lib/actions.py | check_message | gutalavijay1111/zulip-vijay | python | def check_message(sender: UserProfile, client: Client, addressee: Addressee, message_content_raw: str, realm: Optional[Realm]=None, forged: bool=False, forged_timestamp: Optional[float]=None, forwarder_user_profile: Optional[UserProfile]=None, local_id: Optional[str]=None, sender_queue_id: Optional[str]=None, widget_co... |
def _internal_prep_message(realm: Realm, sender: UserProfile, addressee: Addressee, content: str) -> Optional[Dict[(str, Any)]]:
"\n Create a message object and checks it, but doesn't send it or save it to the database.\n The internal function that calls this can therefore batch send a bunch of created\n m... | -3,711,186,963,448,017,400 | Create a message object and checks it, but doesn't send it or save it to the database.
The internal function that calls this can therefore batch send a bunch of created
messages together as one database query.
Call do_send_messages with a list of the return values of this method. | zerver/lib/actions.py | _internal_prep_message | gutalavijay1111/zulip-vijay | python | def _internal_prep_message(realm: Realm, sender: UserProfile, addressee: Addressee, content: str) -> Optional[Dict[(str, Any)]]:
"\n Create a message object and checks it, but doesn't send it or save it to the database.\n The internal function that calls this can therefore batch send a bunch of created\n m... |
def internal_prep_stream_message(realm: Realm, sender: UserProfile, stream: Stream, topic: str, content: str) -> Optional[Dict[(str, Any)]]:
'\n See _internal_prep_message for details of how this works.\n '
addressee = Addressee.for_stream(stream, topic)
return _internal_prep_message(realm=realm, send... | -3,348,404,627,655,703,000 | See _internal_prep_message for details of how this works. | zerver/lib/actions.py | internal_prep_stream_message | gutalavijay1111/zulip-vijay | python | def internal_prep_stream_message(realm: Realm, sender: UserProfile, stream: Stream, topic: str, content: str) -> Optional[Dict[(str, Any)]]:
'\n \n '
addressee = Addressee.for_stream(stream, topic)
return _internal_prep_message(realm=realm, sender=sender, addressee=addressee, content=content) |
def internal_prep_stream_message_by_name(realm: Realm, sender: UserProfile, stream_name: str, topic: str, content: str) -> Optional[Dict[(str, Any)]]:
'\n See _internal_prep_message for details of how this works.\n '
addressee = Addressee.for_stream_name(stream_name, topic)
return _internal_prep_messa... | 1,024,521,372,594,651,600 | See _internal_prep_message for details of how this works. | zerver/lib/actions.py | internal_prep_stream_message_by_name | gutalavijay1111/zulip-vijay | python | def internal_prep_stream_message_by_name(realm: Realm, sender: UserProfile, stream_name: str, topic: str, content: str) -> Optional[Dict[(str, Any)]]:
'\n \n '
addressee = Addressee.for_stream_name(stream_name, topic)
return _internal_prep_message(realm=realm, sender=sender, addressee=addressee, conte... |
def internal_prep_private_message(realm: Realm, sender: UserProfile, recipient_user: UserProfile, content: str) -> Optional[Dict[(str, Any)]]:
'\n See _internal_prep_message for details of how this works.\n '
addressee = Addressee.for_user_profile(recipient_user)
return _internal_prep_message(realm=re... | -2,965,441,005,731,838,500 | See _internal_prep_message for details of how this works. | zerver/lib/actions.py | internal_prep_private_message | gutalavijay1111/zulip-vijay | python | def internal_prep_private_message(realm: Realm, sender: UserProfile, recipient_user: UserProfile, content: str) -> Optional[Dict[(str, Any)]]:
'\n \n '
addressee = Addressee.for_user_profile(recipient_user)
return _internal_prep_message(realm=realm, sender=sender, addressee=addressee, content=content) |
def validate_user_access_to_subscribers(user_profile: Optional[UserProfile], stream: Stream) -> None:
' Validates whether the user can view the subscribers of a stream. Raises a JsonableError if:\n * The user and the stream are in different realms\n * The realm is MIT and the stream is not invite onl... | -7,392,364,703,648,287,000 | Validates whether the user can view the subscribers of a stream. Raises a JsonableError if:
* The user and the stream are in different realms
* The realm is MIT and the stream is not invite only.
* The stream is invite only, requesting_user is passed, and that user
does not subscribe to the stream. | zerver/lib/actions.py | validate_user_access_to_subscribers | gutalavijay1111/zulip-vijay | python | def validate_user_access_to_subscribers(user_profile: Optional[UserProfile], stream: Stream) -> None:
' Validates whether the user can view the subscribers of a stream. Raises a JsonableError if:\n * The user and the stream are in different realms\n * The realm is MIT and the stream is not invite onl... |
def validate_user_access_to_subscribers_helper(user_profile: Optional[UserProfile], stream_dict: Mapping[(str, Any)], check_user_subscribed: Callable[([UserProfile], bool)]) -> None:
"Helper for validate_user_access_to_subscribers that doesn't require\n a full stream object. This function is a bit hard to read,... | 5,070,930,250,182,283,000 | Helper for validate_user_access_to_subscribers that doesn't require
a full stream object. This function is a bit hard to read,
because it is carefully optimized for performance in the two code
paths we call it from:
* In `bulk_get_subscriber_user_ids`, we already know whether the
user was subscribed via `sub_dict`, a... | zerver/lib/actions.py | validate_user_access_to_subscribers_helper | gutalavijay1111/zulip-vijay | python | def validate_user_access_to_subscribers_helper(user_profile: Optional[UserProfile], stream_dict: Mapping[(str, Any)], check_user_subscribed: Callable[([UserProfile], bool)]) -> None:
"Helper for validate_user_access_to_subscribers that doesn't require\n a full stream object. This function is a bit hard to read,... |
def bulk_get_subscriber_user_ids(stream_dicts: Iterable[Mapping[(str, Any)]], user_profile: UserProfile, sub_dict: Mapping[(int, bool)], stream_recipient: StreamRecipientMap) -> Dict[(int, List[int])]:
'sub_dict maps stream_id => whether the user is subscribed to that stream.'
target_stream_dicts = []
for s... | -7,196,757,676,079,950,000 | sub_dict maps stream_id => whether the user is subscribed to that stream. | zerver/lib/actions.py | bulk_get_subscriber_user_ids | gutalavijay1111/zulip-vijay | python | def bulk_get_subscriber_user_ids(stream_dicts: Iterable[Mapping[(str, Any)]], user_profile: UserProfile, sub_dict: Mapping[(int, bool)], stream_recipient: StreamRecipientMap) -> Dict[(int, List[int])]:
target_stream_dicts = []
for stream_dict in stream_dicts:
stream_recipient.populate_with(stream_i... |
def get_subscribers_query(stream: Stream, requesting_user: Optional[UserProfile]) -> QuerySet:
" Build a query to get the subscribers list for a stream, raising a JsonableError if:\n\n 'realm' is optional in stream.\n\n The caller can refine this query with select_related(), values(), etc. depending\n on w... | -4,328,253,176,587,639,300 | Build a query to get the subscribers list for a stream, raising a JsonableError if:
'realm' is optional in stream.
The caller can refine this query with select_related(), values(), etc. depending
on whether it wants objects or just certain fields | zerver/lib/actions.py | get_subscribers_query | gutalavijay1111/zulip-vijay | python | def get_subscribers_query(stream: Stream, requesting_user: Optional[UserProfile]) -> QuerySet:
" Build a query to get the subscribers list for a stream, raising a JsonableError if:\n\n 'realm' is optional in stream.\n\n The caller can refine this query with select_related(), values(), etc. depending\n on w... |
def get_peer_user_ids_for_stream_change(stream: Stream, altered_user_ids: Iterable[int], subscribed_user_ids: Iterable[int]) -> Set[int]:
'\n altered_user_ids is the user_ids that we are adding/removing\n subscribed_user_ids is the already-subscribed user_ids\n\n Based on stream policy, we notify the corre... | -4,022,933,929,084,802,600 | altered_user_ids is the user_ids that we are adding/removing
subscribed_user_ids is the already-subscribed user_ids
Based on stream policy, we notify the correct bystanders, while
not notifying altered_users (who get subscribers via another event) | zerver/lib/actions.py | get_peer_user_ids_for_stream_change | gutalavijay1111/zulip-vijay | python | def get_peer_user_ids_for_stream_change(stream: Stream, altered_user_ids: Iterable[int], subscribed_user_ids: Iterable[int]) -> Set[int]:
'\n altered_user_ids is the user_ids that we are adding/removing\n subscribed_user_ids is the already-subscribed user_ids\n\n Based on stream policy, we notify the corre... |
def check_change_full_name(user_profile: UserProfile, full_name_raw: str, acting_user: UserProfile) -> str:
"Verifies that the user's proposed full name is valid. The caller\n is responsible for checking check permissions. Returns the new\n full name, which may differ from what was passed in (because this\n... | -3,665,740,692,360,973,000 | Verifies that the user's proposed full name is valid. The caller
is responsible for checking check permissions. Returns the new
full name, which may differ from what was passed in (because this
function strips whitespace). | zerver/lib/actions.py | check_change_full_name | gutalavijay1111/zulip-vijay | python | def check_change_full_name(user_profile: UserProfile, full_name_raw: str, acting_user: UserProfile) -> str:
"Verifies that the user's proposed full name is valid. The caller\n is responsible for checking check permissions. Returns the new\n full name, which may differ from what was passed in (because this\n... |
def do_change_notification_settings(user_profile: UserProfile, name: str, value: Union[(bool, int, str)], log: bool=True) -> None:
'Takes in a UserProfile object, the name of a global notification\n preference to update, and the value to update to\n '
notification_setting_type = UserProfile.notification_s... | 2,400,474,181,266,589,700 | Takes in a UserProfile object, the name of a global notification
preference to update, and the value to update to | zerver/lib/actions.py | do_change_notification_settings | gutalavijay1111/zulip-vijay | python | def do_change_notification_settings(user_profile: UserProfile, name: str, value: Union[(bool, int, str)], log: bool=True) -> None:
'Takes in a UserProfile object, the name of a global notification\n preference to update, and the value to update to\n '
notification_setting_type = UserProfile.notification_s... |
def update_to_dict_cache(changed_messages: List[Message], realm_id: Optional[int]=None) -> List[int]:
'Updates the message as stored in the to_dict cache (for serving\n messages).'
items_for_remote_cache = {}
message_ids = []
changed_messages_to_dict = MessageDict.to_dict_uncached(changed_messages, r... | -8,672,592,399,726,761,000 | Updates the message as stored in the to_dict cache (for serving
messages). | zerver/lib/actions.py | update_to_dict_cache | gutalavijay1111/zulip-vijay | python | def update_to_dict_cache(changed_messages: List[Message], realm_id: Optional[int]=None) -> List[int]:
'Updates the message as stored in the to_dict cache (for serving\n messages).'
items_for_remote_cache = {}
message_ids = []
changed_messages_to_dict = MessageDict.to_dict_uncached(changed_messages, r... |
@transaction.atomic
def do_update_message(user_profile: UserProfile, message: Message, new_stream: Optional[Stream], topic_name: Optional[str], propagate_mode: str, send_notification_to_old_thread: bool, send_notification_to_new_thread: bool, content: Optional[str], rendered_content: Optional[str], prior_mention_user_i... | -8,048,410,790,288,677,000 | The main function for message editing. A message edit event can
modify:
* the message's content (in which case the caller will have
set both content and rendered_content),
* the topic, in which case the caller will have set topic_name
* or both
With topic edits, propagate_mode determines whether other message
also ... | zerver/lib/actions.py | do_update_message | gutalavijay1111/zulip-vijay | python | @transaction.atomic
def do_update_message(user_profile: UserProfile, message: Message, new_stream: Optional[Stream], topic_name: Optional[str], propagate_mode: str, send_notification_to_old_thread: bool, send_notification_to_new_thread: bool, content: Optional[str], rendered_content: Optional[str], prior_mention_user_i... |
def get_active_presence_idle_user_ids(realm: Realm, sender_id: int, message_type: str, active_user_ids: Set[int], user_flags: Dict[(int, List[str])]) -> List[int]:
'\n Given a list of active_user_ids, we build up a subset\n of those users who fit these criteria:\n\n * They are likely to need notificati... | 8,566,640,318,382,904,000 | Given a list of active_user_ids, we build up a subset
of those users who fit these criteria:
* They are likely to need notifications (either due
to mentions, alert words, or being PM'ed).
* They are no longer "present" according to the
UserPresence table. | zerver/lib/actions.py | get_active_presence_idle_user_ids | gutalavijay1111/zulip-vijay | python | def get_active_presence_idle_user_ids(realm: Realm, sender_id: int, message_type: str, active_user_ids: Set[int], user_flags: Dict[(int, List[str])]) -> List[int]:
'\n Given a list of active_user_ids, we build up a subset\n of those users who fit these criteria:\n\n * They are likely to need notificati... |
def do_send_confirmation_email(invitee: PreregistrationUser, referrer: UserProfile) -> str:
'\n Send the confirmation/welcome e-mail to an invited user.\n '
activation_url = create_confirmation_link(invitee, Confirmation.INVITATION)
context = {'referrer_full_name': referrer.full_name, 'referrer_email'... | -1,069,681,938,076,176,300 | Send the confirmation/welcome e-mail to an invited user. | zerver/lib/actions.py | do_send_confirmation_email | gutalavijay1111/zulip-vijay | python | def do_send_confirmation_email(invitee: PreregistrationUser, referrer: UserProfile) -> str:
'\n \n '
activation_url = create_confirmation_link(invitee, Confirmation.INVITATION)
context = {'referrer_full_name': referrer.full_name, 'referrer_email': referrer.delivery_email, 'activate_url': activation_ur... |
def estimate_recent_invites(realms: Iterable[Realm], *, days: int) -> int:
'An upper bound on the number of invites sent in the last `days` days'
recent_invites = RealmCount.objects.filter(realm__in=realms, property='invites_sent::day', end_time__gte=(timezone_now() - datetime.timedelta(days=days))).aggregate(S... | 8,210,028,317,846,155,000 | An upper bound on the number of invites sent in the last `days` days | zerver/lib/actions.py | estimate_recent_invites | gutalavijay1111/zulip-vijay | python | def estimate_recent_invites(realms: Iterable[Realm], *, days: int) -> int:
recent_invites = RealmCount.objects.filter(realm__in=realms, property='invites_sent::day', end_time__gte=(timezone_now() - datetime.timedelta(days=days))).aggregate(Sum('value'))['value__sum']
if (recent_invites is None):
re... |
def check_invite_limit(realm: Realm, num_invitees: int) -> None:
'Discourage using invitation emails as a vector for carrying spam.'
msg = _('You do not have enough remaining invites. Please contact {email} to have your limit raised. No invitations were sent.').format(email=settings.ZULIP_ADMINISTRATOR)
if ... | 2,595,359,616,693,616,600 | Discourage using invitation emails as a vector for carrying spam. | zerver/lib/actions.py | check_invite_limit | gutalavijay1111/zulip-vijay | python | def check_invite_limit(realm: Realm, num_invitees: int) -> None:
msg = _('You do not have enough remaining invites. Please contact {email} to have your limit raised. No invitations were sent.').format(email=settings.ZULIP_ADMINISTRATOR)
if (not settings.OPEN_REALM_CREATION):
return
recent_invit... |
def get_occupied_streams(realm: Realm) -> QuerySet:
' Get streams with subscribers '
exists_expression = Exists(Subscription.objects.filter(active=True, user_profile__is_active=True, user_profile__realm=realm, recipient_id=OuterRef('recipient_id')))
occupied_streams = Stream.objects.filter(realm=realm, deac... | 5,858,783,591,674,588,000 | Get streams with subscribers | zerver/lib/actions.py | get_occupied_streams | gutalavijay1111/zulip-vijay | python | def get_occupied_streams(realm: Realm) -> QuerySet:
' '
exists_expression = Exists(Subscription.objects.filter(active=True, user_profile__is_active=True, user_profile__realm=realm, recipient_id=OuterRef('recipient_id')))
occupied_streams = Stream.objects.filter(realm=realm, deactivated=False).annotate(occu... |
def do_remove_realm_custom_profile_field(realm: Realm, field: CustomProfileField) -> None:
'\n Deleting a field will also delete the user profile data\n associated with it in CustomProfileFieldValue model.\n '
field.delete()
notify_realm_custom_profile_fields(realm, 'delete') | -8,935,250,695,324,977,000 | Deleting a field will also delete the user profile data
associated with it in CustomProfileFieldValue model. | zerver/lib/actions.py | do_remove_realm_custom_profile_field | gutalavijay1111/zulip-vijay | python | def do_remove_realm_custom_profile_field(realm: Realm, field: CustomProfileField) -> None:
'\n Deleting a field will also delete the user profile data\n associated with it in CustomProfileFieldValue model.\n '
field.delete()
notify_realm_custom_profile_fields(realm, 'delete') |
def get_ids_for(f: Callable[([Dict[(str, Any)]], bool)]) -> Set[int]:
'Only includes users on the explicit message to line'
return ({row['id'] for row in rows if f(row)} & message_to_user_id_set) | -8,346,664,401,585,981,000 | Only includes users on the explicit message to line | zerver/lib/actions.py | get_ids_for | gutalavijay1111/zulip-vijay | python | def get_ids_for(f: Callable[([Dict[(str, Any)]], bool)]) -> Set[int]:
return ({row['id'] for row in rows if f(row)} & message_to_user_id_set) |
def train(self, mode=True):
'Populate label similarity map based on cosine similarity before running epoch\n\n If the `num_negative_labels_to_sample` is set to an integer value then before starting\n each epoch the model would create a similarity measure between the label names based\n on cosin... | -4,809,101,940,404,317,000 | Populate label similarity map based on cosine similarity before running epoch
If the `num_negative_labels_to_sample` is set to an integer value then before starting
each epoch the model would create a similarity measure between the label names based
on cosine distances between their BERT encoded embeddings. | flair/models/tars_model.py | train | garciaeduardo7143/flair | python | def train(self, mode=True):
'Populate label similarity map based on cosine similarity before running epoch\n\n If the `num_negative_labels_to_sample` is set to an integer value then before starting\n each epoch the model would create a similarity measure between the label names based\n on cosin... |
def _compute_label_similarity_for_current_epoch(self):
'\n Compute the similarity between all labels for better sampling of negatives\n '
all_labels = [label.decode('utf-8') for label in self.get_current_label_dictionary().idx2item]
label_sentences = [Sentence(label) for label in all_labels]
... | -4,897,460,015,375,832,000 | Compute the similarity between all labels for better sampling of negatives | flair/models/tars_model.py | _compute_label_similarity_for_current_epoch | garciaeduardo7143/flair | python | def _compute_label_similarity_for_current_epoch(self):
'\n \n '
all_labels = [label.decode('utf-8') for label in self.get_current_label_dictionary().idx2item]
label_sentences = [Sentence(label) for label in all_labels]
self.tars_embeddings.eval()
self.tars_embeddings.embed(label_senten... |
def add_and_switch_to_new_task(self, task_name, label_dictionary: Union[(List, Set, Dictionary, str)], label_type: str, multi_label: bool=True, force_switch: bool=False):
"\n Adds a new task to an existing TARS model. Sets necessary attributes and finally 'switches'\n to the new task. Parameters are s... | -2,168,035,682,850,008,600 | Adds a new task to an existing TARS model. Sets necessary attributes and finally 'switches'
to the new task. Parameters are similar to the constructor except for model choice, batch
size and negative sampling. This method does not store the resultant model onto disk.
:param task_name: a string depicting the name of the... | flair/models/tars_model.py | add_and_switch_to_new_task | garciaeduardo7143/flair | python | def add_and_switch_to_new_task(self, task_name, label_dictionary: Union[(List, Set, Dictionary, str)], label_type: str, multi_label: bool=True, force_switch: bool=False):
"\n Adds a new task to an existing TARS model. Sets necessary attributes and finally 'switches'\n to the new task. Parameters are s... |
def list_existing_tasks(self) -> Set[str]:
'\n Lists existing tasks in the loaded TARS model on the console.\n '
return set(self._task_specific_attributes.keys()) | 6,965,795,004,101,275,000 | Lists existing tasks in the loaded TARS model on the console. | flair/models/tars_model.py | list_existing_tasks | garciaeduardo7143/flair | python | def list_existing_tasks(self) -> Set[str]:
'\n \n '
return set(self._task_specific_attributes.keys()) |
def switch_to_task(self, task_name):
'\n Switches to a task which was previously added.\n '
if (task_name not in self._task_specific_attributes):
log.error('Provided `%s` does not exist in the model. Consider calling `add_and_switch_to_new_task` first.', task_name)
else:
self._... | -3,186,966,254,722,553,300 | Switches to a task which was previously added. | flair/models/tars_model.py | switch_to_task | garciaeduardo7143/flair | python | def switch_to_task(self, task_name):
'\n \n '
if (task_name not in self._task_specific_attributes):
log.error('Provided `%s` does not exist in the model. Consider calling `add_and_switch_to_new_task` first.', task_name)
else:
self._current_task = task_name |
def predict_zero_shot(self, sentences: Union[(List[Sentence], Sentence)], candidate_label_set: Union[(List[str], Set[str], str)], multi_label: bool=True):
'\n Method to make zero shot predictions from the TARS model\n :param sentences: input sentence objects to classify\n :param candidate_label... | -1,446,347,997,733,357,300 | Method to make zero shot predictions from the TARS model
:param sentences: input sentence objects to classify
:param candidate_label_set: set of candidate labels
:param multi_label: indicates whether multi-label or single class prediction. Defaults to True. | flair/models/tars_model.py | predict_zero_shot | garciaeduardo7143/flair | python | def predict_zero_shot(self, sentences: Union[(List[Sentence], Sentence)], candidate_label_set: Union[(List[str], Set[str], str)], multi_label: bool=True):
'\n Method to make zero shot predictions from the TARS model\n :param sentences: input sentence objects to classify\n :param candidate_label... |
def __init__(self, task_name: Optional[str]=None, label_dictionary: Optional[Dictionary]=None, label_type: Optional[str]=None, embeddings: Union[(TransformerWordEmbeddings, str)]='bert-base-uncased', num_negative_labels_to_sample: int=2, prefix: bool=True, **tagger_args):
"\n Initializes a TextClassifier\n ... | -356,820,534,521,518,200 | Initializes a TextClassifier
:param task_name: a string depicting the name of the task
:param label_dictionary: dictionary of labels you want to predict
:param embeddings: name of the pre-trained transformer model e.g.,
'bert-base-uncased' etc
:param num_negative_labels_to_sample: number of negative labels to sample fo... | flair/models/tars_model.py | __init__ | garciaeduardo7143/flair | python | def __init__(self, task_name: Optional[str]=None, label_dictionary: Optional[Dictionary]=None, label_type: Optional[str]=None, embeddings: Union[(TransformerWordEmbeddings, str)]='bert-base-uncased', num_negative_labels_to_sample: int=2, prefix: bool=True, **tagger_args):
"\n Initializes a TextClassifier\n ... |
def predict(self, sentences: Union[(List[Sentence], Sentence)], mini_batch_size=32, return_probabilities_for_all_classes: bool=False, verbose: bool=False, label_name: Optional[str]=None, return_loss=False, embedding_storage_mode='none', most_probable_first: bool=True):
"\n Predict sequence tags for Named Ent... | -2,638,801,726,960,084,000 | Predict sequence tags for Named Entity Recognition task
:param sentences: a Sentence or a List of Sentence
:param mini_batch_size: size of the minibatch, usually bigger is more rapid but consume more memory,
up to a point when it has no more effect.
:param all_tag_prob: True to compute the score for each tag on each to... | flair/models/tars_model.py | predict | garciaeduardo7143/flair | python | def predict(self, sentences: Union[(List[Sentence], Sentence)], mini_batch_size=32, return_probabilities_for_all_classes: bool=False, verbose: bool=False, label_name: Optional[str]=None, return_loss=False, embedding_storage_mode='none', most_probable_first: bool=True):
"\n Predict sequence tags for Named Ent... |
def __init__(self, task_name: Optional[str]=None, label_dictionary: Optional[Dictionary]=None, label_type: Optional[str]=None, embeddings: Union[(TransformerDocumentEmbeddings, str)]='bert-base-uncased', num_negative_labels_to_sample: int=2, prefix: bool=True, **tagger_args):
"\n Initializes a TextClassifier... | 1,821,094,420,257,161,000 | Initializes a TextClassifier
:param task_name: a string depicting the name of the task
:param label_dictionary: dictionary of labels you want to predict
:param embeddings: name of the pre-trained transformer model e.g.,
'bert-base-uncased' etc
:param num_negative_labels_to_sample: number of negative labels to sample fo... | flair/models/tars_model.py | __init__ | garciaeduardo7143/flair | python | def __init__(self, task_name: Optional[str]=None, label_dictionary: Optional[Dictionary]=None, label_type: Optional[str]=None, embeddings: Union[(TransformerDocumentEmbeddings, str)]='bert-base-uncased', num_negative_labels_to_sample: int=2, prefix: bool=True, **tagger_args):
"\n Initializes a TextClassifier... |
def predict(self, sentences: Union[(List[Sentence], Sentence)], mini_batch_size=32, return_probabilities_for_all_classes: bool=False, verbose: bool=False, label_name: Optional[str]=None, return_loss=False, embedding_storage_mode='none', label_threshold: float=0.5, multi_label: Optional[bool]=None):
"\n Predi... | -6,983,995,804,185,518,000 | Predict sequence tags for Named Entity Recognition task
:param sentences: a Sentence or a List of Sentence
:param mini_batch_size: size of the minibatch, usually bigger is more rapid but consume more memory,
up to a point when it has no more effect.
:param all_tag_prob: True to compute the score for each tag on each to... | flair/models/tars_model.py | predict | garciaeduardo7143/flair | python | def predict(self, sentences: Union[(List[Sentence], Sentence)], mini_batch_size=32, return_probabilities_for_all_classes: bool=False, verbose: bool=False, label_name: Optional[str]=None, return_loss=False, embedding_storage_mode='none', label_threshold: float=0.5, multi_label: Optional[bool]=None):
"\n Predi... |
@click.command()
def main(args=None):
'Console script for python_learn.'
click.echo('Replace this message by putting your code into python_learn.cli.main')
click.echo('See click documentation at http://click.pocoo.org/')
return 0 | -3,725,427,754,268,343,300 | Console script for python_learn. | python_learn/cli.py | main | Zhazhanan/python_learn | python | @click.command()
def main(args=None):
click.echo('Replace this message by putting your code into python_learn.cli.main')
click.echo('See click documentation at http://click.pocoo.org/')
return 0 |
@classmethod
def from_artifact(cls, artifact):
'Upsert logic to generate an ArtifactReference object from an artifact'
obj = cls.query.get(_id=artifact.index_id())
if (obj is not None):
return obj
try:
obj = cls(_id=artifact.index_id(), artifact_reference=dict(cls=bson.Binary(dumps(artif... | 4,642,030,310,060,067,000 | Upsert logic to generate an ArtifactReference object from an artifact | Allura/allura/model/index.py | from_artifact | brondsem/allura | python | @classmethod
def from_artifact(cls, artifact):
obj = cls.query.get(_id=artifact.index_id())
if (obj is not None):
return obj
try:
obj = cls(_id=artifact.index_id(), artifact_reference=dict(cls=bson.Binary(dumps(artifact.__class__, protocol=2)), project_id=artifact.app_config.project_id,... |
@LazyProperty
def artifact(self):
'Look up the artifact referenced'
aref = self.artifact_reference
try:
cls = loads(six.binary_type(aref.cls))
with h.push_context(aref.project_id):
return cls.query.get(_id=aref.artifact_id)
except Exception:
log.exception('Error loadi... | -8,850,843,363,701,119,000 | Look up the artifact referenced | Allura/allura/model/index.py | artifact | brondsem/allura | python | @LazyProperty
def artifact(self):
aref = self.artifact_reference
try:
cls = loads(six.binary_type(aref.cls))
with h.push_context(aref.project_id):
return cls.query.get(_id=aref.artifact_id)
except Exception:
log.exception('Error loading artifact for %s: %r', self._id... |
@classmethod
def from_links(cls, *links):
'Convert a sequence of shortlinks to the matching Shortlink objects'
if len(links):
result = {}
parsed_links = dict(((link, cls._parse_link(link)) for link in links))
links_by_artifact = defaultdict(list)
project_ids = set()
for (... | -9,188,563,132,522,894,000 | Convert a sequence of shortlinks to the matching Shortlink objects | Allura/allura/model/index.py | from_links | brondsem/allura | python | @classmethod
def from_links(cls, *links):
if len(links):
result = {}
parsed_links = dict(((link, cls._parse_link(link)) for link in links))
links_by_artifact = defaultdict(list)
project_ids = set()
for (link, d) in list(parsed_links.items()):
if d:
... |
@classmethod
def _parse_link(cls, s):
'Parse a shortlink into its nbhd/project/app/artifact parts'
s = s.strip()
if s.startswith('['):
s = s[1:]
if s.endswith(']'):
s = s[:(- 1)]
parts = s.split(':')
p_shortname = None
p_id = None
p_nbhd = None
if getattr(c, 'project'... | -1,522,056,454,869,889,800 | Parse a shortlink into its nbhd/project/app/artifact parts | Allura/allura/model/index.py | _parse_link | brondsem/allura | python | @classmethod
def _parse_link(cls, s):
s = s.strip()
if s.startswith('['):
s = s[1:]
if s.endswith(']'):
s = s[:(- 1)]
parts = s.split(':')
p_shortname = None
p_id = None
p_nbhd = None
if getattr(c, 'project', None):
p_shortname = getattr(c.project, 'shortname... |
def grow(plant=[], branch=0.01):
' Updates each root in the given list to a new position.\n Roots can branch and will disappear over time.\n Returns the updated list.\n '
new = []
for root in plant:
root.update()
if (root.time > 0.05):
new.append(root)
el... | -5,876,942,146,591,880,000 | Updates each root in the given list to a new position.
Roots can branch and will disappear over time.
Returns the updated list. | examples/07-filter/09-buffer.py | grow | pepsipepsi/nodebox_opengl_python3 | python | def grow(plant=[], branch=0.01):
' Updates each root in the given list to a new position.\n Roots can branch and will disappear over time.\n Returns the updated list.\n '
new = []
for root in plant:
root.update()
if (root.time > 0.05):
new.append(root)
el... |
def __init__(self, master: object, shape: object, value=0, maximum=100, bg='#231303', trough_color='#8a7852', bar_color='#f7f4bf'):
'Creating the alpha mask and creating a custom widget of the given shape and dimensions.'
im_shape_alpha = Image.open(shape).convert('L')
im_shape = Image.new('RGBA', im_shape_... | -57,122,219,250,956,210 | Creating the alpha mask and creating a custom widget of the given shape and dimensions. | Scripts/mybar.py | __init__ | 1337-inc/Captain | python | def __init__(self, master: object, shape: object, value=0, maximum=100, bg='#231303', trough_color='#8a7852', bar_color='#f7f4bf'):
im_shape_alpha = Image.open(shape).convert('L')
im_shape = Image.new('RGBA', im_shape_alpha.size, bg)
im_shape.putalpha(im_shape_alpha)
(width, height) = im_shape_alph... |
@property
def value(self):
"Return bar's value."
return self._value | 6,355,790,876,013,271,000 | Return bar's value. | Scripts/mybar.py | value | 1337-inc/Captain | python | @property
def value(self):
return self._value |
@value.setter
def value(self, value: int):
"Set bar's value."
self._value = value
self.coords('pbar', 0, self.height, self.width, (self.height * (1 - (value / self.maximum)))) | -8,252,413,346,168,670,000 | Set bar's value. | Scripts/mybar.py | value | 1337-inc/Captain | python | @value.setter
def value(self, value: int):
self._value = value
self.coords('pbar', 0, self.height, self.width, (self.height * (1 - (value / self.maximum)))) |
def _common_args():
'ArgumentParser setup for all CLI commands.'
parser = argparse.ArgumentParser(description='Start a new profiler process.')
parser.add_argument('--config', required=True, help='The Python configuration file for the process.')
return parser | 3,170,931,945,910,749,000 | ArgumentParser setup for all CLI commands. | pyperf/cmd/daemons.py | _common_args | kevinconway/PyPerf | python | def _common_args():
parser = argparse.ArgumentParser(description='Start a new profiler process.')
parser.add_argument('--config', required=True, help='The Python configuration file for the process.')
return parser |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.