Module pyfx.api.domain
High-level API for Pyfx domain objects.
Note that, unless explicitely noted, creating or modifying an object from this package will not update the corresponding platform entity.
Classes
class AbstractTable (conn: Connection, typedid: str, unique_name: Optional[str] = None, label: Optional[str] = None, created_by: Optional[int] = None, created_date: Optional[str] = None, last_update_by: Optional[int] = None, last_update_date: Optional[str] = None)-
Base class for all table types.
Get the representation corresponding to a pricefx Entity.
Ancestors
- BasicEntity
- IdentifiableEntity
- abc.ABC
Subclasses
Methods
def stream(self, chunk_size: int = 128) ‑> Iterator[bytes]-
Stream the content of this table.
def to_file(self, file_path: str) ‑> None-
Write table content to file.
Content will be written in CSV format.
def to_pandas(self, **args: Dict[str, Any]) ‑> pandas.core.frame.DataFrame-
Get a
pd.DataFramewith the table content.
class Attachment (conn: Connection, owner: IdentifiableEntity, typedid: str, name: str, created_by: int, created_date: str, last_update_by: int, last_update_date: str, content_type: str, length: int)-
Representation of an Attachment.
Create the representation of an Attachment.
Ancestors
- BasicEntity
- IdentifiableEntity
- Owned
- abc.ABC
Static methods
def from_dict(conn: Connection, owner: IdentifiableEntity, attrs: Dict[str, Any]) ‑> Attachment-
Create an attachment from a dict of properties.
Methods
def download_file(self, chunk_size: int = 128) ‑> Iterator[bytes]-
Download an attachment.
Args
chunk_size- size of chunks in each iteration (Default: 128)
Inherited members
class Attachments (conn: Connection, owner: IdentifiableEntity)-
Attachments of an entity.
Create the repesentation of an Owned entity.
Args
conn- the underlying connection
owner- the owner
Ancestors
- Owned
- ItemCollection
- abc.ABC
- typing.Generic
Methods
def get(self, typedid: str) ‑> Attachment-
Get the attachment with the given typedid.
def push(self, name: str, content:) ‑> None -
Attach new content to owner on the platform.
Args
name- name of the attachment
content- content of the attachment
Inherited members
class BasicEntity (conn: Connection, typedid: str, unique_name: Optional[str] = None, label: Optional[str] = None, created_by: Optional[int] = None, created_date: Optional[str] = None, last_update_by: Optional[int] = None, last_update_date: Optional[str] = None)-
Common representation of a lot of entities.
Get the representation corresponding to a pricefx Entity.
Ancestors
- IdentifiableEntity
- abc.ABC
Subclasses
class CalculationItem (conn: Connection, owner: IdentifiableEntity, typedid: str, key1: str, key2: str, value: Optional[str], status: Optional[str], created_by: int, created_date: str, last_update_by: int, last_update_date: str)-
Representation of a CalculationItem.
Create the representation of a Calculation Item.
Ancestors
- IdentifiableEntity
- Owned
- abc.ABC
Static methods
def from_dict(conn: Connection, owner: IdentifiableEntity, attrs: Dict[str, Any]) ‑> CalculationItem-
Create an attachment from a dict of properties.
Inherited members
class CalculationItems (conn: Connection, owner: IdentifiableEntity, typedid: str)-
Calculations items of an entity.
Create the repesentation of an identifiable entity.
Args
conn- the underlying connection
typedid- the typedId of the entity
Ancestors
- IdentifiableEntity
- Owned
- abc.ABC
Methods
def push(self, key1: str, key2: str, value: Any) ‑> None-
Add a new calculation item.
Inherited members
class DMModel (conn: Connection, typedid: str, unique_name: Optional[str] = None, label: Optional[str] = None, created_by: Optional[int] = None, created_date: Optional[str] = None, last_update_by: Optional[int] = None, last_update_date: Optional[str] = None, model_type: Optional[ModelType] = None, calcitems_table_id: Optional[str] = None)-
A DM model.
Get the representation corresponding to a DM Model.
Ancestors
- Model
- BasicEntity
- IdentifiableEntity
- abc.ABC
Static methods
def from_conn(conn: Connection, model_typedid: str) ‑> DMModel-
Create a model from a model typedid.
def from_dict(conn: Connection, attrs: Dict[str, Any]) ‑> DMModel-
Create a model from a dict of properties.
Methods
def calculation_items(self) ‑> Optional[CalculationItems]-
Get the calculation items of the model.
Inherited members
class DMModels (conn: Connection)-
The DataMart Models.
Ancestors
- ItemCollection
- abc.ABC
- typing.Generic
Methods
def get(self, typedid: str) ‑> DMModel-
Get the DM model with the given typedid.
Inherited members
class DataSources (conn: Connection)-
The data sources.
Ancestors
- TableMutableSource
- TableSource
- ItemCollection
- abc.ABC
- typing.Generic
Inherited members
class Datamarts (conn: Connection)-
The datamarts.
Ancestors
- TableImmutableSource
- TableSource
- ItemCollection
- abc.ABC
- typing.Generic
Inherited members
class IdentifiableEntity (conn: Connection, typedid: str)-
An entity with an uniquer identifiant.
Create the repesentation of an identifiable entity.
Args
conn- the underlying connection
typedid- the typedId of the entity
Ancestors
- abc.ABC
Subclasses
class Instance (conn: Connection)-
A platform instance.
Static methods
def connect(domain: str, partition: str, account: str) ‑> Instance-
Return an Instance object connecting to a specific instance.
Methods
def datamarts(self) ‑> Datamarts-
Get the data sources stored on the instance.
def datasources(self) ‑> DataSources-
Get the data sources stored on the instance.
def model_objects(self) ‑> ModelObjects-
Get the model objects stored on the instance.
def models(self) ‑> DMModels-
Get the models stored on the instance.
class ItemCollection-
Common interface for all item collections.
Items can either be retrieved:
- as from a list, getting an item by its index, e.g. collection[0],
- as from a dict, getting an item by its name, e.g. collection["somename"].
The second method is equivalent to calling
get_by_nameon the collection.Ancestors
- abc.ABC
- typing.Generic
Subclasses
Methods
def get(self, typedid: str) ‑> ~Item-
Get the item with the given typedid.
def get_by_name(self, name: str) ‑> Optional[~Item]-
Get an item by name.
Returns
the item with the given name, or None if no such item exists.
class Model (conn: Connection, typedid: str, unique_name: Optional[str] = None, label: Optional[str] = None, created_by: Optional[int] = None, created_date: Optional[str] = None, last_update_by: Optional[int] = None, last_update_date: Optional[str] = None)-
Model abstract interface.
Get the representation corresponding to a pricefx Entity.
Ancestors
- BasicEntity
- IdentifiableEntity
- abc.ABC
Subclasses
Methods
def attachments(self) ‑> Attachments-
Get the model attachments.
def tables(self) ‑> ModelTables-
Get the tables owned by the model.
class ModelObject (conn: Connection, typedid: str, unique_name: Optional[str] = None, label: Optional[str] = None, created_by: Optional[int] = None, created_date: Optional[str] = None, last_update_by: Optional[int] = None, last_update_date: Optional[str] = None, model_class: Optional[str] = None)-
A Model Object.
Get the representation corresponding to a ModelObject.
Ancestors
- Model
- BasicEntity
- IdentifiableEntity
- abc.ABC
Static methods
def from_conn(conn: Connection, model_typedid: str) ‑> ModelObject-
Create a model from a model typedid.
def from_dict(conn: Connection, attrs: Dict[str, Any]) ‑> ModelObject-
Create a model from a dict of properties.
Inherited members
class ModelObjects (conn: Connection)-
The Models Objects.
Ancestors
- ItemCollection
- abc.ABC
- typing.Generic
Methods
def get(self, typedid: str) ‑> ModelObject-
Get the model object with the given id.
Inherited members
class ModelTables (conn: Connection, owner: IdentifiableEntity)-
Tables owned by a model.
Ancestors
- TableMutableSource
- TableSource
- ItemCollection
- Owned
- abc.ABC
- typing.Generic
Inherited members
class ModelType (conn: Connection, typedid: str, unique_name: str, label: Optional[str], created_by: int, created_date: str, last_update_by: int, last_update_date: str, nature: str, definition: str)-
A Model Type.
Get the representation corresponding to a Model Type.
Ancestors
- BasicEntity
- IdentifiableEntity
- abc.ABC
Static methods
def from_dict(conn: Connection, attrs: Dict[str, Any]) ‑> ModelType-
Create a model type from a dict of properties.
class Owned (conn: Connection, owner: IdentifiableEntity)-
Something owned by an
IdentifiableEntity.Create the repesentation of an Owned entity.
Args
conn- the underlying connection
owner- the owner
Ancestors
- abc.ABC
Subclasses
Methods
def owner(self) ‑> IdentifiableEntity-
Get entity owner.
class PlatformJob (conn: Connection, jst_id: int)-
A Job executed on the platform.
Get the representation corresponding to a running job.
Args
conn- the underlying connection
jst_id- the jst id of the Job
Methods
def set_results(self, results: Dict[str, Any]) ‑> None-
Set the job results.
def update_progress(self, progress: Optional[int], msg: Optional[str] = None) ‑> None-
Update job status progress.
def update_status(self, progress: Optional[int] = None, msg: Optional[str] = None, results: Optional[Dict[str, Any]] = None) ‑> None-
Update the job status on the platform.
Args
progress- the new job progress percent (optional)
msg- a message for the new status change (optional)
results- a dictionary associating result names to their value (optional). Will be available to next evaluations and calculations.
class TableImmutable (conn: Connection, typedid: str, unique_name: Optional[str] = None, name: Optional[str] = None, label: Optional[str] = None, created_by: Optional[int] = None, created_date: Optional[str] = None, last_update_by: Optional[int] = None, last_update_date: Optional[str] = None)-
Representation of a data Table.
Get the representation corresponding to a Model Type.
Ancestors
Static methods
def from_dict(conn: Connection, attrs: Dict[str, Any]) ‑> TableImmutable-
Create a table from a dict of properties.
Inherited members
class TableImmutableSource (conn: Connection, type_code: str, req_params: Optional[Dict[str, Any]] = None)-
Collection of immutable tables.
Ancestors
- TableSource
- ItemCollection
- abc.ABC
- typing.Generic
Subclasses
Inherited members
class TableMutable (conn: Connection, typedid: str, unique_name: Optional[str] = None, name: Optional[str] = None, label: Optional[str] = None, created_by: Optional[int] = None, created_date: Optional[str] = None, last_update_by: Optional[int] = None, last_update_date: Optional[str] = None)-
Representation of a mutable data Table.
Get the representation corresponding to a Model Type.
Ancestors
Static methods
def from_dict(conn: Connection, attrs: Dict[str, Any]) ‑> TableMutable-
Create a table from a dict of properties.
Methods
def update(self, data: AvroStream) ‑> None-
Update data the table.
Values of rows with same keys will be updated. Rows with new keys will be appended.
data: content to update in avro format.
def update_pandas(self, dataframe: pandas.core.frame.DataFrame, on_unsupported_type: str = 'error', inplace: bool = False) ‑> None-
Update this table from a dataframe.
Values of rows with same index will be updated. Rows with new index will be appended.
Args
dataframe- the dataframe to push
on_unsupported_type- define the behavior when encontering a dataframe column containing an incompatible type (optional, default: "error"):
- "error" (default value) raises an error
- "drop" will drop the column
- "coerce" will try to convert this column to strings
inplace- do the required data prep operations in place (will mutate the source dataframe ; optional, default: False)
Inherited members
class TableMutableSource (conn: Connection, type_code: str, req_params: Optional[Dict[str, Any]] = None)-
Collection of mutable tables.
Ancestors
- TableSource
- ItemCollection
- abc.ABC
- typing.Generic
Subclasses
Methods
def push(self, name: str, fields_spec: List[Dict], content: AvroStream, label: Optional[str] = None, replace_existing: bool = True) ‑> None-
Add a new table to the collection of tables on the platform.
Args
name- the name of the new table
fields_spec- a list of dictionaries that describe the columns of the table
[ { name:"productId", label:"Product ID", type:"TEXT", key:true}, { name:"productGroup", label:"ProductGroup", type:"TEXT", dimension:true}, { name:"revenue", label:"Revenue", type:"MONEY"}, ]content- the content of the new table
label- the label of the new table (optional, defaults to name)
replace_existing- if True then removes the preceding table having the same name if it exists before pushing the data (default = True).
def push_pandas(self, table_name: str, dataframe: pandas.core.frame.DataFrame, table_label: Optional[str] = None, dimensions: Optional[List[str]] = None, on_unsupported_type: str = 'error', replace_existing: bool = True, inplace: bool = False, column_labels: Optional[Dict[str, str]] = None) ‑> None-
Push a pandas dataframe as a new table.
Dataframe index will be used as key columns.
Args
table_name- the name to use for the new table
dataframe- the dataframe to push
table_label- the label for the new table (optional, defaults to name)
dimensions- columns that should be used as dimension (optional, default: None)
on_unsupported_type- define the behavior when encontering a dataframe column containing an incompatible type (optional, default: "error"):
- "error" (default value) raises an error
- "drop" will drop the column
- "coerce" will try to convert this column to strings
replace_existing- if True then removes the preceding table having the same name if it exists before pushing the data (optional, default = True).
inplace- do the required data prep operations in place (will mutate the source dataframe ; optional, default: False)
column_labels- a dictionary associating dataframe column (including index) name to its desired label (optional, default: None).
Inherited members
class TableSource (conn: Connection, type_code: str, req_params: Optional[Dict[str, Any]] = None)-
Base class for all collections of tables.
Ancestors
- ItemCollection
- abc.ABC
- typing.Generic
Subclasses
Methods
def get(self, typedid: str) ‑> ~TableType-
Get the table with the given typedid.
Inherited members