Skip to main content

Tests

FiLoc File Locator

Filoc makes the saving, reading and analysis of files easy: You files are the database.

Machine Learning Swiss Knife

In machine learning, we use it to schedule, record, and analyze hundreds of machine learning experiences without the need of any service.

Schedule Simulations

Prepare hyperparameters for all your simulations at one place in a pandas dataframe or in an excel sheet. Save the simulation configurations into the folder structure of your choice, along with the processing state.

Record Simulations

In the algorithm script, you do not need to introduce any dependency to filoc. Just open the files previously written in the simulation folder. Nevertheless, you can also use filoc to harmonize your file handling.

Analyze Simulations

While the simulation are running or after, you can get insight on any information about the current results. Filoc doesn't do any difference between the simulation state, the hyperparameters and the result files of your simulations: it handles all in the same way and displays statistical analysis along with the hyperparameters.

Basic

import os
from filoc import Filoc

loc = Filoc('/data/simid={simid:d}/epid={epid:d}/settings.json') 

#--------------------------------------------------------------
# Build the path for simid=0 and epid=1, then write to the file
#--------------------------------------------------------------
path1 = loc.get_path(simid=0, epid=1)  # /data/simid=0/epid=1/settings.json
os.makedirs(os.path.dirname(path1))
with open(path1, 'w') as f:
    f.write('Coucou')

#--------------------------------------------------------------
# Same for simid=0 and epid=1 with a more compact syntax
#--------------------------------------------------------------
with loc.open(dict(simid=0, epid=2), 'w') as f:  # file handle to /data/simid=0/epid=2/settings.json
    f.write('Salut')

#--------------------------------------------------------------
# Find all files on file system having simid=0
#--------------------------------------------------------------
paths = loc.find_paths(simid=0)          # ['/data/simid=0/epid=1/settings.json', '/data/simid=0/epid=2/settings.json']

#--------------------------------------------------------------
# Extract properties for path paths[0]
#--------------------------------------------------------------
props = loc.get_path_properties(paths[0]) # { 'simid': 0, 'epid': 1 }

#--------------------------------------------------------------
# More compact form to get both the paths and their related properties
#--------------------------------------------------------------
for path, props in loc.find_paths_and_properties(simid=0):
    print(path, props)

#--------------------------------------------------------------
# Analyse all files and build a report
#--------------------------------------------------------------
def get_file_report(f):
    content = f.read()
    return { 'content_length' : len(content) }

report = loc.report(dict(simid=0), get_file_report, 'r')

print(report) #-> [{"simid":0, "epid":1, "content_length":6}, {"simid":0, "epid":2, "content_length":5}]

from pandas import DataFrame
print(DataFrame(report)) #-> convert report to pandas DataFrame 

#--------------------------------------------------------------
# Analyse all files and build a report
#--------------------------------------------------------------
def my_analysis(f):
    content = f.read()
    return { 'content_length' : len(content) }

fimap = Filoc(loc, my_analysis)

report = fimap.read_contents(simid=0)

print(report) #-> [{"simid":0, "epid":1, "content_length":6}, {"simid":0, "epid":2, "content_length":5}]

from pandas import DataFrame
print(DataFrame(report)) #-> convert report to pandas DataFrame 

Install

pip install filoc

Syntax

The FiLoc constructor accepts a file path/url, which will finally be interpreted by fsspec. That way, it is possible to access ftp, HDFS or any other file repository supported by fsspec. The path is at the same time a format string with named placeholder, which will be parsed by the parse library. Each placeholder defines a property associated to the files to save, retrieve or analyse.

ToDos

  • Readme Doc
  • API Doc
  • File locking
  • Unit Test
    • Multiloc with different aggregation layers (snowflake)
    • File locking
  • Dev: Logging of edited files
  • Dev: File watcher
  • Dev: Excel File watcher / binder

Metadata

Release files for filoc 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for filoc 0.0.8
File Size Uploaded
filoc-0.0.8.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for filoc 0.0.8
File Interpreter ABI Platform
filoc-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 28.0 kB

Release files / filoc-0.0.8.tar.gz

Download URL filoc-0.0.8.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b4a73c559a99bd95003719a2a0eaf9c0e92232f57d3310c7aa7e3cf9f8b84488
BLAKE2b-256 checksum
How to use checksums
c1802f054899d5fee76e3caf0726297b5f525738370f3948004b5eed24face6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release files / filoc-0.0.8-py3-none-any.whl

Download URL filoc-0.0.8-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b5332ec56606718697309cf8051a2699e09fce3ae6f3f44caa932ed28fbd8afa
BLAKE2b-256 checksum
How to use checksums
4b06fdcdb189f862e1408b33d6a99209987fd6e547a2d5626a58e83873d4624d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release history Release notifications | RSS feed

0.0.24

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.17

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.10

2 release files

0.0.9

2 release files

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page