Skip to content

Commit

Permalink
doc: how to and agent name
Browse files Browse the repository at this point in the history
  • Loading branch information
maffettone committed Apr 8, 2024
1 parent b0f22db commit 4b85234
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
10 changes: 9 additions & 1 deletion containers/gsas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ We had to use the conda install because the pure Fedora and Ubuntu image ran int
cd /path/to/pdf-agents
curl https://subversion.xray.aps.anl.gov/admin_pyGSAS/downloads/gsas2full-Latest-Linux-x86_64.sh > ./containers/gsas/gsas2full-Latest-Linux-x86_64.sh
podman build --platform linux/amd64 -t gsas:conda -f containers/gsas/Containerfile-conda .
podman run -it --rm gsas:conda conda run -n GSASII --no-capture-output ipython
podman run -v ./pdf_agents:/src/pdf-agents/pdf_agents:ro -it --rm gsas:conda conda run -n GSASII --no-capture-output ipython
```

## Poking around with the agent
```python
import tiled.client.node # Workaround for API issue
from pdf_agents.gsas import RefinementAgent
offline_obj = RefinementAgent.get_offline_objects()
agent = RefinementAgent(cif_paths = [], refinement_params = [], inst_param_path = "", report_producer=offline_obj["kafka_producer"], offline=True)
```
37 changes: 35 additions & 2 deletions pdf_agents/gsas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,41 @@
import numpy as np
from numpy.typing import ArrayLike

from pdf_agents.agents import PDFBaseAgent, PDFReporterMixin

logger = logging.getLogger(__name__)


# class RefinementAgent(PDFReporterMixin, PDFBaseAgent):
class RefinementAgent:
class RefinementAgent(PDFReporterMixin, PDFBaseAgent):
"""_summary_
Parameters
----------
cif_paths : List[Union[str, Path]]
Cif paths for the refinements
refinement_params : List[dict]
Dictionaries of refinement parameters for each cif
inst_param_path : Union[str, Path]
Path to instrument parameters file
Attributes
----------
cif_paths : List[Union[str, Path]]
Cif paths for the refinements
refinement_params : List[dict]
Dictionaries of refinement parameters for each cif
inst_param_path : Union[str, Path]
Path to instrument parameters file
Examples
--------
This agent is designed to be used in offline mode. It can be used as follows:
>>> import tiled.client.node # Workaround for API issue
>>> from pdf_agents.gsas import RefinementAgent
>>> offline_obj = RefinementAgent.get_offline_objects()
>>> agent = RefinementAgent(cif_paths = [], refinement_params = [], inst_param_path = "",
report_producer=offline_obj["kafka_producer"], offline=True)
"""

def __init__(
self,
Expand Down Expand Up @@ -57,6 +87,9 @@ def inst_param_path(self, inst_param_path):
self._inst_param_path = inst_param_path
self.close_and_restart()

def name(self):
return "GSAS-Refinement-Agent"

def unpack_run(self, run):
self._recent_uid = run.metadata["start"]["uid"]
return super().unpack_run(run)
Expand Down

0 comments on commit 4b85234

Please sign in to comment.