MCPcopy Create free account
hub / github.com/Pometry/Raphtory / load_nodes

Method load_nodes

raphtory/src/python/graph/graph.rs:751–848  ·  view source on GitHub ↗
(
        &self,
        data: &Bound<PyAny>,
        time: &str,
        id: &str,
        node_type: Option<&str>,
        node_type_col: Option<&str>,
        properties: Option<Vec<PyBackedStr>>,

Source from the content-addressed store, hash-verified

749 signature = (data, time, id, node_type = None, node_type_col = None, properties = None, metadata= None, shared_metadata = None, schema = None, csv_options = None, event_id = None, layer = None, layer_col = None)
750 )]
751 fn load_nodes(
752 &self,
753 data: &Bound<PyAny>,
754 time: &str,
755 id: &str,
756 node_type: Option<&str>,
757 node_type_col: Option<&str>,
758 properties: Option<Vec<PyBackedStr>>,
759 metadata: Option<Vec<PyBackedStr>>,
760 shared_metadata: Option<HashMap<String, Prop>>,
761 schema: Option<Bound<PyAny>>,
762 csv_options: Option<CsvReadOptions>,
763 event_id: Option<&str>,
764 layer: Option<&str>,
765 layer_col: Option<&str>,
766 ) -> Result<(), GraphError> {
767 let properties = convert_py_prop_args(properties.as_deref()).unwrap_or_default();
768 let metadata = convert_py_prop_args(metadata.as_deref()).unwrap_or_default();
769 let column_schema = convert_py_schema(schema)?;
770 if data.hasattr("__arrow_c_stream__")? {
771 load_nodes_from_arrow_c_stream(
772 &self.graph,
773 data,
774 time,
775 id,
776 node_type,
777 node_type_col,
778 &properties,
779 &metadata,
780 shared_metadata.as_ref(),
781 layer,
782 layer_col,
783 column_schema,
784 event_id,
785 )
786 } else if let Ok(path) = data.extract::<PathBuf>() {
787 // extracting PathBuf handles Strings too
788 let is_parquet = is_parquet_path(&path)?;
789 let is_csv = is_csv_path(&path)?;
790
791 // fail before loading anything at all to avoid loading partial data
792 if !is_csv && csv_options.is_some() {
793 return Err(GraphError::from(PyValueError::new_err(format!(
794 "CSV options were passed but no CSV files were detected at {}.",
795 path.display()
796 ))));
797 }
798
799 // wrap in Arc to avoid cloning the entire schema for Parquet, CSV, and inner loops in CSV path
800 let arced_schema = column_schema.map(Arc::new);
801
802 // if-if instead of if-else to support directories with mixed parquet and CSV files
803 if is_parquet {
804 load_nodes_from_parquet(
805 &self.graph,
806 path.as_path(),
807 time,
808 event_id,

Calls 12

convert_py_prop_argsFunction · 0.85
convert_py_schemaFunction · 0.85
is_parquet_pathFunction · 0.85
is_csv_pathFunction · 0.85
ErrEnum · 0.85
load_nodes_from_parquetFunction · 0.85
load_nodes_from_csv_pathFunction · 0.85
as_refMethod · 0.45
is_someMethod · 0.45
mapMethod · 0.45
cloneMethod · 0.45