Skip to content

Commit

Permalink
comments to explain
Browse files Browse the repository at this point in the history
  • Loading branch information
tcnichol committed Nov 22, 2021
1 parent 1366e74 commit 1dee7bc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
24 changes: 20 additions & 4 deletions clowder/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@

import pyclowder.datasets


def find_dataset_in_collection(dataset_name, collection_name):

dataset_found = None

url = sys.argv[1]
userkey = sys.argv[2]
client = pyclowder.datasets.ClowderClient(host=url, key=userkey)

collection_results = client.get('/search',params={'query':collection_name,'resource_type':'colllection'})
if len(collection_results) > 0:
result = collection_results[0]
collection_datasets = client.get('/collections/'+result['id']+'/datasets')

for ds in collection_datasets:
if ds['name'] == dataset_name:
dataset_found = ds
return ds


def main():
url = sys.argv[1]
userkey = sys.argv[2]
Expand All @@ -22,8 +42,4 @@ def main():
print('got all spaces')

if __name__ == '__main__':
try:
local()
except:
pass
main()
24 changes: 23 additions & 1 deletion industry/process.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import json
import datetime
import dateutil.parser
import pyclowder
import pyclowder.datasets

clowder_url = 'https://pdg.clowderframework.org/'

user_api = 'b81d4590-cd89-416e-8ee4-d0dade8b0c95'

file_id = '6192cf36e4b0e1bb77ac6b7a'

client = pyclowder.datasets.ClowderClient(host=clowder_url, key=user_api)

def post_metadata_file():
try:
with open('61775e9cb84813122064b444.json', 'r') as f:
md = json.load(f)

result = client.post('/files/'+file_id+'/metadata', content=md, params=md)
print(result)
except Exception as e:
print(e)

def is_start_before_json(path_to_json, start):
span = get_timespan_json_file(path_to_json)
Expand Down Expand Up @@ -47,6 +67,8 @@ def get_entries_within_timestamp(start_time, end_time, path_to_json):
return results


post_metadata_file()

total_file = get_entire_json_file('61775e9cb84813122064b444.json')

time_stamps = get_timespan_json_file('61775e9cb84813122064b444.json')
Expand All @@ -68,7 +90,7 @@ def get_entries_within_timestamp(start_time, end_time, path_to_json):

# this check if the start or end times are BEFORE this particular json

is_earlier = is_start_before_json('61775e9cb84813122064b444.json', earlier_date)
is_earlier = is_start_before_json(path_to_json='61775e9cb84813122064b444.json', start=earlier_date)

is_later = is_end_after_json('61775e9cb84813122064b444.json', later_date)

Expand Down

0 comments on commit 1dee7bc

Please sign in to comment.