Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable validation checker as an option and refactor as separate file and function. #15

Open
jameshalgren opened this issue Oct 19, 2023 · 0 comments
Assignees

Comments

@jameshalgren
Copy link
Member

jameshalgren commented Oct 19, 2023

This is a proposal to move the validation checking capability to a separate file. Moving this to a separate file would reduce the tqdm dependency, which is only needed if validation is requested.

A use case we might want to support is providing an externally generated list of files to this utility to check if the URLs have downloadable endpoints.

from tqdm import tqdm
# def check_valid_urls(file_list, session=None):
# """if not session:
# session = requests.Session()"""
# t = tqdm(range(len(file_list)))
# check_url_part = partial(check_url, t)
# """with ThreadPoolExecutor(max_workers=10) as executor:
# valid_file_list = list(executor.map(check_url_part, file_list))"""
# valid_file_list = [gevent.spawn(check_url_part, file_name) for file_name in file_list]
# gevent.joinall(valid_file_list)
# return [file.get() for file in valid_file_list if file.get() is not None]
# def check_url(t, file):
# filename = file.split("/")[-1]
# try:
# with requests.head(file) as response:
# if response.status_code == 200:
# t.set_description(f"Found: {filename}")
# t.update(1)
# t.refresh()
# return file
# else:
# t.set_description(f"Not Found: {filename}")
# t.update(1)
# t.refresh()
# return None
# #response = session.head(file, timeout=1)
# except requests.exceptions.RequestException:
# t.set_description(f"Not Found: {filename}")
# t.update(1)
# t.refresh()
# return None

@jameshalgren jameshalgren changed the title Move this validation checker to a separate file or an internal function name Re-enable validation checker as an option and refactor as separate file. Oct 19, 2023
@jameshalgren jameshalgren changed the title Re-enable validation checker as an option and refactor as separate file. Re-enable validation checker as an option and refactor as separate file and function. Oct 19, 2023
sepehrkrz added a commit that referenced this issue Oct 31, 2023
Update python-publish.yml updated token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants