Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
miloswrath committed Sep 23, 2024
1 parent 1dc1d64 commit 9fa7cf6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 28 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ jobs:
# Get the list of CSV files changed in the last 24 hours
data=$(git log --since="24 hours ago" --name-only --pretty=format: -- '*.csv' | sort | uniq)
# Export the data variable to the environment
echo "data=$data" >> $GITHUB_ENV
# Convert the list into a multi-line format
formatted_data=$(echo "$data" | tr ' ' '\n')
# Export the formatted data variable to the environment
echo "data<<EOF" >> $GITHUB_ENV
echo "$formatted_data" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Print the changed CSV files
echo "Changed CSV files in the last 24 hours: $data"
echo "Changed CSV files in the last 24 hours:"
echo "$formatted_data"
- name: Install Python Dependencies
Expand Down
67 changes: 42 additions & 25 deletions jatosAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@

# jap_5ThOJ14yf7z1EPEUpAoZYMWoETZcmJk305719

def get_met():
tease = os.getenv['TEASE']
def parse_cmd():
#parse command line for TEASE var
import argparse
parser = argparse.ArgumentParser(description='API File to Pull Subject Data from Jatos')
parser.add_argument('-t', type=str, help='TEASE')
parser.add_argument('-a', type=str, help="toke")
return parser.parse_args()



def get_met(tease):


proxies = {
'http': f'http:zjgilliam:{tease}//proxy.divms.uiowa.edu:8888',
'https': f'https://zjgilliam:{tease}proxy.divms.uiowa.edu:8888',
'http': f'http:zjgilliam:{tease}@proxy.divms.uiowa.edu:8888',
'https': f'http://zjgilliam:{tease}@proxy.divms.uiowa.edu:8888',
}


Expand Down Expand Up @@ -62,13 +72,14 @@ def get_met():

return study_result_ids

def get_data(study_result_ids):
def get_data(study_result_ids, tease):


tease = os.getenv['TEASE']


proxies = {
'http': f'http:zjgilliam:{tease}//proxy.divms.uiowa.edu:8888',
'https': f'https://zjgilliam:{tease}proxy.divms.uiowa.edu:8888',
'http': f'http:zjgilliam:{tease}@proxy.divms.uiowa.edu:8888',
'https': f'http://zjgilliam:{tease}@proxy.divms.uiowa.edu:8888',
}


Expand Down Expand Up @@ -184,7 +195,6 @@ def convert_beh():

return paths


def move_txt(txt_files):
dic = {}
for file_path in txt_files:
Expand All @@ -200,43 +210,50 @@ def move_txt(txt_files):
print(sub)
target_dir = f'./data/{sub}/raw'
os.makedirs(target_dir, exist_ok=True)
# Save the DataFrame to a CSV file in the target directory
# Save the DataFrame to a text file in the target directory
output_file = os.path.join(target_dir, os.path.basename(file_path))
# save df as a txt file to target dir
with open(output_file, 'w') as f:
f.write(df.to_string(index=False))
print(f"Saved {output_file} to {target_dir}")
os.remove(file_path)
print(f"Removed {file_path}")
# remove any dirs in data/raw
for root, dirs, files in os.walk('./data/raw'):
for d in dirs:
shutil.rmtree(os.path.join(root, d))

return None
# Move the directory removal outside the loop
for root, dirs, files in os.walk('./data/raw'):
for d in dirs:
shutil.rmtree(os.path.join(root, d))
# Optionally, remove the raw directory itself
os.rmdir('./data/raw')

return None



def push():
subprocess.run(["git","remote", "set-url", "https://github.com/HBClab/boost-beh-AF.git"])
subprocess.run(["git", "add", "-A"])
subprocess.run(["git", "commit", "-m", "auto commit -> added subject task data"])
subprocess.run(["git", "push"])
def push(toke):
#use the folder name as task
task = os.path.basename(os.getcwd())

subprocess.run(['git', 'config', 'user.email', '[email protected]'])
subprocess.run(['git', 'remote', 'set-url', 'origin', f'https://miloswrath:{toke}@github.com/HBClab/{task}'])
subprocess.run(['git', 'config', 'user.name', 'miloswrath'])
subprocess.run(['git', 'add', '.'])
subprocess.run(['git', 'commit', '-m', 'Automated Commit -> New Data'])
subprocess.run(['git', 'push', 'origin', 'main'])

def main():
study_result_ids = get_met()
get_data(study_result_ids)
args = parse_cmd()
tease = args.t
toke = args.a
study_result_ids = get_met(tease)
get_data(study_result_ids, tease)
convert_beh()
txt_files = []
for root, dirs, files in os.walk('./data/raw'):
for file in files:
if file.endswith(".txt"):
txt_files.append(os.path.join(root, file))
move_txt(txt_files)
push()

push(toke)



Expand Down
16 changes: 16 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
contourpy==1.2.1
cycler==0.12.1
fonttools==4.53.1
fuzzywuzzy==0.18.0
kiwisolver==1.4.5
matplotlib==3.9.2
numpy==2.0.1
packaging==24.1
pandas==2.2.2
pillow==10.4.0
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytz==2024.1
seaborn==0.13.2
six==1.16.0
tzdata==2024.1

0 comments on commit 9fa7cf6

Please sign in to comment.