hsfs.core.sharepoint_sync #
SharePointSync #
A sync that copies a folder of a SharePoint document library into a dataset of the project.
The copy runs as an ordinary Python job, either once when started or on a cron schedule, with rsync semantics from SharePoint to Hopsworks. Create one with SharePointConnector.create_sync or SharePointConnector.copy_folder.
Every method that changes the sync needs the Data Owner role; reading its status and audit log needs project membership.
active_execution_id property #
active_execution_id: int | None
Execution that holds the sync's run claim, if a run is in progress.
alert_receiver property #
alert_receiver: str | None
Alert receiver notified when a run of the sync job fails or is killed.
audit_path property #
audit_path: str | None
Directory of the sync's audit log, with one date=YYYY-MM-DD partition per day of CSV files.
bytes_total property #
bytes_total: int | None
Size of the files in the dataset after the most recent run.
checksum_every property #
checksum_every: int | None
Number of runs between checksum runs when verify_checksums is off.
connector_name property #
connector_name: str | None
Name of the SharePoint data source the sync reads from.
cron_expression property #
cron_expression: str | None
Cron expression of the schedule, None for a copy-once sync.
dataset_id property #
dataset_id: int | None
Id of the synced dataset, None once it was deleted outside the sync.
dataset_name property #
dataset_name: str | None
Top-level dataset of the project the files are copied into, fixed at creation.
exclude_patterns property #
Filter patterns, in rclone syntax, of the files to skip.
files_total property #
files_total: int | None
Number of files in the dataset after the most recent run.
folder_item_id property #
folder_item_id: str | None
Graph id of the synced folder, empty for the library root.
folder_path property #
folder_path: str | None
Path of the synced folder inside the library, empty for the library root.
include_patterns property #
Filter patterns, in rclone syntax, of the files to copy; empty copies everything not excluded.
index_feature_group property #
index_feature_group: str | None
Name of the index feature group (version 1), or None when the sync does not index.
index_feature_group_id property #
index_feature_group_id: int | None
Id of the index feature group, or None until a run has created it.
index_files property #
index_files: bool | None
Whether each run indexes the dataset's files in a feature group.
job_name property #
job_name: str | None
Name of the Python job that runs the sync, sharepoint_<connector>_<dataset>.
last_audit_file property #
last_audit_file: str | None
Audit file written by the most recent run that changed files, relative to the project.
last_run_execution_id property #
last_run_execution_id: int | None
Execution of the most recent run that reported a result.
last_success property #
last_success: Any
End of the most recent run that copied everything without errors.
max_file_size_mb property #
max_file_size_mb: int | None
Files larger than this many MB are skipped; 0 copies files of any size.
mirror_deletions property #
mirror_deletions: bool | None
Whether files gone from SharePoint, or added in Hopsworks, are deleted from the dataset.
resync_requested_at property #
resync_requested_at: Any
When a full resync was requested that no run has done yet.
scheduled property #
scheduled: bool | None
Whether the sync has a schedule; a sync without one copies only when started.
transfers property #
transfers: int | None
Number of files downloaded in parallel; the cluster default when None.
verify_checksums property #
verify_checksums: bool | None
Whether every run compares file contents by checksum.
delete #
Delete the sync and its job.
With force, the backend stops a run in progress first; when that run does not stop in time the delete is left pending. A pending delete keeps the sync in state DELETING, and retry or another delete finishes it.
Deletes the synced dataset unless keep_files is set
Without keep_files, the dataset and the sync's audit log are deleted with every file in them, and so is the index feature group of a sync that indexes its files. Files are not recoverable from Hopsworks afterwards; only SharePoint still has them.
| PARAMETER | DESCRIPTION |
|---|---|
keep_files | Keep the dataset, the audit log and the index feature group; the audit log is then no longer rotated. TYPE: |
force | Stop a run in progress instead of refusing the delete. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If a run is in progress and |
force_full_resync #
Make the next run compare file contents by checksum, not only size and modification time.
A run normally detects a changed file by its size or modification time, so a file rewritten with the same size and time is only caught by a checksum run. The sync is reloaded afterwards, so resync_requested_at shows the pending request.
| PARAMETER | DESCRIPTION |
|---|---|
run | Start the run now; otherwise the next scheduled or manual run does the full comparison. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Execution | None | The started execution, or |
get_audit #
Return the paths changed by the runs of one day, as recorded in the audit log.
Runs that changed nothing write no audit rows. The backend keeps a cluster-wide number of days, 7 by default.
| PARAMETER | DESCRIPTION |
|---|---|
day | Day in UTC, as |
| RETURNS | DESCRIPTION |
|---|---|
list[dict[str, Any]] | One dict per changed path with |
get_index_feature_group #
get_index_feature_group() -> FeatureGroup | None
Get the feature group that indexes the sync's files.
It holds one row per file in the dataset: SharePoint id, path, link, type, size, times, authors, quickXorHash and path in HopsFS, partitioned by ingestion_date, the day the file was first indexed. The first run after indexing is turned on creates it.
| RETURNS | DESCRIPTION |
|---|---|
FeatureGroup | None | The index feature group, or |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If the sync does not index its files. |
pause #
pause() -> SharePointSync
Disable the schedule, keeping it so that resume restores it.
| RETURNS | DESCRIPTION |
|---|---|
SharePointSync | This sync, updated. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the sync has no schedule. |
refresh #
refresh() -> SharePointSync
Reload the sync from Hopsworks.
| RETURNS | DESCRIPTION |
|---|---|
SharePointSync | This sync, with its fields as the backend reports them now. |
resume #
resume() -> SharePointSync
Re-enable a paused schedule.
| RETURNS | DESCRIPTION |
|---|---|
SharePointSync | This sync, updated. |
| RAISES | DESCRIPTION |
|---|---|
hopsworks.client.exceptions.RestAPIError | If the sync has no schedule. |
retry #
retry() -> SharePointSync
Resume a sync left in CREATING or DELETING by a failed create or delete.
| RETURNS | DESCRIPTION |
|---|---|
SharePointSync | This sync, updated. |
run #
Start an execution of the sync job now, also while the sync is paused or has no schedule.
The execution runs as the caller, who must be a Data Owner. When a run of this sync is already in progress, the new execution finishes immediately without copying anything.
| RETURNS | DESCRIPTION |
|---|---|
Execution | Any | The started execution, or the backend's response when it does not describe one. |
set_folder #
set_folder(folder_path: str) -> SharePointSync
Point the sync at another folder of the same document library.
Under mirror semantics the next run deletes the files of the old folder from the dataset and copies the new one.
| PARAMETER | DESCRIPTION |
|---|---|
folder_path | Folder path inside the library, TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
SharePointSync | This sync, updated. |
set_schedule #
set_schedule(cron_expression: str | None) -> SharePointSync
Add, change or remove the schedule.
| PARAMETER | DESCRIPTION |
|---|---|
cron_expression | Quartz cron expression in UTC, with seconds first, e.g. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
SharePointSync | This sync, updated. |
status #
Reload the sync and return its run state and counters.
A run that ended without reporting a result, because its pod was killed or crashed, is reported as FAILED with last_error saying so.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any] |
|
update #
update(**fields: Any) -> SharePointSync
Change settings of the sync; they apply from the next run.
The keyword arguments are any of include_patterns, exclude_patterns, max_file_size_mb, mirror_deletions, verify_checksums, checksum_every, transfers, index_files, index_feature_group, cron_expression (None removes the schedule), folder_path and take_ownership. Fields not given keep their value. Under mirror semantics, files that a new filter or size cap excludes are deleted from the dataset on the next run. index_files=False stops indexing and keeps the feature group; a new index_feature_group starts a new one, which the next run fills with every copied file still in the folder. take_ownership=True re-creates the schedule as the caller, so scheduled runs run as the caller, which adopts a sync whose creator left the project.
| RETURNS | DESCRIPTION |
|---|---|
SharePointSync | This sync, updated. |
| RAISES | DESCRIPTION |
|---|---|
ValueError | If a field cannot be changed, such as |