Skip to content

Commit

Permalink
Merge pull request #13 from madhavajay/madhava/flow
Browse files Browse the repository at this point in the history
Added to_flow capability for Code
  • Loading branch information
madhavajay authored Sep 18, 2024
2 parents bc9c247 + 8306fb9 commit 77b54a8
Show file tree
Hide file tree
Showing 7 changed files with 437 additions and 45 deletions.
2 changes: 2 additions & 0 deletions me.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
uv run syftbox/client/client.py --config_path=./users/me.json --sync_folder=./users/me [email protected] --port=8085 --server=http://localhost:5001
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies = [
"markdown>=3.7",
"pandas>=2.2.2",
"setuptools>=75.1.0",
"postmarker>=1.0",
]

[build-system]
Expand Down
21 changes: 12 additions & 9 deletions syftbox/client/plugins/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
)

CLIENT_CHANGELOG_FOLDER = "syft_changelog"
IGNORE_FOLDERS = [CLIENT_CHANGELOG_FOLDER]
STAGING = "staging"
IGNORE_FOLDERS = [CLIENT_CHANGELOG_FOLDER, STAGING]


# write operations
Expand Down Expand Up @@ -125,8 +126,9 @@ def filter_changes(
valid_changes.append(change)
valid_change_files.append(change.sub_path)
continue
# todo we need to handle this properly
if perm_file_at_path.read == [user_email]:
if change.internal_path[-10:] == "_.syftperm":
if change.internal_path.endswith("_.syftperm"):
# include changes for syft_perm file even if only we have read perms.
valid_changes.append(change)
valid_change_files.append(change.sub_path)
Expand Down Expand Up @@ -192,9 +194,9 @@ def pull_changes(client_config, changes):
data = None

if response.status_code == 200:
print(
f"> {client_config.email} /read {change.kind} {change.internal_path}",
)
# print(
# f"> {client_config.email} /read {change.kind} {change.internal_path}",
# )
remote_changes.append((ok_change, data))
else:
print(
Expand Down Expand Up @@ -259,7 +261,7 @@ def ascii_for_change(changes) -> str:
pipe = "├──"
if count == len(changes):
pipe = "└──"
change_text += pipe + change
change_text += pipe + change + "\n"
return change_text


Expand Down Expand Up @@ -308,6 +310,7 @@ def sync_up(client_config):

# send val changes
results = push_changes(client_config, val)

deleted_files = []
changed_files = []
for result in results:
Expand All @@ -320,10 +323,12 @@ def sync_up(client_config):

# combine successful changes qwith old dir state
combined_tree = old_dir_state.tree

# add new successful changes
combined_tree.update(synced_dir_state.tree)
synced_dir_state.tree = combined_tree

synced_dir_state = delete_files(new_dir_state, deleted_files)
synced_dir_state = delete_files(synced_dir_state, deleted_files)

change_text = ""
if len(changed_files):
Expand All @@ -334,8 +339,6 @@ def sync_up(client_config):
change_text += f"❌ Syncing Up {len(deleted_files)} Deletes\n"
change_text += ascii_for_change(deleted_files)

print(change_text)

synced_dir_state.save(dir_filename)
n_changes += len(changed_files) + len(deleted_files)

Expand Down
Loading

0 comments on commit 77b54a8

Please sign in to comment.