-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from OpenMined/madhava/syftignore
Added support for .syftignore files (simple prefix matching)
- Loading branch information
Showing
6 changed files
with
291 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import json | ||
import os | ||
|
||
from syftbox.lib import ClientConfig | ||
|
||
config_path = os.environ.get("SYFTBOX_CLIENT_CONFIG_PATH", None) | ||
client_config = ClientConfig.load(config_path) | ||
|
||
input_folder = ( | ||
f"{client_config.sync_folder}/{client_config.email}/app_pipelines/adder/inputs/" | ||
) | ||
output_folder = ( | ||
f"{client_config.sync_folder}/{client_config.email}/app_pipelines/adder/done/" | ||
) | ||
os.makedirs(input_folder, exist_ok=True) | ||
os.makedirs(output_folder, exist_ok=True) | ||
|
||
input_file_path = f"{input_folder}data.json" | ||
output_file_path = f"{output_folder}data.json" | ||
|
||
if os.path.exists(input_file_path): | ||
with open(input_file_path, "r") as f: | ||
data = json.load(f) | ||
|
||
data["datum"] += 1 | ||
|
||
with open(output_file_path, "w") as f: | ||
json.dump(data, f) | ||
|
||
os.remove(input_file_path) | ||
else: | ||
print(f"Input file {input_file_path} does not exist.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import json | ||
import os | ||
from datetime import datetime | ||
|
||
from syftbox.lib import ClientConfig | ||
|
||
|
||
def main(): | ||
# Load the client configuration | ||
config_path = os.environ.get("SYFTBOX_CLIENT_CONFIG_PATH", None) | ||
client_config = ClientConfig.load(config_path) | ||
|
||
# Get the current timestamp | ||
current_timestamp = datetime.now().isoformat() | ||
|
||
# Prepare the data to be written | ||
timestamp_data = {"last_check_in": current_timestamp} | ||
|
||
# Prepare output folders | ||
output_folder = f"{client_config.sync_folder}/{client_config.email}/app_pipelines/timestamp_recorder/" | ||
os.makedirs(output_folder, exist_ok=True) | ||
|
||
# Write timestamp to output file | ||
output_file_path = f"{output_folder}last_check_in.json" | ||
with open(output_file_path, "w") as f: | ||
json.dump(timestamp_data, f, indent=2) | ||
|
||
# Write _.syftperm file | ||
syftperm_data = { | ||
"admin": [client_config.email], | ||
"read": ["GLOBAL"], | ||
"write": [client_config.email], | ||
"filepath": f"{output_folder}_.syftperm", | ||
"terminal": False, | ||
} | ||
syftperm_path = f"{output_folder}_.syftperm" | ||
with open(syftperm_path, "w") as f: | ||
json.dump(syftperm_data, f, indent=2) | ||
|
||
print(f"Timestamp has been written to {output_file_path}") | ||
print(f"_.syftperm file has been written to {syftperm_path}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.