-
Notifications
You must be signed in to change notification settings - Fork 0
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 #5 from dirac-institute/awo/parsl-poc
Lots of tweaks, pushing toward a final POC.
- Loading branch information
Showing
9 changed files
with
157 additions
and
23 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
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
File renamed without changes.
File renamed without changes.
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,44 @@ | ||
import os | ||
import glob | ||
from kbmod import ImageCollection | ||
|
||
|
||
def uri_to_ic(target_uris_file=None, uris_base_dir=None, ic_output_file=None, logger=None): | ||
# Load the list of images from our saved file "sample_uris.txt" | ||
uris = [] | ||
with open(target_uris_file) as f: | ||
for l in f.readlines(): | ||
l = l.strip() # seeing invisible trailing characters 6/12/2024 COC | ||
if l == "": | ||
continue # skip blank lines 6/12/2024 COC | ||
if not l.startswith("#"): | ||
# Ignore commented metadata | ||
uris.append(l) | ||
|
||
if uris_base_dir is not None: | ||
logger.debug(f"Using URIs base dir: {uris_base_dir}") | ||
if not os.path.isdir(uris_base_dir): | ||
logger.error(f"Invalid URIS base directory provided: {uris_base_dir}") | ||
raise ValueError(f"Invalid URIS base directory provided: {uris_base_dir}") | ||
|
||
# Clean up the URI strings | ||
for i in range(len(uris)): | ||
file_prefix = "file://" | ||
curr = uris[i].replace("%23", "#").strip() | ||
if curr.startswith(file_prefix): | ||
curr = curr[len(file_prefix) :] | ||
if uris_base_dir is not None: | ||
curr = os.path.join(uris_base_dir, curr.lstrip(os.path.sep)) | ||
uris[i] = curr | ||
|
||
# Make sure the files can all be found 6/12/2024 COC | ||
for uri in uris: | ||
if len(glob.glob(uri)) == 0: | ||
raise FileNotFoundError(f"Could not find {uri}.") | ||
|
||
logger.info("Creating ImageCollection") | ||
# Create an ImageCollection object from the list of URIs | ||
ic = ImageCollection.fromTargets(uris) | ||
logger.info("ImageCollection created") | ||
|
||
ic.write(ic_output_file, format="ascii.ecsv") |
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
import platform | ||
from typing import Literal | ||
|
||
from kbmod_wf.configurations import * | ||
|
||
|
||
def get_config(env: Literal["dev", "klone"] | None = None): | ||
"""A naive attempt to return a reasonable configuration using platform.system. | ||
This will likely be insufficient in a very short amount of time, but this | ||
is meant to be a first step. | ||
Parameters | ||
---------- | ||
env : Literal["dev", "klone"] | None, optional | ||
The common name used to retrieve the given configuration, by default None. | ||
If none, the configuration will be determined by the platform.system(). | ||
Returns | ||
------- | ||
parls.config.Config | ||
The configuration object to be used by the parsl.load() function. | ||
Raises | ||
------ | ||
ValueError | ||
If an unknown environment is provided, raise a ValueError. | ||
""" | ||
|
||
if env is None: | ||
if platform.system().lower() == "darwin": | ||
config = dev_config() | ||
else: | ||
config = klone_config() | ||
elif env == "dev": | ||
config = dev_config() | ||
elif env == "klone": | ||
config = klone_config() | ||
else: | ||
raise ValueError(f"Unknown environment: {env}") | ||
|
||
return config |
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,21 @@ | ||
from kbmod_wf.utilities.configuration_utilities import get_config | ||
|
||
|
||
def get_executors(possible_executors=[]): | ||
"""Get the list of executors that are available on the system. | ||
Parameters | ||
---------- | ||
possible_executors : List[str] | ||
A list of possible executors that can be used. | ||
Returns | ||
------- | ||
List[str] | ||
A list of executors that are available on the system. | ||
""" | ||
|
||
config = get_config() | ||
available_executors = [e.label for e in config.executors] | ||
|
||
return [executor for executor in possible_executors if executor in available_executors] |
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