Skip to content

Commit

Permalink
delete ol _workunit_definition.py
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Sep 11, 2024
1 parent a8ccf06 commit 2381dea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 121 deletions.
107 changes: 0 additions & 107 deletions bfabric/experimental/app_interface/_workunit_definition.py

This file was deleted.

28 changes: 14 additions & 14 deletions bfabric/wrapper_creator/bfabric_wrapper_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from bfabric import Bfabric
from bfabric.bfabric_legacy import bfabricEncoder
from bfabric.entities import Workunit, ExternalJob, Application, Resource, Storage, Order, Project
from bfabric.experimental.app_interface._workunit_definition import WorkunitDefinition
from bfabric.experimental.app_interface.workunit.definition import WorkunitDefinition
from bfabric.wrapper_creator.bfabric_external_job import BfabricExternalJob


Expand All @@ -24,7 +24,7 @@ def __init__(self, client: Bfabric, external_job_id: int) -> None:

@cached_property
def workunit_definition(self) -> WorkunitDefinition:
return WorkunitDefinition.from_external_job_id(client=self._client, external_job_id=self._external_job_id)
return WorkunitDefinition.from_workunit(self._external_job.workunit)

@cached_property
def _external_job(self) -> ExternalJob:
Expand Down Expand Up @@ -70,7 +70,7 @@ def create_log_resource(self, variant: Literal["out", "err"], output_resource: R
"resource",
{
"name": f"slurm_std{variant}",
"workunitid": self.workunit_definition.workunit_id,
"workunitid": self.workunit_definition.registration.workunit_id,
"storageid": self._log_storage.id,
"relativepath": f"/workunitid-{self._workunit.id}_resourceid-{output_resource.id}.{variant}",
},
Expand All @@ -80,10 +80,10 @@ def create_log_resource(self, variant: Literal["out", "err"], output_resource: R
def get_application_section(self, output_resource: Resource) -> dict[str, Any]:
output_url = f"bfabric@{self._application.storage.data_dict['host']}:{self._application.storage.data_dict['basepath']}{output_resource.data_dict['relativepath']}"
inputs = defaultdict(list)
for resource in self.workunit_definition.execution.input_resources:
inputs[resource.app_name].append(f"bfabric@{resource.scp_address}")
for resource in Resource.find_all(self.workunit_definition.execution.resources, client=self._client).values():
inputs[resource.application.name].append(f"bfabric@{resource.storage.scp_address}")
return {
"parameters": self.workunit_definition.parameter_values,
"parameters": self.workunit_definition.execution.raw_parameters,
"protocol": "scp",
"input": dict(inputs),
"output": [output_url],
Expand All @@ -102,18 +102,18 @@ def get_job_configuration_section(
}

inputs = defaultdict(list)
for resource in self.workunit_definition.execution.input_resources:
for resource in Resource.find_all(self.workunit_definition.execution.resources, client=self._client).values():
web_url = Resource({"id": resource.id}, client=self._client).web_url
inputs[resource.app_name].append({"resource_id": resource.id, "resource_url": web_url})
inputs[resource.storage.name].append({"resource_id": resource.id, "resource_url": web_url})

return {
"executable": str(self.workunit_definition.executable_path),
"executable": str(self.workunit_definition.execution.executable),
"external_job_id": self._external_job_id,
"fastasequence": self._fasta_sequence,
"input": dict(inputs),
"inputdataset": None,
"order_id": self.workunit_definition.order_id,
"project_id": self.workunit_definition.project_id,
"order_id": self._order.id,
"project_id": self._project.id,
"output": {
"protocol": "scp",
"resource_id": output_resource.id,
Expand All @@ -122,7 +122,7 @@ def get_job_configuration_section(
"stderr": log_resource["stderr"],
"stdout": log_resource["stdout"],
"workunit_createdby": self._workunit.data_dict["createdby"],
"workunit_id": self.workunit_definition.workunit_id,
"workunit_id": self.workunit_definition.registration.workunit_id,
"workunit_url": self._workunit.web_url,
}

Expand All @@ -147,7 +147,7 @@ def write_results(self, config_serialized: str) -> None:
{
"name": "job configuration (executable) in YAML",
"context": "WORKUNIT",
"workunitid": self.workunit_definition.workunit_id,
"workunitid": self.workunit_definition.registration.workunit_id,
"description": "This is a job configuration as YAML base64 encoded. It is configured to be executed by the B-Fabric yaml submitter.",
"base64": base64.b64encode(config_serialized.encode()).decode(),
"version": "10",
Expand All @@ -156,7 +156,7 @@ def write_results(self, config_serialized: str) -> None:
yaml_workunit_externaljob = self._client.save(
"externaljob",
{
"workunitid": self.workunit_definition.workunit_id,
"workunitid": self.workunit_definition.registration.workunit_id,
"status": "new",
"executableid": yaml_workunit_executable["id"],
"action": "WORKUNIT",
Expand Down

0 comments on commit 2381dea

Please sign in to comment.