text
stringlengths
81
112k
Build attachment mock. def build_attachment2(): """Build attachment mock.""" attachment = Attachment() attachment.content = "BwdW" attachment.type = "image/png" attachment.filename = "banner.png" attachment.disposition = "inline" attachment.content_id = "Banner" return attachment
All settings set def build_kitchen_sink(): """All settings set""" from sendgrid.helpers.mail import ( Mail, From, To, Cc, Bcc, Subject, PlainTextContent, HtmlContent, SendGridException, Substitution, Header, CustomArg, SendAt, Content, MimeType, Attachment, FileName, FileConte...
Allow variables assigned in .env available using os.environ.get('VAR_NAME') def init_environment(): """Allow variables assigned in .env available using os.environ.get('VAR_NAME')""" base_path = os.path.abspath(os.path.dirname(__file__)) env_path = '{0}/.env'.format(base_pa...
Get a JSON-ready representation of this MailSettings. :returns: This MailSettings, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this MailSettings. :returns: This MailSettings, ready for use in a request body. :rtyp...
Get a JSON-ready representation of this Substitution. :returns: This Substitution, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this Substitution. :returns: This Substitution, ready for use in a request body. :rtyp...
Get a JSON-ready representation of this Header. :returns: This Header, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this Header. :returns: This Header, ready for use in a request body. :rtype: dict """ ...
Return a dictionary of key/values in the payload received from the webhook def key_values(self): """ Return a dictionary of key/values in the payload received from the webhook """ key_values = {} for key in self.keys: if key in self.payload: ...
This only applies to raw payloads: https://sendgrid.com/docs/Classroom/Basics/Inbound_Parse_Webhook/setting_up_the_inbound_parse_webhook.html#-Raw-Parameters def get_raw_email(self): """ This only applies to raw payloads: https://sendgrid.com/docs/Classroom/Basics/Inbound_Parse_Webhook/...
Returns an object with: type = file content type file_name = the name of the file contents = base64 encoded file contents def attachments(self): """Returns an object with: type = file content type file_name = the name of the file contents = base64 encoded file co...
decouple, allow for modifications to return type returns a list of ip addresses in object or json form def format_ret(return_set, as_json=False): """ decouple, allow for modifications to return type returns a list of ip addresses in object or json form """ ret_list = list() for item in retu...
https://sendgrid.com/docs/API_Reference/api_v3.html#ip-addresses The /ips rest endpoint returns information about the IP addresses and the usernames assigned to an IP unassigned returns a listing of the IP addresses that are allocated but have 0 users assigned data (response.b...
Add a single recipient to this Personalization. :type email: Email def add_to(self, email): """Add a single recipient to this Personalization. :type email: Email """ if email.substitutions: if isinstance(email.substitutions, list): for substitution ...
Add a new Substitution to this Personalization. :type substitution: Substitution def add_substitution(self, substitution): """Add a new Substitution to this Personalization. :type substitution: Substitution """ if isinstance(substitution, dict): self._substitutions...
Get a JSON-ready representation of this Personalization. :returns: This Personalization, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this Personalization. :returns: This Personalization, ready for use in a request body. ...
Get a JSON-ready representation of this CustomArg. :returns: This CustomArg, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this CustomArg. :returns: This CustomArg, ready for use in a request body. :rtype: dict ...
Get a JSON-ready representation of this Section. :returns: This Section, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this Section. :returns: This Section, ready for use in a request body. :rtype: dict """ ...
Get a JSON-ready representation of this ClickTracking. :returns: This ClickTracking, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this ClickTracking. :returns: This ClickTracking, ready for use in a request body. :...
Get a JSON-ready representation of this SubscriptionTracking. :returns: This SubscriptionTracking, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this SubscriptionTracking. :returns: This SubscriptionTracking, ready for use ...
Get a JSON-ready representation of this TrackingSettings. :returns: This TrackingSettings, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this TrackingSettings. :returns: This TrackingSettings, ready for use in a request bod...
Get a JSON-ready representation of this OpenTracking. :returns: This OpenTracking, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this OpenTracking. :returns: This OpenTracking, ready for use in a request body. :rtyp...
:return: response stats dict def get(self): """ :return: response stats dict """ stats = {} if self.start_date is not None: stats["start_date"] = self.start_date if self.end_date is not None: stats["end_date"] = self.end_date if self.aggre...
The Base64 encoded content of the attachment :param value: The Base64 encoded content of the attachment :type value: FileContent, string def file_content(self, value): """The Base64 encoded content of the attachment :param value: The Base64 encoded content of the attachment :t...
The filename of the attachment :param file_name: The filename of the attachment :type file_name: FileName, string def file_name(self, value): """The filename of the attachment :param file_name: The filename of the attachment :type file_name: FileName, string """ ...
The MIME type of the content you are attaching :param file_type: The MIME type of the content you are attaching :type file_type FileType, string, optional def file_type(self, value): """The MIME type of the content you are attaching :param file_type: The MIME type of the content you a...
The content-disposition of the attachment, specifying display style. Specifies how you would like the attachment to be displayed. - "inline" results in the attached file being displayed automatically within the message. - "attachment" results in the attached file requiring some ac...
The content id for the attachment. This is used when the disposition is set to "inline" and the attachment is an image, allowing the file to be displayed within the email body. :param content_id: The content id for the attachment. This is used when the Disposition is...
Get a JSON-ready representation of this Attachment. :returns: This Attachment, ready for use in a request body. :rtype: dict def get(self): """ Get a JSON-ready representation of this Attachment. :returns: This Attachment, ready for use in a request body. :rtype: dict ...
Execute computation of blobs on input eopatch :param eopatch: Input eopatch :type eopatch: eolearn.core.EOPatch :return: EOPatch instance with new key holding the blob image. :rtype: eolearn.core.EOPatch def execute(self, eopatch): """ Execute computation of blobs on input eopa...
Check if the classifier implements predict and predict_proba methods. def _check_classifier(classifier): """ Check if the classifier implements predict and predict_proba methods. """ predict = getattr(classifier, "predict", None) if not callable(predict): raise...
Checks the image size and its compatibility with classifier's receptive field. At this moment it is required that image size = K * receptive_field. This will be relaxed in future with the introduction of padding. def _check_image(self, X): """ Checks the image size and its compati...
Predicts class label for the entire image. Parameters: ----------- X: array, shape = [n_samples, n_pixels_y, n_pixels_x, n_bands] Array of training images y: array, shape = [n_samples] or [n_samples, n_pixels_y, n_pixels_x] Target labels or masks. def...
Predicts class probabilities for the entire image. Parameters: ----------- X: array, shape = [n_samples, n_pixels_x, n_pixels_y, n_bands] Array of training images y: array, shape = [n_samples] or [n_samples, n_pixels_x, n_pixels_y, n_classes] Target pr...
Reshapes input to patches of the size of classifier's receptive field. For example: input X shape: [n_samples, n_pixels_y, n_pixels_x, n_bands] output: [n_samples * n_pixels_y/receptive_field_y * n_pixels_x/receptive_field_x, receptive_field_y, receptive_field_x, n_ban...
Predicts class label for the entire image. Parameters: ----------- X: array, shape = [n_samples, n_pixels_y, n_pixels_x, n_bands] Array of training images y: array, shape = [n_samples] or [n_samples, n_pixels_y, n_pixels_x] Target labels or masks. def...
Predicts class probabilities for the entire image. Parameters: ----------- X: array, shape = [n_samples, n_pixels_x, n_pixels_y, n_bands] Array of training images y: array, shape = [n_samples] or [n_samples, n_pixels_x, n_pixels_y, n_classes] Target pr...
Reshapes input to patches of the size of classifier's receptive field. For example: input X shape: [n_samples, n_pixels_y, n_pixels_x, n_bands] output: [n_samples * n_pixels_y/receptive_field_y * n_pixels_x/receptive_field_x, receptive_field_y, receptive_field_x, n_ban...
Predicts class label for the entire image. Parameters: ----------- X: array, shape = [n_samples, n_pixels_y, n_pixels_x, n_bands] Array of training images y: array, shape = [n_samples] or [n_samples, n_pixels_y, n_pixels_x] Target labels or masks. def...
Predicts class probabilities for the entire image. Parameters: ----------- X: array, shape = [n_samples, n_pixels_x, n_pixels_y, n_bands] Array of training images y: array, shape = [n_samples] or [n_samples, n_pixels_x, n_pixels_y, n_classes] Target pr...
Transforms [n, w, h, d] eopatch into a [n, w, h, 1] eopatch, adding it the classification mask. :param eopatch: An input EOPatch :type eopatch: EOPatch :return: Outputs EOPatch with n classification masks appended to out_feature_type with out_feature_name key :rtype...
Parses execution arguments provided by user and raises an error if something is wrong def _parse_execution_args(execution_args): """ Parses execution arguments provided by user and raises an error if something is wrong """ if not isinstance(execution_args, (list, tuple)): raise Valu...
Runs the executor with n workers. :param workers: Number of parallel processes used in the execution. Default is a single process. If set to `None` the number of workers will be the number of processors of the system. :type workers: int or None def run(self, workers=1): """ Runs th...
Handles a single execution of a workflow def _execute_workflow(cls, process_args): """ Handles a single execution of a workflow """ workflow, input_args, log_path = process_args if log_path: logger = logging.getLogger() logger.setLevel(logging.DEBUG) ...
Makes a html report and saves it into the same folder where logs are stored. def make_report(self): """ Makes a html report and saves it into the same folder where logs are stored. """ if self.execution_stats is None: raise RuntimeError('Cannot produce a report without running the e...
Action to be taken when an event is triggered. Event is scroll of the mouse's wheel. This leads to changing the temporal frame displayed. :param event: Scroll of mouse wheel def onscroll(self, event): """Action to be taken when an event is triggered. Event is scroll of the mou...
Updates image to be displayed with new time frame. def update(self): """Updates image to be displayed with new time frame.""" if self.single_channel: self.im.set_data(self.data[self.ind, :, :]) else: self.im.set_data(self.data[self.ind, :, :, :]) self.ax.se...
Performs checks on dimensionality of data to makes it suitable for display. :param eopatch: Input eopatch :return: Array to display and whether it is single channel or not def _get_data_to_display(self, eopatch): """Performs checks on dimensionality of data to makes it suitable for display...
Shows data and scrolls through. Currently not working from Jupyter notebooks. :param eopatch: Image sequence to display. Can be single channel, RGB or multi-channel. If multi-channel, indices must be specified. :type eopatch: numpy array :param title: String to be d...
Compute spatio-temporal features for input eopatch :param eopatch: Input eopatch :return: eopatch with computed spatio-temporal features def execute(self, eopatch): """ Compute spatio-temporal features for input eopatch :param eopatch: Input eopatch :return: eopatch with compu...
Compute argmax/argmin of specified `data_feature` and `data_index` :param eopatch: Input eopatch :return: eopatch with added argmax/argmin features def execute(self, eopatch): """ Compute argmax/argmin of specified `data_feature` and `data_index` :param eopatch: Input eopatch ...
Computation of NDVI slope using finite central differences This implementation loops through every spatial location, considers the valid NDVI values and approximates their first order derivative using central differences. The argument of min and max is added to the eopatch. The NDVI slope at d...
Returns WMS request. def _get_wms_request(self, bbox, size_x, size_y): """ Returns WMS request. """ bbox_3857 = transform_bbox(bbox, CRS.POP_WEB) return GeopediaWmsRequest(layer=self.layer, theme=self.theme, bb...
Reprojects the raster data from Geopedia's CRS (POP_WEB) to EOPatch's CRS. def _reproject(self, eopatch, src_raster): """ Reprojects the raster data from Geopedia's CRS (POP_WEB) to EOPatch's CRS. """ height, width = src_raster.shape dst_raster = np.ones((height, width), dtype=...
Each request represents a binary class which will be mapped to the scalar `raster_value` def _map_from_binaries(self, eopatch, dst_shape, request_data): """ Each request represents a binary class which will be mapped to the scalar `raster_value` """ if self.feature_name in eopatch[self....
`raster_value` is a dictionary specifying the intensity values for each class and the corresponding label value. A dictionary example for GLC30 LULC mapping is: raster_value = {'no_data': (0,[0,0,0,0]), 'cultivated land': (1,[193, 243, 249, 255]), 'forest...
Add requested feature to this existing EOPatch. def execute(self, eopatch): """ Add requested feature to this existing EOPatch. """ data_arr = eopatch[FeatureType.MASK]['IS_DATA'] _, height, width, _ = data_arr.shape request = self._get_wms_request(eopatch.bbox, width, ...
Collects the parameter either from initialization parameters or from EOPatch def _get_parameter(self, name, eopatch): """ Collects the parameter either from initialization parameters or from EOPatch """ if hasattr(self, name) and getattr(self, name) is not None: return getattr(self,...
Collects all parameters used for DataRequest, each one is taken either from initialization parameters or from EOPatch def _prepare_request_data(self, eopatch, bbox, time_interval): """ Collects all parameters used for DataRequest, each one is taken either from initialization parameters or from ...
Adds downloaded data to EOPatch def _add_data(self, eopatch, data): """ Adds downloaded data to EOPatch """ valid_mask = data[..., -1] data = data[..., :-1] if data.ndim == 3: data = data.reshape(data.shape + (1,)) if not self.feature_type.is_time_dependent(): ...
Adds any missing metadata info to EOPatch def _add_meta_info(self, eopatch, request_params, service_type): """ Adds any missing metadata info to EOPatch """ for param, eoparam in zip(['time', 'time_difference', 'maxcc'], ['time_interval', 'time_difference', 'maxcc']): if eoparam not in eop...
Creates OGC (WMS or WCS) request, downloads requested data and stores it together with valid data mask in newly created EOPatch. Returns the EOPatch. :param eopatch: :type eopatch: EOPatch or None :param bbox: specifies the bounding box of the requested image. Coordinates must be in ...
Wrapper function for pixel-based S2 cloud detector `S2PixelCloudDetector` def get_s2_pixel_cloud_detector(threshold=0.4, average_over=4, dilation_size=2, all_bands=True): """ Wrapper function for pixel-based S2 cloud detector `S2PixelCloudDetector` """ return S2PixelCloudDetector(threshold=threshold, ...
Returns WMS request. def _get_wms_request(self, bbox, time_interval, size_x, size_y, maxcc, time_difference, custom_url_params): """ Returns WMS request. """ return WmsRequest(layer=self.data_feature, bbox=bbox, time=time_interval, ...
Returns WCS request. def _get_wcs_request(self, bbox, time_interval, size_x, size_y, maxcc, time_difference, custom_url_params): """ Returns WCS request. """ return WcsRequest(layer=self.data_feature, bbox=bbox, time=time_interval, ...
Compute the resampling factor for height and width of the input array :param reference_shape: Tuple specifying height and width in pixels of high-resolution array :type reference_shape: tuple of ints :param meta_info: Meta-info dictionary of input eopatch. Defines OGC request and parameters use...
Downscale existing array to resolution requested by cloud detector :param hr_array: High-resolution data array to be downscaled :param meta_info: Meta-info of eopatch :param interp: Interpolation method to be used in downscaling. Default is `'linear'` :param smooth: Apply Gaussian smoot...
Upsample the low-resolution array to the original high-resolution grid :param lr_array: Low-resolution array to be upsampled :param rescale: Rescale factor for rows/columns :param reference_shape: Original size of high-resolution eopatch. Tuple with dimension for time, height and ...
Make OGC request to create input for cloud detector classifier :param bbox: Bounding box :param meta_info: Meta-info dictionary of input eopatch :return: Requested data def _make_request(self, bbox, meta_info, timestamps): """ Make OGC request to create input for cloud detector classif...
Add cloud binary mask and (optionally) cloud probability map to input eopatch :param eopatch: Input `EOPatch` instance :return: `EOPatch` with additional cloud maps def execute(self, eopatch): """ Add cloud binary mask and (optionally) cloud probability map to input eopatch :param eop...
Handles measuring execution time and error propagation def _execute_handling(self, *eopatches, **kwargs): """ Handles measuring execution time and error propagation """ self.private_task_config.start_time = datetime.datetime.now() caught_exception = None try: ...
See eolearn.core.utilities.FeatureParser class. def _parse_features(features, new_names=False, rename_function=None, default_feature_type=None, allowed_feature_types=None): """ See eolearn.core.utilities.FeatureParser class. """ return FeatureParser(features, new_nam...
Function which will process README.md file and divide it into INTRO.md and INSTALL.md, which will be used in documentation def process_readme(): """ Function which will process README.md file and divide it into INTRO.md and INSTALL.md, which will be used in documentation """ with open('../../README...
Return indices of timestamps from source that are also found in target. :param source: timestamps from source :type source: list of datetime objects :param target: timestamps from target :type target: list of datetime objects :return: indices of timestamps from source that are also found in t...
Compares whether fst_obj and snd_obj are deeply equal. In case when both fst_obj and snd_obj are of type np.ndarray or either np.memmap, they are compared using np.array_equal(fst_obj, snd_obj). Otherwise, when they are lists or tuples, they are compared for length and then deep_eq is applied component...
Returns the negated mask. If elements of input mask have 0 and non-zero values, then the returned matrix will have all elements 0 (1) where the original one has non-zero (0). :param mask: Input mask :type mask: np.array :return: array of same shape and dtype=int8 as input array :rtype:...
Function pads an image of shape (rows, columns, channels) with zeros. It pads an image so that the shape becomes (rows + padded_rows, columns + padded_columns, channels), where padded_rows = (int(rows/multiple_of[0]) + 1) * multiple_of[0] - rows Same rule is applied to columns. :type X: array ...
Takes a collection of features structured in a various ways and parses them into one way. If input format is not recognized it raises an error. :return: A collection of features :rtype: collections.OrderedDict(FeatureType: collections.OrderedDict(str: str or Ellipsis) or Ellipsis) ...
Helping function of `_parse_features` that parses a list. def _parse_dict(features, new_names): """Helping function of `_parse_features` that parses a list.""" feature_collection = OrderedDict() for feature_type, feature_names in features.items(): try: feature_t...
Helping function of `_parse_features` that parses a list. def _parse_list(features, new_names): """Helping function of `_parse_features` that parses a list.""" feature_collection = OrderedDict() for feature in features: if isinstance(feature, FeatureType): featu...
Helping function of `_parse_features` that parses a tuple. def _parse_tuple(features, new_names): """Helping function of `_parse_features` that parses a tuple.""" name_idx = 1 try: feature_type = FeatureType(features[0]) except ValueError: feature_type = No...
Helping function of `_parse_features` that parses a collection of feature names. def _parse_feature_names(feature_names, new_names): """Helping function of `_parse_features` that parses a collection of feature names.""" if isinstance(feature_names, set): return FeatureParser._parse_names...
Helping function of `_parse_feature_names` that parses a set of feature names. def _parse_names_set(feature_names): """Helping function of `_parse_feature_names` that parses a set of feature names.""" feature_collection = OrderedDict() for feature_name in feature_names: if isins...
Helping function of `_parse_feature_names` that parses a dictionary of feature names. def _parse_names_dict(feature_names): """Helping function of `_parse_feature_names` that parses a dictionary of feature names.""" feature_collection = OrderedDict() for feature_name, new_feature_name in fea...
Helping function of `_parse_feature_names` that parses a tuple or a list of feature names. def _parse_names_tuple(feature_names, new_names): """Helping function of `_parse_feature_names` that parses a tuple or a list of feature names.""" for feature in feature_names: if not isinstance(fe...
Checks that feature types are a subset of allowed feature types. (`None` is handled :raises: ValueError def _check_feature_types(self): """ Checks that feature types are a subset of allowed feature types. (`None` is handled :raises: ValueError """ if self.default_featur...
A generator of parsed features. :param eopatch: A given EOPatch :type eopatch: EOPatch or None :return: One by one feature :rtype: tuple(FeatureType, str) or tuple(FeatureType, str, str) def _get_features(self, eopatch=None): """A generator of parsed features. ...
Iterates over allowed feature types of given EOPatch and tries to find a feature type for which there exists a feature with given name :return: A feature type or `None` if such feature type does not exist :rtype: FeatureType or None def _find_feature_type(self, feature_name, eopatch): ...
Helping function of `get_features` def _return_feature(self, feature_type, feature_name, new_feature_name=...): """ Helping function of `get_features` """ if self.new_names: return feature_type, feature_name, (self.rename_function(feature_name) if new_feature_name is ... else ...
Parses dependencies and adds names of task_names. :param dependencies: Input of dependency parameter :type dependencies: list(tuple or Dependency) :param task_names: Human-readable names of tasks :type task_names: dict(EOTask: str) or None :return: List of dependencies ...
Adds universally unique user ids (UUID) to each task of the workflow. :param dependencies: The list of dependencies between tasks defining the computational graph :type dependencies: list(Dependency) :return: A dictionary mapping UUID to dependencies :rtype: dict(str: Dependency) ...
Creates a directed graph from dependencies. :param dependencies: A list of Dependency objects :type dependencies: list(Dependency) :return: A directed graph of the workflow :rtype: DirectedGraph def create_dag(self, dependencies): """Creates a directed graph from dependen...
Computes an ordering < of tasks so that for any two tasks t and t' we have that if t depends on t' then t' < t. In words, all dependencies of a task precede the task in this ordering. :param dag: A directed acyclic graph representing dependencies between tasks. :type dag: DirectedGraph ...
Factory method for creating linear workflows. :param tasks: EOTask's t1,t2,...,tk with dependencies t1->t2->...->tk :param kwargs: Optional keyword arguments (such as workflow name) forwarded to the constructor :return: A new EO workflow instance :rtype: EOWorkflow def make_linear...
Executes the workflow. :param input_args: External input arguments to the workflow. They have to be in a form of a dictionary where each key is an EOTask used in the workflow and each value is a dictionary or a tuple of arguments. :type input_args: dict(EOTask: dict(str: object) or tupl...
Parses EOWorkflow input arguments provided by user and raises an error if something is wrong. This is done automatically in the process of workflow execution def parse_input_args(input_args): """ Parses EOWorkflow input arguments provided by user and raises an error if something is wrong. This is ...
Executes tasks comprising the workflow in the predetermined order. :param input_args: External input arguments to the workflow. :type input_args: Dict :param out_degs: Dictionary mapping vertices (task IDs) to their out-degrees. (The out-degree equals the number of tasks that depen...
Executes a task of the workflow. :param dependency: A workflow dependency :type dependency: Dependency :param input_args: External task parameters. :type input_args: dict :param intermediate_results: The dictionary containing intermediate results, including the results of ...
Relaxes dependencies incurred by ``task_id``. After the task with ID ``task_id`` has been successfully executed, all the tasks it depended on are upadted. If ``task_id`` was the last remaining dependency of a task ``t`` then ``t``'s result is removed from memory and, depending on ``remove_intermediate...
Returns an ordered dictionary {task_name: task} of all tasks within this workflow. :return: Ordered dictionary with key being task_name (str) and an instance of a corresponding task from this workflow :rtype: OrderedDict def get_tasks(self): """Returns an ordered dictionary {task_...
Generates the DOT description of the underlying computational graph. :return: The DOT representation of the computational graph :rtype: Digraph def get_dot(self): """Generates the DOT description of the underlying computational graph. :return: The DOT representation of the compu...
Creates mapping between Dependency classes and names used in DOT graph def _get_dep_to_dot_name_mapping(dependencies): """ Creates mapping between Dependency classes and names used in DOT graph """ dot_name_to_deps = {} for dep in dependencies: dot_name = dep.name ...