===================================================== Artificial SMB File Sharing Protocol Resource Library ===================================================== This page has all the information specific to the SMB file sharing protocol resource libary. SMB :file:`pyproject.toml` Dependencies --------------------------------------- To add SMB support to your adapter, run the command ``uv add artificial-smb-resource-library==0.0.*`` Your :file:`pyproject.toml` file should now include ``artificial-smb-resource-library`` in the project dependencies section: .. code-block:: python [project] dependencies = [ "artificial-smb-resource-library==0.0.*", ] Venus Adapter :file:`config.yaml` File -------------------------------------- .. code-block:: yaml :caption: :file:`config.yaml` log: level: "DEBUG" loggerLevels: - logger: "tutorial" level: "DEBUG" artificial: host: your-instance.artificial.com lab: lab_1a2b3c-4d5e-6f7g-8h9i-123456abcdef adapter: name: SmbTutorialAdapter remoteConfig: True allowAnySequenceId: True # Useful when running in a local dev container #. Update the artificial section to the correct host and lab. Consult the corresponding step in :doc:`tutorial_adapter_hardware_setup` for how to do this. .. note:: When you configure the adapter in LabOps, enter the ip address as just the server name or ip address, no :file:`http://` needed. Also, fill in the username and password. SMB :file:`adapter/main/plugin.py` File --------------------------------------- .. code-block:: python :caption: :file:`adapter/main/plugin.py` file from artificial.adapter_common import ActionModulePlugin, action_modules from artificial.adapter_common.plugin import PluginContext, plugin_config from artificial.logging import get_logger from artificial.smb.actions import SMBActions from artificial.smb.config.config import SMBConfig logger = get_logger(__name__) @action_modules(SMBActions) class AdapterPlugin(ActionModulePlugin): cfg = plugin_config(SMBConfig) async def setup(self, pctx: PluginContext) -> None: self.add_module(SMBActions(self.cfg)) SMB Adapter :file:`adapter/main/__main__.py` File --------------------------------------------------- Copy the following list of actors into the file in place of the example actors. .. code-block:: python actors = [ ActorConfig(id='smb', abilities={'smb': 1}), ] SMB Sample Workflow ------------------- This workflow will get the list of files at the given path and display that in Artificial. For path enter only the shared file path, no server name needed, e.g. :file:`smb\\test`. After copying this code into a file, remember to replace the lab_guid in the workflow heading with the one from your Lab (most easily found by opening the Lab in Artificial and looking in the browser address bar). Consult :doc:`tutorial_adding_tutorial_workflow` for more info. .. code-block:: python from artificial.workflows.decorators import parameter, workflow from artificial.workflows.runtime import show_info from stubs.stubs_actions import get_files @parameter('smb_folder_path', {'required': True, 'uiTitle': 'Folder Path'}) @workflow('Simple SMB Test Workflow', 'simple_smb_workflow', 'lab_3d1485d1-020b-40cd-8acd-c2226eea164d') async def simple_smb_workflow(smb_folder_path: str) -> None: files = await get_files(smb_folder_path=smb_folder_path) filestring = 'The files at that path are: ' for file in files: filestring += file + ', ' await show_info(filestring) await show_info('Congratulations, you successfully ran the SMB workflow!', 'Hardware Success') Full SMB API ------------ .. autoclass:: artificial.smb.config.config.SMBConfig :members: :undoc-members: .. autoclass:: artificial.smb.actions.SMBActions :members: :undoc-members: